Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

Application Class Reference

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

#include <cxxtools/application.h>

Inheritance diagram for Application:

Connectable List of all members.

Public Member Functions

 Application (int argc=0, char **argv=0)
 Application (EventLoopBase *loop, int argc=0, char **argv=0)
EventLoopBaseloop ()
void run ()
void exit ()
bool catchSystemSignal (int sig)
bool raiseSystemSignal (int sig)
int argc () const
char ** argv () const
ApplicationImpl & impl ()

Static Public Member Functions

static Applicationinstance ()

Public Attributes

Signal< int > systemSignal

Protected Member Functions

void init (EventLoopBase &loop)

Detailed Description

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.

Copyright © 2008 The Tntnet Development Team
Tntnet 1.6