SimCallbackBase Class Reference

A SimEventQueue callback for SimModule. More...

#include <Simulation/SimCallback.H>

Inheritance diagram for SimCallbackBase:
Inheritance graph
[legend]
Collaboration diagram for SimCallbackBase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SimCallbackBase (SimCallbackClient *smod, const int priority=0, const SimEventQueueFlag flags=SEQ_UNMARKED|SEQ_MARK, const SimModule *eventsource=0)
 Constructor.
virtual ~SimCallbackBase ()
 Destructor.
virtual const std::type_info & etype () const =0
 What's our underlying SimEvent type?
virtual const std::type_info & mtype () const =0
 What's our underlying SimCallbackClient (usually SimModule) type?
int priority () const
 Get the priority.
virtual SimCallbackClientclient () const =0
 Get the SimCallbackClient.
const SimEventQueueFlag sflags () const
 Get the flags.
const SimModuleeventsrc () const
 Get the desired event source, if any.
std::string toString () const
 Get some string description of ourselves, for printing/debug.
virtual void execute (SimEventQueue &q, rutz::shared_ptr< SimEvent > &e)=0
 Execute the callback.

Protected Attributes

int itsPriority
SimEventQueueFlag itsFlags
const SimModuleitsEventSrc

Detailed Description

A SimEventQueue callback for SimModule.

This is the base class. We will then create template derived classes (see ModelParamBase and ModelParam for a similar idea). The basic idea here is that a SimModule should, at construction, declare a series of callbacks which SimEventQueue will automatically call when the appropriate SimEvent objects are received by the queue. The standard C++ way of doing this typically would involve a callback class, and then derivatives of this, each one implementing the operator() in various ways (functor paradigm). However, this is not very convenient as typically the callback function would want to access the data members of its SimModule. Hence, we here use a different strategy, first declaring a function which is a member of SimModule and implements the actual code to be executed during callback, and second implementing a template "callback hook" whose role is just to connect that member function to the SimEventQueue. SimCallback is just the hook.

Definition at line 70 of file SimCallback.H.


Constructor & Destructor Documentation

SimCallbackBase::SimCallbackBase ( SimCallbackClient smod,
const int  priority = 0,
const SimEventQueueFlag  flags = SEQ_UNMARKED | SEQ_MARK,
const SimModule eventsource = 0 
)

Constructor.

Definition at line 44 of file SimCallback.C.

References SimCallbackClient::registerSimCallback().

SimCallbackBase::~SimCallbackBase (  )  [inline, virtual]

Destructor.

Definition at line 246 of file SimCallback.H.


Member Function Documentation

virtual SimCallbackClient* SimCallbackBase::client (  )  const [pure virtual]
virtual const std::type_info& SimCallbackBase::etype (  )  const [pure virtual]

What's our underlying SimEvent type?

Forbidden in the base class.

Implemented in SimCallback< Module, Event >.

Referenced by SimEventQueue::registerSimCallbackClient(), and toString().

const SimModule * SimCallbackBase::eventsrc (  )  const [inline]

Get the desired event source, if any.

Definition at line 255 of file SimCallback.H.

virtual void SimCallbackBase::execute ( SimEventQueue q,
rutz::shared_ptr< SimEvent > &  e 
) [pure virtual]

Execute the callback.

This will call the callback method on the callback client, passing it the queue and the event.

Implemented in SimCallback< Module, Event >.

virtual const std::type_info& SimCallbackBase::mtype (  )  const [pure virtual]

What's our underlying SimCallbackClient (usually SimModule) type?

Forbidden in the base class.

Implemented in SimCallback< Module, Event >.

Referenced by toString().

int SimCallbackBase::priority (  )  const [inline]

Get the priority.

Definition at line 249 of file SimCallback.H.

Referenced by toString().

const SimEventQueueFlag SimCallbackBase::sflags (  )  const [inline]

Get the flags.

Definition at line 252 of file SimCallback.H.

std::string SimCallbackBase::toString (  )  const [inline]

Get some string description of ourselves, for printing/debug.

Definition at line 258 of file SimCallback.H.

References rutz::demangled_name(), etype(), mtype(), priority(), and sformat().

Referenced by SimEventQueue::registerSimCallbackClient().


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:24:58 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3