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, bool autoFree=true)
 Registers an event mapper with the dispatcher.
EventMapperqueryMapper () const
 Queries the setup event mapper.
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

bool _autoFreeMapper
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 348 of file events.h.


Constructor & Destructor Documentation

Common::EventDispatcher::EventDispatcher (  ) 

Definition at line 27 of file EventDispatcher.cpp.

Common::EventDispatcher::~EventDispatcher (  ) 

Definition at line 30 of file EventDispatcher.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 73 of file EventDispatcher.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 47 of file EventDispatcher.cpp.

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

Definition at line 142 of file EventDispatcher.cpp.

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

Definition at line 149 of file EventDispatcher.cpp.

EventMapper* Common::EventDispatcher::queryMapper (  )  const [inline]

Queries the setup event mapper.

Definition at line 386 of file events.h.

void Common::EventDispatcher::registerMapper ( EventMapper mapper,
bool  autoFree = true 
)

Registers an event mapper with the dispatcher.

The ownership of the "mapper" variable will pass to the EventDispatcher, thus it will be deleted with "delete", when EventDispatcher is destroyed.

Parameters:
autoFree Destroy previous mapper [default] Normally we allow only one event mapper to exists, However Event Recorder must intervent into normal event flow without altering its semantics. Thus during Event Recorder playback and recording we allow two mappers.

Definition at line 82 of file EventDispatcher.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 112 of file EventDispatcher.cpp.

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

Registers a new EventSource with the Dispatcher.

Definition at line 91 of file EventDispatcher.cpp.

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

Unregisters a EventObserver.

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

Definition at line 130 of file EventDispatcher.cpp.

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

Unregisters a EventSource.

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

Definition at line 100 of file EventDispatcher.cpp.


Member Data Documentation

Definition at line 415 of file events.h.

Definition at line 416 of file events.h.

Definition at line 434 of file events.h.

Definition at line 426 of file events.h.


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


Generated on Sat Jul 20 2019 05:02:39 for ResidualVM by doxygen 1.7.1
curved edge   curved edge