8#ifndef MALENA_EVENTSMANAGER_H
9#define MALENA_EVENTSMANAGER_H
54 inline static std::map<
56 std::vector<Subscriber>
68 template<
typename EnumType>
83 template<
typename EnumType>
88 doUnsubscribe(key, core);
119 template<
typename EnumType>
120 static void fire(EnumType eventEnum,
122 const std::optional<sf::Event>& event,
123 SystemCallback resolve =
nullptr,
124 SystemCallback reject =
nullptr)
126 doFire(
EnumKey::get(eventEnum), dispatcher, event, resolve, reject);
143 static void doSubscribe(
const std::string& key, EventReceiver* component);
144 static void doFire(
const std::string& key,
145 Fireable* dispatcher,
146 const std::optional<sf::Event>& event,
147 SystemCallback resolve,
148 SystemCallback reject);
149 static void doUnsubscribe(
const std::string& key, Core* core);
150 static void doUnsubscribeAll(Core* core);
153 static void forceUnsubscribeAll(Core* core);
Virtual base class for all Malena framework objects.
CRTP base that gives a manager safe deferred-operation support.
static void deferOrExecute(std::function< void()> operation)
Centralized event bus for the Malena trait-based event system.
static void clear()
Remove all subscriptions for all events.
static void unsubscribe(EnumType eventEnum, Core *core)
Remove a component's subscription to one event.
static void fire(EnumType eventEnum, Fireable *dispatcher, const std::optional< sf::Event > &event, SystemCallback resolve=nullptr, SystemCallback reject=nullptr)
Fire an event to all matching subscribers.
static void subscribe(EnumType eventEnum, EventReceiver *component)
Register a component for an enum-keyed event.
static void unsubscribeAll(Core *core)
Remove all subscriptions for a component.
friend class Unsubscribable
Base class for all event-receiving traits.
Trait that gives components the ability to unsubscribe from events.
static std::string get(EnumType value)
Generate a unique string key for an enum value.