Class EventManager

Class Documentation

class EventManager

Manages event consumers and event dispatching.

Public Functions

void SubscribeConsumer(std::string type, const EventConsumer &consumer)

Subscribe a consumer to the given event type.

Registers this consumer to be called when an event of the given type is dispatched

Parameters:
  • type – The type of event to subscribe to

  • consumer – The consumer to subscribe

void UnsubscribeConsumer(std::string type, const EventConsumer &consumer)

Unsubscribe a consumer from the given event type.

Parameters:
  • type – The type of event to unsubscribe from

  • consumer – The consumer to unsubscribe

void UnsubscribeAllConsumers()

Unsubscribe all consumers of any event type.

void Dispatch(Event &event)

Dispatch an event to all subscribed consumers of its type.

Warning

Currently, this blocks until all consumers are done. This behavior will be changed in the future and will be replaced with a signalling API.

Parameters:

event – The event to dispatch

Public Static Functions

static EventManager &Get()

Get the instance and create one if there isn’t one.

Returns:

The instance