
#include <Simulation/SimCallback.H>
Inheritance diagram for SimCallbackBase:


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.
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 SimCallbackClient * | client () const =0 |
| Get the SimCallbackClient. | |
| const SimEventQueueFlag | sflags () const |
| Get the flags. | |
| const SimModule * | eventsrc () 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 SimModule * | itsEventSrc |
|
||||||||||||||||||||
|
Constructor.
Definition at line 44 of file SimCallback.C. References SimCallbackClient::registerSimCallback(). |
|
|
Destructor.
Definition at line 51 of file SimCallback.C. |
|
|
Get the SimCallbackClient.
Implemented in SimCallback< Module, Event >. |
|
|
What's our underlying SimEvent type? Forbidden in the base class. Implemented in SimCallback< Module, Event >. Referenced by SimEventQueue::registerSimCallbackClient(). |
|
|
Get the desired event source, if any.
Definition at line 251 of file SimCallback.H. References itsEventSrc. |
|
||||||||||||
|
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 >. |
|
|
What's our underlying SimCallbackClient (usually SimModule) type? Forbidden in the base class. Implemented in SimCallback< Module, Event >. |
|
|
Get the priority.
Definition at line 245 of file SimCallback.H. References itsPriority. Referenced by SimCallbackCompare::operator()(), and toString(). |
|
|
Get the flags.
Definition at line 248 of file SimCallback.H. References itsFlags. |
|
|
Get some string description of ourselves, for printing/debug.
Definition at line 254 of file SimCallback.H. References rutz::demangled_name(), priority(), and sformat(). Referenced by SimEventQueue::registerSimCallbackClient(). |
1.4.4