The Application class provides an event loop for console applications without a GUI. More...

#include <cxxtools/application.h>

Inheritance diagram for cxxtools::Application:
cxxtools::Connectable

Public Member Functions

 Application ()
 Application (int argc, char **argv)
 Application (EventLoopBase *loop)
 Application (EventLoopBase *loop, int argc, char **argv)
 ~Application ()
EventLoopBaseloop ()
void run ()
void exit ()
bool catchSystemSignal (int sig)
bool raiseSystemSignal (int sig)
int argc () const
char ** argv () const
ApplicationImpl & impl ()
- Public Member Functions inherited from cxxtools::Connectable
 Connectable ()
 Default constructor.
virtual ~Connectable ()
 Closes all connections.
virtual void onConnectionOpen (const Connection &c)
 Registers a Connection with the Connectable.
virtual void onConnectionClose (const Connection &c)
 Unregisters a Connection from the Connectable.
size_t connectionCount () const

Static Public Member Functions

static Applicationinstance ()

Public Attributes

Signal< int > systemSignal

Protected Member Functions

void init (EventLoopBase &loop)
- Protected Member Functions inherited from cxxtools::Connectable
 Connectable (const Connectable &)
 Copy constructor.
Connectableoperator= (const Connectable &)
 Assignment operator.
const std::list< Connection > & connections () const
 Returns a list of all current connections.
std::list< Connection > & connections ()
 Returns a list of all current connections.
void clear ()

Additional Inherited Members

- Protected Attributes inherited from cxxtools::Connectable
std::list< Connection_connections
 A list of all current connections.

Detailed Description

The Application class provides an event loop for console applications without a GUI.

This class is used by non-GUI applications to provide the applications's event loop. There should be only exactly one instance of Application (or one of its subclasses) per application. This is not ensured, though.

Application contains the main event loop, where event sources can be registered and events from those sources are dispatched to listeners, that were registered to the event loop. Events may for example be operating system events (timer, file system changes).

The application and therefore the event loop is started with a call to run() and can be exited with a call to exit(). After calling exit() the application should terminate.

The event loop can be access by calling eventLoop(). Events can be committed by calling EventLoop::commitEvent(). Long running operations can call EventLoop::processEvents() to keep the application responsive.

There are convenience methods available for easier access to functionality of the underlying event loop. commitEvent() delegates to EventLoop::commitEvent(), queueEvent() delegates to EventLoop::delegateEvent() and processEvents() delegates to EventLoop::processEvents() without making it necessary to first obtain the event loop manually.

Constructor & Destructor Documentation

cxxtools::Application::Application ( )
cxxtools::Application::Application ( int  argc,
char **  argv 
)
cxxtools::Application::Application ( EventLoopBase loop)
cxxtools::Application::Application ( EventLoopBase loop,
int  argc,
char **  argv 
)
cxxtools::Application::~Application ( )

Member Function Documentation

int cxxtools::Application::argc ( ) const
inline
char** cxxtools::Application::argv ( ) const
inline
bool cxxtools::Application::catchSystemSignal ( int  sig)
void cxxtools::Application::exit ( )
inline
ApplicationImpl& cxxtools::Application::impl ( )
inline
void cxxtools::Application::init ( EventLoopBase loop)
protected
static Application& cxxtools::Application::instance ( )
static
EventLoopBase& cxxtools::Application::loop ( )
inline
bool cxxtools::Application::raiseSystemSignal ( int  sig)
void cxxtools::Application::run ( )
inline

Member Data Documentation

Signal<int> cxxtools::Application::systemSignal

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