#include <typeinfo>
#include "rutz/shared_ptr.h"
#include "rutz/demangle.h"
#include "Simulation/SimEventQueueFlag.H"
#include "Util/log.H"
#include "Util/sformat.H"
Go to the source code of this file.
Classes | |
class | SimCallbackBase |
A SimEventQueue callback for SimModule. More... | |
class | SimCallback< Module, Event > |
Template class for SimEventQueue callbacks. More... | |
struct | SimCallbackCompare |
Functor used to compare two SimCallbackBase objects, sorting by priority. More... | |
Defines | |
#define | SIMCALLBACK_DECLARE(classname, eventname) |
Macro to declare a SimCallback (use in your .H). | |
#define | SIMCALLBACK_INIT(eventname,...) itsCallback##eventname(this, &itsSimCallbackClassTypeFor##eventname::on##eventname, ## __VA_ARGS__ ) |
Init a SimCallback created by SIMCALLBACK_DECLARE. |
A callback when some SimEvent is received by SimEventQueue
Definition in file SimCallback.H.
#define SIMCALLBACK_DECLARE | ( | classname, | |||
eventname | ) |
void on##eventname(SimEventQueue& q, rutz::shared_ptr<eventname>& e); \ typedef classname itsSimCallbackClassTypeFor##eventname; \ SimCallback<classname, eventname> itsCallback##eventname;
Macro to declare a SimCallback (use in your .H).
This will declare a SimCallback called itsCallback[eventname] and a function called on[eventname] which you will need to implement. For example:
is equivalent to:
void onSimEventInputFrame(SimEventQueue& q, rutz::shared_ptr<SimEventInputFrame>& e); SimCallback<Retina, SimEventInputFrame> itsCallbackSimEventInputFrame;
then make sure you use the macro SIMCALLBACK_INIT in your class constructor, and that you implement onSimEventInputFrame() somewhere in your .C file. In our example:
Retina::Retina(...) : ..., SIMCALLBACK_INIT(SimEventInputFrame) { } void Retina::onSimEventInputFrame(SimEventQueue& q, rutz::shared_ptr<SimEventInputFrame>& e) { do_something(); }
Have a look at Retina and other modules in src/Neuro for examples of usage.
Definition at line 220 of file SimCallback.H.
#define SIMCALLBACK_INIT | ( | eventname, | |||
... | ) | itsCallback##eventname(this, &itsSimCallbackClassTypeFor##eventname::on##eventname, ## __VA_ARGS__ ) |
Init a SimCallback created by SIMCALLBACK_DECLARE.
Takes possible optional arguments which are the ones that have default values in the SimCallback constructor, namely: const int priority = 0, const SimEventQueueFlag flags = SEQ_UNMARKED | SEQ_MARK, const SimModule* eventsource = 0.
Definition at line 231 of file SimCallback.H.