Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

base::STEventDaemon Class Reference

Single-threaded event driven daemon class. More...

#include <libppbase/base/STEventDaemon.h>

Inheritance diagram for base::STEventDaemon:
base::Daemon base::Mutex

List of all members.

Public Types

typedef void(* fdCallback )(int fd, int what, void *user)
 The definition of a file descriptor callback (which might be a socket, pipe, semaphore, ...).

Public Member Functions

virtual ~STEventDaemon ()
 Destructor.
void addCallback (int fd, fdCallback callback, void *user=NULL)
 Adds a callback to invoke when an event occurred on a descriptor.
void delCallback (int fd)
 Removes a callback.

Protected Member Functions

 STEventDaemon (const String &name)
 Constructor.
virtual void config ()
 Configures the daemon.
bool dumpState (bool force)
 Dumps the daemon state into the log file.
virtual int loop ()
 The main loop.

Protected Attributes

DynamicArray< int > _fds
 the descriptors to wait for events
std::map< int, std::pair
< fdCallback, void * > > 
_fdcallbacks
 descriptor callbacks

Detailed Description

Single-threaded event driven daemon class.

Author:
Christoph Schwarz
Version:
$Id: STEventDaemon.h 21 2010-09-05 04:18:17Z cschwarz1 $

Member Typedef Documentation

typedef void(* base::STEventDaemon::fdCallback)(int fd, int what, void *user)

The definition of a file descriptor callback (which might be a socket, pipe, semaphore, ...).

Parameters:
fd the file descriptor
what the events occurred on the file descriptor
user the user data

Constructor & Destructor Documentation

base::STEventDaemon::STEventDaemon ( const String name  )  [protected]

Constructor.

Parameters:
name daemon name

Member Function Documentation

void base::STEventDaemon::addCallback ( int  fd,
fdCallback  callback,
void *  user = NULL 
)

Adds a callback to invoke when an event occurred on a descriptor.

Parameters:
fd the descriptor
callback the callback to invoke
user user data to pass to the callback
void base::STEventDaemon::delCallback ( int  fd  ) 

Removes a callback.

Parameters:
fd the descriptor to remove the callback for
bool base::STEventDaemon::dumpState ( bool  force  )  [protected, virtual]

Dumps the daemon state into the log file.

The daemon state contains information on its internal state

Parameters:
force force dump, otherwise it is only dumped if the last dump was more than one minute ago
Returns:
true if the state has been dumped, false if not

Reimplemented from base::Daemon.

virtual int base::STEventDaemon::loop (  )  [protected, virtual]

The main loop.

Returns:
the daemon's exit code

Implements base::Daemon.


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