Template class for SimEventQueue requests. More...
#include <Simulation/SimReqHandler.H>
Public Types | |
typedef void(Module::* | Method )(SimEventQueue &, rutz::shared_ptr< Req > &) |
Definition for the format and args of the called-back method. | |
Public Member Functions | |
SimReqHandler (Module *mod, Method meth, const SimModule *reqsource=0) | |
Constructor. | |
virtual | ~SimReqHandler () |
Destructor. | |
virtual const std::type_info & | rtype () const |
What's our underlying SimReq type? | |
virtual const std::type_info & | mtype () const |
What's our underlying SimReqHandlerClient (usually SimModule) type? | |
virtual SimReqHandlerClient * | client () const |
Get the SimReqHandlerClient. | |
virtual void | execute (SimEventQueue &q, rutz::shared_ptr< SimReq > &e) |
Call the callback. | |
template<class Module , class Req > | |
SimReqHandler (Module *mod, SimReqHandler< Module, Req >::Method meth, const SimModule *source) |
Template class for SimEventQueue requests.
Method 'meth' will be called by the SimEventQueue when a desired requesr is triggered. Typical usage is as follows:
in your .H:
// your class should inherit from at least SimReqHandlerClient, // typically it will inherit from SimModule which itself iherits // from SimReqHandlerClient: class MySimModule : public SimModule { ... private: // our method to run when SimReqX is posted to the queue, // will be called by SimEventQueue: void processX(SimEventQueue& q, rutz::shared_ptr<SimReqX>& e); // a hook by which we will let our SimEventQueue know about processX(): SimReqHandler<MySimModule, SimReqX> itsRHx;
in your .C, in the constructor of your class (which must be a SimReqHandlerClient derivative), in the initalizer list:
MySimModule::MySimModule() : ... itsRHx(this, &MySimModule::processX), ... { ... }
and finally you also should implement MySimModule::processX().
Definition at line 144 of file SimReqHandler.H.
typedef void(Module::* SimReqHandler< Module, Req >::Method)(SimEventQueue &, rutz::shared_ptr< Req > &) |
Definition for the format and args of the called-back method.
Definition at line 148 of file SimReqHandler.H.
SimReqHandler< Module, Req >::SimReqHandler | ( | Module * | mod, | |
Method | meth, | |||
const SimModule * | reqsource = 0 | |||
) | [inline] |
Constructor.
SimReqHandler< Module, Req >::~SimReqHandler | ( | ) | [inline, virtual] |
Destructor.
Definition at line 242 of file SimReqHandler.H.
SimReqHandlerClient * SimReqHandler< Module, Req >::client | ( | ) | const [inline, virtual] |
Get the SimReqHandlerClient.
Implements SimReqHandlerBase.
Definition at line 254 of file SimReqHandler.H.
void SimReqHandler< Module, Req >::execute | ( | SimEventQueue & | q, | |
rutz::shared_ptr< SimReq > & | e | |||
) | [inline, virtual] |
Call the callback.
Implements SimReqHandlerBase.
Definition at line 259 of file SimReqHandler.H.
References rutz::demangled_name(), and rutz::shared_ptr< T >::is_valid().
const std::type_info & SimReqHandler< Module, Req >::mtype | ( | ) | const [inline, virtual] |
What's our underlying SimReqHandlerClient (usually SimModule) type?
Implements SimReqHandlerBase.
Definition at line 250 of file SimReqHandler.H.
const std::type_info & SimReqHandler< Module, Req >::rtype | ( | ) | const [inline, virtual] |
What's our underlying SimReq type?
Implements SimReqHandlerBase.
Definition at line 246 of file SimReqHandler.H.