code::LBEventHandler Class Reference

Inheritance diagram for code::LBEventHandler:

code::EventHandler List of all members.

Detailed Description

The event notification is based on the LinearBuffer, from the Open RPG development group.

Posting processes write their messages to a well-known linear buffer (that is agreed upon) and receiving processes ask to be notified.

The EventHandler provides a registration interface. To post, write to the LinearBuffer (using LBWriter, for example).

Author:
Lakshman
Version:
Id
code_LBEventHandler.h,v 1.10 2009/06/02 20:17:38 lakshman Exp


Public Member Functions

 LBEventHandler (const URL &lb_url, SmartPtr< EventCallback > cb)
 To register to be notified of something, pass LinearBuffer URL and a pointer to a callback.
virtual ~LBEventHandler ()

Static Public Member Functions

static void introduceSelf ()
static void setNumberCallbacksToSave (size_t num)
 This only makes sense for the _rss, but by promoting it up to the base class we can avoid a lot of ifdefs in client code.
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.

Public Attributes

LBEventHandlerImpl * _impl

Protected Member Functions

virtual void addCallbacks ()
 This should effectively be a static function that adds to EventHandler's allCallbacks.
virtual void resumeAllNotification ()
 This should effectively be a static function that resumes all notification that was paused by this class.
virtual void pauseAllNotification ()
 This should effectively be a static function that pauses all notification for this class.

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.


Constructor & Destructor Documentation

code::LBEventHandler::LBEventHandler ( const URL lb_url,
SmartPtr< EventCallback cb 
)

To register to be notified of something, pass LinearBuffer URL and a pointer to a callback.

The callback's actionPerformed() function will be called when the linear buffer gets written into.

The EventHandler needs to be kept as long as the callback is required. When the EventHandler is destroyed (or goes out of scope), the callback is de-registered.

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


Member Function Documentation

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

This should effectively be a static function that adds to EventHandler's allCallbacks.

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 void code::EventHandler::introduce ( SmartPtr< EventHandler subclass  )  [static, protected, inherited]

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

virtual void code::LBEventHandler::pauseAllNotification (  )  [protected, virtual]

This should effectively be a static function that pauses all notification for this class.

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.

virtual void code::LBEventHandler::resumeAllNotification (  )  [protected, virtual]

This should effectively be a static function that resumes all notification that was paused by this class.

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]

static void code::LBEventHandler::setNumberCallbacksToSave ( size_t  num  )  [static]

This only makes sense for the _rss, but by promoting it up to the base class we can avoid a lot of ifdefs in client code.


Member Data Documentation

LBEventHandlerImpl* code::LBEventHandler::_impl

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

The set of all the event callbacks.


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