Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

Eris::Timeout Class Reference

Timeout. More...

#include <Timeout.h>

List of all members.

Public Member Functions

 Timeout (const std::string &label, unsigned long milli)
 standard constructor for new timeouts

 Timeout (const std::string &label, void *inst, unsigned long milli)
 constructor for new timeouts which are owned by an instance of a class

Timeoutoperator= (const Timeout &t)
 assignment operator

void extend (unsigned long msec)
 extend the timeout termination by the specified time.

void reset (unsigned long msec)
 reset the timeout to the specified time, and reset the 'expired' flag.

void cancel ()
 cancel the Timeout immediately

unsigned long poll (const Time::Stamp &t)
bool isExpired () const
 test whether or not the timeout has fired or not


Static Public Member Functions

const TimeoutfindByName (const std::string &lbl, void *inst=0)
 Access an existing timeout by name.

unsigned long pollAll ()
 poll all running timeouts.

void extendByName (const std::string &lbl, unsigned long msec)
 helper function to lookup a timeout and call extend().

void extendByName (const std::string &lbl, void *inst, unsigned long msec)
void cancelByName (const std::string &lbl, void *inst=0)
 helper function to lookup a timeout and call cancel().


Public Attributes

SigC::Signal0< void > Expired
 The timeout signal.


Protected Types

typedef std::map< Label, Timeout * > TimeoutMap

Protected Attributes

const Label _label
 the unique label of the timeout

Time::Stamp _due
 interval at which the timeout is due

bool _fired
 flag if the timeout has expired


Static Protected Attributes

TimeoutMap _allTimeouts


Detailed Description

Timeout.


Constructor & Destructor Documentation

Eris::Timeout::Timeout const std::string &  label,
unsigned long  milli
 

standard constructor for new timeouts

Parameters:
label The unique timeout identification label
milli The initial timeout value, in milliseconds

Eris::Timeout::Timeout const std::string &  label,
void *  inst,
unsigned long  milli
 

constructor for new timeouts which are owned by an instance of a class

Parameters:
label The unique timeout identification label
milli The initial timeout value, in milliseconds
inst The class instance pointer (used as unique ID)


Member Function Documentation

void Eris::Timeout::cancelByName const std::string &  lbl,
void *  inst = 0
[static]
 

helper function to lookup a timeout and call cancel().

As above, a missing timeout will cause an InvalidOperation to be thrown.

void Eris::Timeout::extend unsigned long  msec  ) 
 

extend the timeout termination by the specified time.

This has no effect if the timeout has already fired

Parameters:
msec The interval to extend the timeout by, in milliseconds

void Eris::Timeout::extendByName const std::string &  lbl,
unsigned long  msec
[inline, static]
 

helper function to lookup a timeout and call extend().

If the timeout is not found, InvalidOperation will be thrown

const Timeout * Eris::Timeout::findByName const std::string &  lbl,
void *  inst = 0
[static]
 

Access an existing timeout by name.

This will throw an exception if no such timeout exists. Also note that it returns a reference, so don't mis-treat the poor thing

unsigned long Eris::Timeout::pollAll  )  [static]
 

poll all running timeouts.

This calls poll() on each timeout, and hence triggers expiry signals and so on. Timeout accuracy is directly related to how frequently polling is done (but timeouts aren't supposed to be accurate, so once per main loop iteration should be fine)

void Eris::Timeout::reset unsigned long  msec  ) 
 

reset the timeout to the specified time, and reset the 'expired' flag.

This means invoking reset() is equivalent to destroying the Timeout object and creating a new one with the same name.


The documentation for this class was generated from the following files:
Generated on Thu Jul 29 08:12:34 2004 for Eris by doxygen 1.3.7