Lysa  0.0
Lysa 3D Engine
EventManager Class Reference

Detailed Description

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 ()
 

Constructor & Destructor Documentation

EventManager ( size_t  reservedCapacity)

Creates an EventManager with an initial capacity for the event queue.

Parameters
reservedCapacityThe initial number of events to reserve space for.
~EventManager ( )

Member Function Documentation

void fire ( Event event)

Immediately deliver an event to all interested handlers.

Parameters
eventThe event to fire.
void push ( const Event e)

Enqueue an event to be delivered on next processing.

Parameters
eThe 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.

Parameters
typeThe event kind to listen to.
callbackReference 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

Parameters
typeThe event kind to listen to.
idThe specific target id to filter on.
callbackReference to a callable receiving the event.
void unsubscribe ( unique_id  id)

Unsubscribe a C++ handler to a given global event type

Parameters
idPreviously registered handler