![]() |
Lysa
0.0
Lysa 3D Engine
|
Simple event manager.
Supports both C++ and Lua handlers. Events are queued via push and delivered in FIFO order each frame. The C++ handlers are called before the Lua ones.
Public Member Functions | |
| void | push (const Event &e) |
| unique_id | subscribe (const event_type &type, unique_id id, EventHandlerCallback callback) |
| unique_id | subscribe (const event_type &type, EventHandlerCallback callback) |
| void | unsubscribe (unique_id id) |
| void | fire (Event &event) |
| EventManager (size_t reservedCapacity) | |
| ~EventManager () | |
| EventManager | ( | size_t | reservedCapacity | ) |
Creates an EventManager with an initial capacity for the event queue.
| reservedCapacity | The initial number of events to reserve space for. |
| ~EventManager | ( | ) |
| void fire | ( | Event & | event | ) |
Immediately deliver an event to all interested handlers.
| event | The event to fire. |
| void push | ( | const Event & | e | ) |
Enqueue an event to be delivered on next processing.
| e | The event to push into the queue. |
| unique_id subscribe | ( | const event_type & | type, |
| EventHandlerCallback | callback | ||
| ) |
Subscribe a C++ handler to a given global event type. Subscribers are called in order of subscription.
| type | The event kind to listen to. |
| callback | Reference to a callable receiving the event. |
| unique_id subscribe | ( | const event_type & | type, |
| unique_id | id, | ||
| EventHandlerCallback | callback | ||
| ) |
Subscribe a C++ handler to a given event type and target id. Subscribers are called in reverse order of subscription, allowing the more recent subscription to stop the event processing by setting consumed to true
| type | The event kind to listen to. |
| id | The specific target id to filter on. |
| callback | Reference to a callable receiving the event. |
| void unsubscribe | ( | unique_id | id | ) |
Unsubscribe a C++ handler to a given global event type
| id | Previously registered handler |