iCub-main
|
The EventDispatcher manages the relation between the various instances of IEventListeners and IEvents. More...
#include <EventDispatcher.h>
Public Member Functions | |
virtual void | addListener (IEventListener *listener) |
Adds an IEventListener to the list. | |
virtual void | removeListener (int idx) |
Removes an IEventListener from the list. | |
virtual void | removeListener (IEventListener *listener) |
Removes an IEventListener from the list. | |
virtual IEventListener & | getAt (int idx) |
Returns the IEventListener at a specified index. | |
virtual IEventListener & | getAt (int idx) const |
Returns the IEventListener at a specified index. | |
virtual void | clear () |
Clears all the IEventListeners from the EventDispatcher. | |
virtual void | raise (IEvent &event) |
Raises an IEvent, causing it to be dispatched to each registered IEventListener. | |
virtual int | countListeners () const |
Counts the number of registered listeners. | |
virtual bool | hasListeners () |
Tells whether there are listeners for events. | |
Static Public Member Functions | |
static EventDispatcher & | instance () |
An instance retrieval method that follows the Singleton pattern. | |
The EventDispatcher manages the relation between the various instances of IEventListeners and IEvents.
It allows IEvents to get raised and dispatches these to the registered IEventListeners. Internally, the EventDispatcher uses a double dispatching mechanism that allows extension of both IEventListeners and IEvents.
Definition at line 44 of file EventDispatcher.h.
|
inlinevirtual |
Adds an IEventListener to the list.
Note that the EventDispatcher takes over responsibility of the pointer and its deconstruction.
listener | The IEventListener that is to be add. |
Definition at line 93 of file EventDispatcher.h.
|
virtual |
Clears all the IEventListeners from the EventDispatcher.
Definition at line 76 of file EventDispatcher.cpp.
|
inlinevirtual |
Counts the number of registered listeners.
Definition at line 144 of file EventDispatcher.h.
|
virtual |
Returns the IEventListener at a specified index.
idx | The index of the IEventListener. |
Definition at line 64 of file EventDispatcher.cpp.
|
virtual |
Returns the IEventListener at a specified index.
idx | The index of the IEventListener. |
Definition at line 70 of file EventDispatcher.cpp.
|
inlinevirtual |
Tells whether there are listeners for events.
Definition at line 153 of file EventDispatcher.h.
|
inlinestatic |
An instance retrieval method that follows the Singleton pattern.
Note that this implementation should not be considered thread safe and that problems may arise. However, due to the nature of the expected use this will not be likely to result in problems.
See http://www.oaklib.org/docs/oak/singleton.html for more information.
Definition at line 83 of file EventDispatcher.h.
|
virtual |
Raises an IEvent, causing it to be dispatched to each registered IEventListener.
Note that a double dispatching mechanism is used to determine the proper runtime types of both the IEvent and the IEventListener using dynamic binding.
event | The IEvent instance that is to be raised. |
Definition at line 83 of file EventDispatcher.cpp.
|
virtual |
Removes an IEventListener from the list.
This does not delete the object itself. As the caller has access to the pointer, it can take responsibility for the proper destruction of the object.
listener | The IEventListener instance that is to be removed. |
Definition at line 59 of file EventDispatcher.cpp.
|
virtual |
Removes an IEventListener from the list.
idx | The index of the IEventListener that is to be removed. |
Definition at line 51 of file EventDispatcher.cpp.