-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventSystem.h
33 lines (26 loc) · 913 Bytes
/
EventSystem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once
#include <map>
#include <vector>
#include <Trackable.h>
class Event;
class EventListener;
enum class EventType;
//using namespace std;
class EventSystem :public Trackable
{
public:
EventSystem();
~EventSystem();
void fireEvent(const Event *theEvent);
void addListener(EventType type, EventListener* pListener);
//void fireAll();
void removeListener(EventType type, EventListener* pListener);
void removeListenerFromAllEvents(EventListener* pListener);
void dispatchAllEvents();
private:
static EventSystem* msInstance;
std::multimap< EventType, EventListener* > mListenerMap;
std::vector<const Event*> mQueue, mSecondaryQueue; //events that are fired inside of handleEvent() MUST be added to mSecondaryQueue
bool mDispatching; //set to true while inside the dispatch loop. if true, add Events to secondary queue
};
extern EventSystem* gpEventSystem;