6 #include <unordered_map>
15 using Callback = std::function<void(const Event&)>;
17 using ObserverMap = std::unordered_map<EventType, CallbackList>;
31 dispatcher(dispatcher) {
46 dispatcher(o.dispatcher) {
47 o.dispatcher =
nullptr;
50 CallbackPointer::operator=(o);
51 dispatcher = o.dispatcher;
52 o.dispatcher =
nullptr;
76 template<
class... CPTypes>
Definition: GameController.hpp:7
~CallbackHolder()
Definition: EventDispatcher.hpp:56
CallbackHolder(CallbackHolder &&o)
Definition: EventDispatcher.hpp:44
std::function< void(const Event &)> Callback
Definition: EventDispatcher.hpp:15
EventDispatcher * dispatcher
Definition: EventDispatcher.hpp:22
std::list< Callback > CallbackList
Definition: EventDispatcher.hpp:16
void dispatch(const Event &event)
Definition: EventDispatcher.cpp:8
Definition: EventDispatcher.hpp:13
CallbackHolder addObserver(EventType type, const Callback &method)
Definition: EventDispatcher.cpp:22
CallbackHolder()
Definition: EventDispatcher.hpp:25
void removeObserver(CallbackPointer cb0, const CPTypes &...cbN)
Definition: EventDispatcher.hpp:77
CallbackHolder(EventDispatcher *dispatcher, EventType &et, CallbackList::iterator &it)
Definition: EventDispatcher.hpp:29
CallbackPointer observeWildcardRaw(const Callback &method)
Definition: EventDispatcher.cpp:71
CallbackHolder & operator=(CallbackHolder &)=delete
void removeObserver(const CallbackPointer &ptr)
Definition: EventDispatcher.cpp:56
std::unordered_map< EventType, CallbackList > ObserverMap
Definition: EventDispatcher.hpp:17
EventDispatcher()
Definition: EventDispatcher.cpp:5
ObserverMap observerMap
Definition: EventDispatcher.hpp:64
void unobserveWildcard(const CallbackPointer &ptr)
Definition: EventDispatcher.cpp:76
Definition: EventDispatcher.hpp:20
uint32_t EventType
Definition: Event.hpp:11
std::pair< EventType, CallbackList::iterator > CallbackPointer
Definition: EventDispatcher.hpp:18
void operator()(const Event &e)
Definition: EventDispatcher.hpp:35
CallbackPointer addObserverRaw(EventType type, const Callback &method)
Definition: EventDispatcher.cpp:39
CallbackList wildcardObservers
Definition: EventDispatcher.hpp:65
CallbackHolder & operator=(CallbackHolder &&o)
Definition: EventDispatcher.hpp:49
CallbackHolder observeWildcard(const Callback &method)
Definition: EventDispatcher.cpp:65