Logo Search packages:      
Sourcecode: poco version File versions  Download package

Poco::Util::Application Class Reference

#include <Application.h>

Inheritance diagram for Poco::Util::Application:

Poco::Util::Subsystem Poco::RefCountedObject HTTPLoadTest Ping Poco::Util::ServerApplication SampleApp EchoServer HTTPFormServer HTTPSTimeServer HTTPTimeServer TimeServer

List of all members.


Detailed Description

The Application class implements the main subsystem in a process. The application class is responsible for initializing all its subsystems.

Subclasses can and should override the following virtual methods:

The application's main logic should be implemented in the main() method.

There may be at most one instance of the Application class in a process.

The Application class maintains a LayeredConfiguration (available via the config() member function) consisting of:

The Application class sets a few default properties in its configuration. These are:

If loadConfiguration() has never been called, application.configDir will be equal to application.dir.

The POCO_APP_MAIN macro can be used to implement main(argc, argv). If POCO has been built with POCO_WIN32_UTF8, POCO_APP_MAIN supports Unicode command line arguments.

Definition at line 64 of file Application.h.


Public Types

enum  ConfigPriority { PRIO_APPLICATION = -100, PRIO_DEFAULT = 0, PRIO_SYSTEM = 100 }
enum  ExitCode {
  EXIT_OK = 0, EXIT_USAGE = 64, EXIT_DATAERR = 65, EXIT_NOINPUT = 66,
  EXIT_NOUSER = 67, EXIT_NOHOST = 68, EXIT_UNAVAILABLE = 69, EXIT_SOFTWARE = 70,
  EXIT_OSERR = 71, EXIT_OSFILE = 72, EXIT_CANTCREAT = 73, EXIT_IOERR = 74,
  EXIT_TEMPFAIL = 75, EXIT_PROTOCOL = 76, EXIT_NOPERM = 77, EXIT_CONFIG = 78
}

Public Member Functions

void addSubsystem (Subsystem *pSubsystem)
 Creates the Application and calls init(argc, argv).
 Application (int argc, char *argv[])
 Creates the Application.
std::string commandName () const
LayeredConfigurationconfig () const
 Returns the command name used to invoke the application.
void duplicate () const
template<class C>
C & getSubsystem () const
void init (const std::vector< std::string > &args)
void init (int argc, char *argv[])
bool initialized () const
void loadConfiguration (const std::string &path, int priority=PRIO_DEFAULT)
int loadConfiguration (int priority=PRIO_DEFAULT)
Poco::Loggerlogger () const
 Returns the application's configuration.
const char * name () const
const OptionSetoptions () const
int referenceCount () const
void release () const
 Increments the object's reference count.
virtual int run ()
void setUnixOptions (bool flag)
const Poco::TimestampstartTime () const
void stopOptionsProcessing ()
 Returns the application uptime.
Poco::Timespan uptime () const
 Returns the application start time (UTC).

Static Public Member Functions

static Applicationinstance ()
 Returns the application's option set.

Protected Member Functions

virtual void defineOptions (OptionSet &options)
bool findFile (Poco::Path &path) const
virtual void handleOption (const std::string &name, const std::string &value)
void init ()
void initialize (Application &self)
virtual int main (const std::vector< std::string > &args)
 Sets the logger used by the application.
void reinitialize (Application &self)
void setLogger (Poco::Logger &logger)
void uninitialize ()
 ~Application ()
 Common initialization code.

Private Types

typedef std::vector< std::string > ArgVec
typedef Poco::AutoPtr
< LayeredConfiguration
ConfigPtr
typedef Poco::AutoPtr< SubsystemSubsystemPtr
typedef std::vector< SubsystemPtrSubsystemVec

Private Member Functions

bool findAppConfigFile (const std::string &appName, const std::string &extension, Poco::Path &path) const
void getApplicationPath (Poco::Path &path) const
void processOptions ()
void setArgs (const std::vector< std::string > &args)
void setArgs (int argc, char *argv[])
void setup ()
 Destroys the Application and deletes all registered subsystems.

Private Attributes

ArgVec _args
std::string _command
bool _initialized
OptionSet _options
ConfigPtr _pConfig
Poco::Logger_pLogger
Poco::Timestamp _startTime
bool _stopOptionsProcessing
SubsystemVec _subsystems
bool _unixOptions

Static Private Attributes

static Application_pInstance = 0

Friends

class Application
 Destroys the Subsystem.
class LoggingSubsystem

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index