EventDispatcher dispatches a given event to the list of EventHandlers that it contains.
Currently, only one EventHandler will handle a given event - once an event has been handled, it is not dispatched to the rest of the handles, and dispatch() immediately returns true. The order in which EventHandlers are added is therefore important.
#include <EventDispatcher.h>
Public Member Functions |
|
EventDispatcher (bool usingPython=false) | |
virtual | ~EventDispatcher () |
bool | addEventHandler (const EventHandlerRef &handler) |
bool | removeEventHandler (const EventHandlerRef &handler) |
int | getEventHandlerCount () |
bool | dispatch (const Event &event) |
Ensures that the call to a virtual method
dispatchEvent() is safe in python/multithreaded environment.
|
|
void | dispatchAll (EventList &events, bool advanceTime) |
Similar to dispatch, this method will avoid
acquiring locks on a per event basis by dispatching an array of
events. |
|
EventHandlerList::const_iterator | eventHandlerListBegin () const |
EventHandlerList::const_iterator | eventHandlerListEnd () const |
virtual void | setTimerPaused (bool pause) |
virtual bool | dispatchEvent (const Event &event) |
bool | isMessageDispatched () const |
void | setMessageDispatched (bool dispatched) |
virtual void | dispatchBatchPullEvents () |
Instead of overriding dispatchEvent it's
possible to override dispatchBatchPullEvents and then call
getNextEvent to process the current list of events. |
|
Event * | getNextEvent () |
Protected Member Functions |
|
void | dispatchBatch (EventList &events, bool advanceTime) |
Protected Attributes |
|
EventHandlerList | myEventHandlers |
EventDispatcher | ( | bool | usingPython =
false |
) | [explicit] |
virtual ~EventDispatcher | ( | ) | [virtual] |
bool addEventHandler | ( | const EventHandlerRef & | handler | ) |
bool removeEventHandler | ( | const EventHandlerRef & | handler | ) |
int getEventHandlerCount | ( | ) |
bool dispatch | ( | const Event & | event | ) |
Ensures that the call to a virtual method dispatchEvent() is safe in python/multithreaded environment.
returns true if the event was handled by any of the handlers, false otherwise.
void dispatchAll | ( | EventList & | events, |
bool | advanceTime | ||
) |
Similar to dispatch, this method will avoid acquiring locks on a per event basis by dispatching an array of events.
If advanceTime is true then we use the TimeDriven interface to advance time on each event prior to dispatching it.
EventHandlerList::const_iterator eventHandlerListBegin | ( | ) | const |
EventHandlerList::const_iterator eventHandlerListEnd | ( | ) | const |
void dispatchBatch | ( | EventList & | events, |
bool | advanceTime | ||
) | [protected] |
virtual void setTimerPaused | ( | bool | pause | ) | [virtual] |
virtual bool dispatchEvent | ( | const Event & | event | ) | [virtual] |
bool isMessageDispatched | ( | ) | const |
void setMessageDispatched | ( | bool | dispatched | ) |
virtual void dispatchBatchPullEvents | ( | ) | [virtual] |
Instead of overriding dispatchEvent it's possible to override dispatchBatchPullEvents and then call getNextEvent to process the current list of events.
Event* getNextEvent | ( | ) |