code::TimedEventHandler Class Reference

Inheritance diagram for code::TimedEventHandler:

code::EventHandler List of all members.

Detailed Description

This class allows you to set up ActionListeners to be called every N milliseconds.

The check for past-due events is done during a call to EventHandler::handle_events(). It is a singleton, i.e. all the ActionListeners are managed by the same TimedEventHandler

Author:
Lakshman
See also:
EventHandler
Version:
Id
code_TimedEventHandler.h,v 1.7 2011/08/02 17:29:28 Valliappa.Lakshmanan Exp


Public Member Functions

virtual ~TimedEventHandler ()
void addActionListener (size_t msec, SmartPtr< ActionListener > listener, int roundOff_inSeconds=-1)
 Add a listener to be notified once every N milliseconds.
void removeActionListener (SmartPtr< ActionListener > listener)
 Remove a particular ActionListener.

Static Public Member Functions

static TimedEventHandlerinstance ()
static void introduceSelf ()
static void handle_events ()
 It is the user's responsibility to call this function once in a while.
static void setIdleTime (size_t milliseconds)
 Change the idle time that handle_events will wait, so that the CPU is not caught in a do-nothing mode.
static void pauseNotification ()
 When calling a non-reentrant function (outside of a callback), it might be useful to turn off the signal, so that you are not interrupted.
static void resumeNotification ()
 Resume notification after it has been paused.

Protected Member Functions

virtual void addCallbacks ()
 adds to EventHandler's allCallbacks if past due.

Static Protected Member Functions

static void introduce (SmartPtr< EventHandler > subclass)
static void setMaxCallbacks ()

Static Protected Attributes

static std::vector< CallbackInfo > allCallbacks
 The set of all the event callbacks.

Classes

class  ListenerHandle
 Listener Handle holds an ActionListener and keeps track of past due times for each handler.
class  TimerEvent
 TimerEvents are launched by the TimedEventHandler. More...


Constructor & Destructor Documentation

virtual code::TimedEventHandler::~TimedEventHandler (  )  [virtual]


Member Function Documentation

void code::TimedEventHandler::addActionListener ( size_t  msec,
SmartPtr< ActionListener listener,
int  roundOff_inSeconds = -1 
)

Add a listener to be notified once every N milliseconds.

The listener's actionPerformed method will be passed in an ActionEvent of type TimerEvent If roundOff is 300, then the timer event will be invoked at 0,5,10,15,20,...55 after the hour. Pass in negative if the timer event should be invoked msec after the previous one

virtual void code::TimedEventHandler::addCallbacks (  )  [protected, virtual]

adds to EventHandler's allCallbacks if past due.

Reimplemented from code::EventHandler.

static void code::EventHandler::handle_events (  )  [static, inherited]

It is the user's responsibility to call this function once in a while.

When the function is called, the callbacks associated with all the events that have happened so far are invoked.

If there are no callbacks to process, handle_events will sleep a while before returning, so as to avoid over-loading the CPU waiting for messages.

You can set this sleep interval using setIdleTime()

static TimedEventHandler& code::TimedEventHandler::instance (  )  [static]

static void code::EventHandler::introduce ( SmartPtr< EventHandler subclass  )  [static, protected, inherited]

static void code::TimedEventHandler::introduceSelf (  )  [static]

static void code::EventHandler::pauseNotification (  )  [static, inherited]

When calling a non-reentrant function (outside of a callback), it might be useful to turn off the signal, so that you are not interrupted.

In this case, signals will be queued up and delivered on a resume call.

Pauses may not be nested. If a re-entrant form of your function exists, you might want to use it instead of using the pause facility.

Note: This function is not needed in the threaded OPUP environment. Re-entrant functions are safe in that context.

void code::TimedEventHandler::removeActionListener ( SmartPtr< ActionListener listener  ) 

Remove a particular ActionListener.

static void code::EventHandler::resumeNotification (  )  [static, inherited]

Resume notification after it has been paused.

static void code::EventHandler::setIdleTime ( size_t  milliseconds  )  [static, inherited]

Change the idle time that handle_events will wait, so that the CPU is not caught in a do-nothing mode.

The default is 1 second.

You can set it to zero, if needed.

static void code::EventHandler::setMaxCallbacks (  )  [static, protected, inherited]


Member Data Documentation

std::vector< CallbackInfo > code::EventHandler::allCallbacks [static, protected, inherited]

The set of all the event callbacks.


Generated on Fri May 4 13:40:13 2012 for WDSS-IIw2 by  doxygen 1.4.7