Public Methods | |
Listener () | |
By default, listener not registered. | |
virtual | ~Listener () |
Automatically deregister ourselves. | |
void | ignoreEvents () |
void | listenForEvents () |
void | ignoreThisEvent () |
void | processEventPublic (const EvType &) |
bool | isRegistered () const |
Protected Methods | |
virtual void | processEvent (const EvType &event)=0 |
class YourListener: public Listener<TicEvent>, public Listener<TacEvent> { public: YourListener() { Listener<TicEvent>::listenForEvents(); Listener<TacEvent>::listenForEvents(); } protected: virtual void processEvent(const TicEvent& event) {...} virtual void processEvent(const TacEvent& event) {...} };
struct TicEvent {...}; class YourListener: public Listener<TicEvent> {...}; class DerivedListener: public YourListener { public: // ... protected: virtual void processEvent(const TicEvent& event) { // give parent class a chance to process event YourListener::processEvent(event); // do our stuff ... } };
Definition at line 24 of file Listener.hh.
|
Tell EventSender<EvType> that this listener is not interested in hearing EvType events. This does nothing if already ignoring them. Definition at line 59 of file Listener.cc. |
|
Tell EventSender<EvType> that this listener is ignoring the event received. This will increment a counter in EventSender<EvType>, such that a call to EventSender<EvType>::getNumIgnored() will return how many listeners ignored the event. Note however that the listener is not required to notify EventSender<EvType> that it is ignoring the event, hence this number is only a minimum. This method can be called more than once without screwing up the count. If called from outside a call to Listener<EvType>::processEvent(), nothing is done. Definition at line 39 of file Listener.cc. References EventSender< EvType >::isSending(). |
|
Is this instance of listener registered? If not, it will not receive events of type EvType, processEvent() will not be called. To register it, call listenForEvents().
Definition at line 45 of file Listener.hh. |
|
Tell EventSender<EvType> that this listener wants to hear EvType events. This does nothing if already listening to them. Definition at line 75 of file Listener.cc. |
|
Classes that inherit from Listener must override this method. This is where you react to the event heard.
Referenced by Listener< EvType >::processEventPublic(). |
|
Process this event. This public method can be called directly with an event to simulate an event having been generated and heard by this listener. It is also called by EventSender<EvType>::send(). This public method is a "template pattern" method, in that it calls several private methods but most importantly calls the protected, virtual processEvent(). Since the latter is virtual it is the definition in the most derived class of this Listener<EvType> that will get called. The event is passed as const, so listeners can't change the data carried by the event.
Definition at line 101 of file Listener.hh. References Listener< EvType >::processEvent(). |