ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

Common::EventDispatcher Class Reference

Dispatches events from various sources to various observers. More...

#include <events.h>

Collaboration diagram for Common::EventDispatcher:

List of all members.

Classes

struct  Entry
struct  ObserverEntry
struct  SourceEntry

Public Member Functions

 EventDispatcher ()
 ~EventDispatcher ()
void dispatch ()
 Tries to catch events from the registered event sources and dispatch them to the observers.
void clearEvents ()
 Clear all events currently in the event queue.
void registerMapper (EventMapper *mapper)
 Registers an event mapper with the dispatcher.
void registerSource (EventSource *source, bool autoFree)
 Registers a new EventSource with the Dispatcher.
void unregisterSource (EventSource *source)
 Unregisters a EventSource.
void registerObserver (EventObserver *obs, uint priority, bool autoFree, bool listenPolls=false)
 Registers a new EventObserver with the Dispatcher.
void unregisterObserver (EventObserver *obs)
 Unregisters a EventObserver.

Private Member Functions

void dispatchEvent (const Event &event)
void dispatchPoll ()

Private Attributes

EventMapper_mapper
List< SourceEntry_sources
List< ObserverEntry_observers

Detailed Description

Dispatches events from various sources to various observers.

EventDispatcher is using a priority based approach. Observers with higher priority will be notified before observers with lower priority. Because of the possibility that oberservers might 'eat' events, not all observers might be notified.

Another speciality is the support for a event mapper, which will catch events and create new events out of them. This mapper will be processed before an event is sent to the observers.

Definition at line 369 of file events.h.


Constructor & Destructor Documentation

Common::EventDispatcher::EventDispatcher (  ) 

Definition at line 53 of file events.cpp.

Common::EventDispatcher::~EventDispatcher (  ) 

Definition at line 56 of file events.cpp.


Member Function Documentation

void Common::EventDispatcher::clearEvents (  ) 

Clear all events currently in the event queue.

The cleared events are not dispatched and are simply discarded.

Definition at line 101 of file events.cpp.

void Common::EventDispatcher::dispatch (  ) 

Tries to catch events from the registered event sources and dispatch them to the observers.

This dispatches *all* events the sources offer.

Definition at line 68 of file events.cpp.

void Common::EventDispatcher::dispatchEvent ( const Event event  )  [private]

Definition at line 166 of file events.cpp.

void Common::EventDispatcher::dispatchPoll (  )  [private]

Definition at line 173 of file events.cpp.

void Common::EventDispatcher::registerMapper ( EventMapper mapper  ) 

Registers an event mapper with the dispatcher.

Definition at line 110 of file events.cpp.

void Common::EventDispatcher::registerObserver ( EventObserver obs,
uint  priority,
bool  autoFree,
bool  listenPolls = false 
)

Registers a new EventObserver with the Dispatcher.

Parameters:
listenPolls if set, then all pollEvent() calls are passed to observer currently it is used by keyMapper

Definition at line 136 of file events.cpp.

void Common::EventDispatcher::registerSource ( EventSource source,
bool  autoFree 
)

Registers a new EventSource with the Dispatcher.

Definition at line 115 of file events.cpp.

void Common::EventDispatcher::unregisterObserver ( EventObserver obs  ) 

Unregisters a EventObserver.

This takes the "autoFree" flag passed to registerObserver into account.

Definition at line 154 of file events.cpp.

void Common::EventDispatcher::unregisterSource ( EventSource source  ) 

Unregisters a EventSource.

This takes the "autoFree" flag passed to registerSource into account.

Definition at line 124 of file events.cpp.


Member Data Documentation

Definition at line 420 of file events.h.

Definition at line 438 of file events.h.

Definition at line 430 of file events.h.


The documentation for this class was generated from the following files:


Generated on Sat Jul 4 2020 05:03:28 for ResidualVM by doxygen 1.7.1
curved edge   curved edge