Class for object-oriented handling of user-defined events. More...

Public Types | |
|
typedef std::tr1::function < void(const Event &) > | Listener |
| Function type of listeners associated with Event. | |
Public Member Functions | |
| EventSystem () | |
| Default constructor. | |
| void | TriggerEvent (const Event &event) |
| Fires an event. | |
| Connection | Connect (const EventIdentifier &trigger, const Listener &listener) |
| Connects an event to the specified listener. | |
| void | ClearConnections (EventIdentifier identifier) |
| Disconnects listeners associated with a given event type. | |
| void | ClearAllConnections () |
| Disconnects all listeners. | |
Class for object-oriented handling of user-defined events.
| Event | The event type. For example, this can be a class or enum. |
| EventIdentifier | The type that distinguishes different events. This isn't necessarily the event type itself. Consider SFML: The event type would be sf::Event, but the identifier is sf::Event::EventType. When you use custom events where EventIdentifier and Event are distinct types, you have to provide a global function EventIdentifier ExtractEventIdentifier(const Event&) in the namespace of the Event type definition. Besides, the event system requires less-than operator < for EventIdentifier (enums can use the implicit conversion to int). |
| thor::EventSystem< Event, EventIdentifier >::EventSystem | ( | ) |
Default constructor.
Sets up an EventSystem where Event and EventIdentifier are the same types.
| void thor::EventSystem< Event, EventIdentifier >::ClearAllConnections | ( | ) |
Disconnects all listeners.
Removes all event-listener connections, independently of the event type.
| void thor::EventSystem< Event, EventIdentifier >::ClearConnections | ( | EventIdentifier | identifier | ) |
Disconnects listeners associated with a given event type.
| identifier | The event type identifier of which you want to remove all connected listeners. |
| Connection thor::EventSystem< Event, EventIdentifier >::Connect | ( | const EventIdentifier & | trigger, |
| const Listener & | listener | ||
| ) |
Connects an event to the specified listener.
Duplicates are allowed (thus, the listener is invoked multiple times).
| trigger | The event you want to associate with a listener function. |
| listener | The function that is invoked when a trigger event is fired. |
| void thor::EventSystem< Event, EventIdentifier >::TriggerEvent | ( | const Event & | event | ) |
Fires an event.
Calls all listener functions that are currently associated with event.