LibCT 2.0
Public Member Functions | Private Member Functions | Private Attributes | Friends

LibCT::EventListener Class Reference

EventListener is a base class that all classes wishing to recieve events should derive from. More...

#include <EventListener.h>

List of all members.

Public Member Functions

 EventListener ()
 Constructor.
virtual ~EventListener ()
 Destructor.
template<typename T >
void ListenFor (const std::string &name, void(T::*Callback)(EventOccurance *))
 Listen for a specific event.
void StopListeningFor (const std::string &name)
 Stop listening for an event.
bool IsListeningFor (const std::string &name)
EventListenerMode GetMode () const
void SetMode (EventListenerMode mode)
 Set the current EventListenerMode.

Private Member Functions

void AddEventOccurance (EventOccurance *pEventOccurance)
 Add an event occurance.
void PrioiritiseEventOccurances ()
 Sort the EventOccuranceList by priority.
void ClearEventOccurances ()
 Clear the EventOccuranceList.

Private Attributes

EventOccuranceList m_EventOccurances
 List of all events that have occured since the last time ClearEventOccurances was called.
ListenerHandleList m_ListenerHandles
 List of all the ListenerHandles associated with this EventListener.
EventListenerMode m_Mode
 Current mode.

Friends

class EventType

Detailed Description

EventListener is a base class that all classes wishing to recieve events should derive from.

An EventListener can either be in BufferedMode or Immediate mode, in buffered mode and evetn that occurs is added to a priority queue, for later processing. In Immediate mode the events are processed as soon as they occur, the default is Immediate mode


Constructor & Destructor Documentation

LibCT::EventListener::EventListener ( )

Constructor.

virtual LibCT::EventListener::~EventListener ( ) [virtual]

Destructor.


Member Function Documentation

void LibCT::EventListener::AddEventOccurance ( EventOccurance pEventOccurance) [private]

Add an event occurance.

Parameters:
pEventOccuranceEventOccurance to add
void LibCT::EventListener::ClearEventOccurances ( ) [private]

Clear the EventOccuranceList.

EventListenerMode LibCT::EventListener::GetMode ( ) const

Get the current mode

Returns:
The current EventListenerMode
bool LibCT::EventListener::IsListeningFor ( const std::string &  name)

Check if this EventListener is listening for an event

Returns:
True if this EventListener is listening for the event, false if not
Parameters:
nameName of the event to test listening for
template<typename T >
void LibCT::EventListener::ListenFor ( const std::string &  name,
void(T::*)(EventOccurance *)  Callback 
) [inline]

Listen for a specific event.

Parameters:
nameName of the event to listen for
CallbackFunction to call when the event occurs
void LibCT::EventListener::PrioiritiseEventOccurances ( ) [private]

Sort the EventOccuranceList by priority.

void LibCT::EventListener::SetMode ( EventListenerMode  mode)

Set the current EventListenerMode.

Parameters:
modeNew mode
void LibCT::EventListener::StopListeningFor ( const std::string &  name)

Stop listening for an event.

Parameters:
nameName od the event to stop listening for

Friends And Related Function Documentation

friend class EventType [friend]

Member Data Documentation

List of all events that have occured since the last time ClearEventOccurances was called.

List of all the ListenerHandles associated with this EventListener.

Current mode.


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