#include <events.h>
Public Member Functions | |
void | dispatch () |
void | clearEvents () |
void | registerMapper (EventMapper *mapper, bool autoFree) |
void | unregisterMapper (EventMapper *mapper) |
void | registerSource (EventSource *source, bool autoFree) |
void | unregisterSource (EventSource *source) |
void | ignoreSources (bool ignore) |
void | registerObserver (EventObserver *obs, uint priority, bool autoFree, bool listenPolls=false) |
void | unregisterObserver (EventObserver *obs) |
Dispatch events from various sources to various observers.
EventDispatcher uses a priority-based approach. Observers with higher priority are notified before observers with lower priority. Note that observers might 'eat' events, and thus not all observers might be notified.
Another speciality is the support for an event mapper that will catch events and create new events out of them. This mapper will be processed before an event is sent to the observers.
void Common::EventDispatcher::dispatch | ( | ) |
Attempt to catch events from the registered event sources and dispatch them to the observers.
This dispatches all events the sources offer.
void Common::EventDispatcher::clearEvents | ( | ) |
Clear all events currently in the event queue. The cleared events are not dispatched and are simply discarded.
void Common::EventDispatcher::registerMapper | ( | EventMapper * | mapper, |
bool | autoFree | ||
) |
Register a new EventMapper with the dispatcher.
void Common::EventDispatcher::unregisterMapper | ( | EventMapper * | mapper | ) |
Unregister an EventMapper.
This takes the "autoFree" flag passed to registerSource into account.
void Common::EventDispatcher::registerSource | ( | EventSource * | source, |
bool | autoFree | ||
) |
Register a new EventSource with the Dispatcher.
void Common::EventDispatcher::unregisterSource | ( | EventSource * | source | ) |
Unregister an EventSource.
This takes the "autoFree" flag passed to registerSource into account.
void Common::EventDispatcher::ignoreSources | ( | bool | ignore | ) |
Ignore some event sources and don't poll them. This is useful for e.g. the EventRecorder where you don't want the other EventSource instances to interfer with the serialized events.
void Common::EventDispatcher::registerObserver | ( | EventObserver * | obs, |
uint | priority, | ||
bool | autoFree, | ||
bool | listenPolls = false |
||
) |
Register a new EventObserver with the Dispatcher.
listenPolls | If set, then all pollEvent() calls are passed to the observer. Currently, it is used by keyMapper. |
void Common::EventDispatcher::unregisterObserver | ( | EventObserver * | obs | ) |
Unregister an EventObserver.
This takes the "autoFree" flag passed to registerObserver into account.