LibCT 2.0
|
EventListener is a base class that all classes wishing to recieve events should derive from. More...
#include <EventListener.h>
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 |
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
LibCT::EventListener::EventListener | ( | ) |
Constructor.
virtual LibCT::EventListener::~EventListener | ( | ) | [virtual] |
Destructor.
void LibCT::EventListener::AddEventOccurance | ( | EventOccurance * | pEventOccurance | ) | [private] |
Add an event occurance.
pEventOccurance | EventOccurance to add |
void LibCT::EventListener::ClearEventOccurances | ( | ) | [private] |
Clear the EventOccuranceList.
EventListenerMode LibCT::EventListener::GetMode | ( | ) | const |
Get the current mode
bool LibCT::EventListener::IsListeningFor | ( | const std::string & | name | ) |
Check if this EventListener is listening for an event
name | Name of the event to test listening for |
void LibCT::EventListener::ListenFor | ( | const std::string & | name, |
void(T::*)(EventOccurance *) | Callback | ||
) | [inline] |
Listen for a specific event.
name | Name of the event to listen for |
Callback | Function 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.
mode | New mode |
void LibCT::EventListener::StopListeningFor | ( | const std::string & | name | ) |
Stop listening for an event.
name | Name od the event to stop listening for |
friend class EventType [friend] |
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.