8#ifndef MALENA_EVENTSMANAGER_H
9#define MALENA_EVENTSMANAGER_H
54 inline static std::map<
56 std::vector<Subscriber>
75 template<
typename EnumType>
95 template<
typename EnumType>
100 doUnsubscribe(key, core);
141 template<
typename EnumType>
142 static void fire(EnumType eventEnum,
144 const std::optional<sf::Event>& event,
145 SystemCallback resolve =
nullptr,
146 SystemCallback reject =
nullptr)
148 doFire(
EnumKey::get(eventEnum), dispatcher, event, resolve, reject);
165 static void doSubscribe(
const std::string& key, EventReceiver* component, Core* core =
nullptr);
166 static void doFire(
const std::string& key,
167 Fireable* dispatcher,
168 const std::optional<sf::Event>& event,
169 SystemCallback resolve,
170 SystemCallback reject);
171 static void doUnsubscribe(
const std::string& key, Core* core);
172 static void doUnsubscribeAll(Core* core);
175 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, Core *core=nullptr)
Register a component for an enum-keyed event.
static bool hasReceiver(EventReceiver *receiver)
True if receiver is still registered under any event key.
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.