5#ifndef _EVENTSMANAGER_H
6#define _EVENTSMANAGER_H
49 inline static std::map<
51 std::vector<Subscriber>
63 template<
typename EnumType>
78 template<
typename EnumType>
83 doUnsubscribe(key, core);
114 template<
typename EnumType>
115 static void fire(EnumType eventEnum,
117 const std::optional<sf::Event>& event,
118 SystemCallback resolve =
nullptr,
119 SystemCallback reject =
nullptr)
121 doFire(
EnumKey::get(eventEnum), dispatcher, event, resolve, reject);
138 static void doSubscribe(
const std::string& key, EventReceiver* component);
139 static void doFire(
const std::string& key,
141 const std::optional<sf::Event>& event,
142 SystemCallback resolve,
143 SystemCallback reject);
144 static void doUnsubscribe(
const std::string& key,
Core* core);
145 static void doUnsubscribeAll(
Core* core);
148 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.