GameEngine::EventManager Class Reference

#include <EventManager.h>

Inheritance diagram for GameEngine::EventManager:

Inheritance graph
[legend]
Collaboration diagram for GameEngine::EventManager:

Collaboration graph
[legend]
List of all members.

Detailed Description

Manager class for game events. Stores a queue of events to be processed, and matches event listerners with event types, on each call of tick the manager will try to dispatch all the queued events to all the relevant listeners. It is also possible to dispatch an event immediatly instead of waiting for a tick.

Definition at line 39 of file EventManager.h.

Public Member Functions

 EventManager ()
 ~EventManager ()
bool addListener (const EventListenerPtr &listener, const EventType &eventType)
bool delListener (const EventListenerPtr &listener, const EventType &eventType)
bool sendEvent (const Event &event) const
bool queueEvent (const EventPtr &event)
bool tick (const double maxTime)
bool validateType (const EventType &type) const

Private Types

typedef std::set< EventTypeEventTypeSet
typedef std::pair< EventTypeSet::iterator,
bool > 
EventTypeSetIRes
typedef std::list< EventListenerPtrEventListenerTable
typedef std::map< unsigned
int, EventListenerTable
EventListenerMap
typedef std::pair< unsigned
int, EventListenerTable
EventListenerMapEnt
typedef std::pair< EventListenerMap::iterator,
bool > 
EventListenerMapIRes
typedef std::list< EventPtrEventQueue

Private Attributes

EventTypeSet mTypeList
EventListenerMap mRegistry
EventQueue mQueues [NUM_QUEUES]
int mActiveQueue


Member Typedef Documentation

typedef std::set< EventType > GameEngine::EventManager::EventTypeSet [private]

Definition at line 99 of file EventManager.h.

typedef std::pair< EventTypeSet::iterator, bool> GameEngine::EventManager::EventTypeSetIRes [private]

Definition at line 100 of file EventManager.h.

typedef std::list< EventListenerPtr > GameEngine::EventManager::EventListenerTable [private]

Definition at line 101 of file EventManager.h.

typedef std::map< unsigned int, EventListenerTable > GameEngine::EventManager::EventListenerMap [private]

Definition at line 102 of file EventManager.h.

typedef std::pair< unsigned int, EventListenerTable > GameEngine::EventManager::EventListenerMapEnt [private]

Definition at line 103 of file EventManager.h.

typedef std::pair< EventListenerMap::iterator, bool > GameEngine::EventManager::EventListenerMapIRes [private]

Definition at line 104 of file EventManager.h.

typedef std::list< EventPtr > GameEngine::EventManager::EventQueue [private]

Definition at line 105 of file EventManager.h.


Constructor & Destructor Documentation

GameEngine::EventManager::EventManager (  ) 

Constructor

Definition at line 26 of file EventManager.cpp.

GameEngine::EventManager::~EventManager (  ) 

Destructor

Definition at line 33 of file EventManager.cpp.


Member Function Documentation

bool GameEngine::EventManager::addListener ( const EventListenerPtr listener,
const EventType eventType 
)

Register a listener to listen for a specific type of event

Parameters:
listener The event listener
eventType The type of event to listen for
Returns:
true if the listener was registered successfully, false otherwise

Definition at line 39 of file EventManager.cpp.

bool GameEngine::EventManager::delListener ( const EventListenerPtr listener,
const EventType eventType 
)

Unregister a listener from receiving a specfic type of event

Parameters:
listener The listener to unregister
eventType The type of event to no longer listen for
Returns:
true if the listener was unregistered successfully, false otherwise

Definition at line 82 of file EventManager.cpp.

bool GameEngine::EventManager::sendEvent ( const Event event  )  const

Dispatch an event immediatly to all those listening for events of its type

Parameters:
event The event to be dispatched

Definition at line 113 of file EventManager.cpp.

bool GameEngine::EventManager::queueEvent ( const EventPtr event  ) 

Queue an event to be dispatched to listeners the next time events are processed

Parameters:
event The event to be queued for dispatch

Definition at line 151 of file EventManager.cpp.

bool GameEngine::EventManager::tick ( const double  maxTime  ) 

Process any queued events

Parameters:
maxTime The maximum ammount of time to be spent processing events
Returns:
true if all events were processed during this tick, false if some remain unprocessed

Definition at line 174 of file EventManager.cpp.

bool GameEngine::EventManager::validateType ( const EventType type  )  const

Check a given event type is valid

Parameters:
type The event type to validate
Returns:
true of the type is valid, false otherwise

Definition at line 236 of file EventManager.cpp.


Member Data Documentation

EventTypeSet GameEngine::EventManager::mTypeList [private]

Definition at line 108 of file EventManager.h.

EventListenerMap GameEngine::EventManager::mRegistry [private]

Definition at line 109 of file EventManager.h.

EventQueue GameEngine::EventManager::mQueues[NUM_QUEUES] [private]

Definition at line 111 of file EventManager.h.

int GameEngine::EventManager::mActiveQueue [private]

Definition at line 112 of file EventManager.h.


The documentation for this class was generated from the following files:
Generated on Thu Apr 19 09:48:43 2007 for GameEngine by  doxygen 1.5.2