OdinAI

- Main Page
- Namespaces
- Classes
- Files
- Examples

- File List

All Classes Namespaces Functions Variables
EventManager.h
1 /*******************************************************************************
2 * ________ .___.__ _____ .___
3 * \_____ \ __| _/|__| ____ / _ \ | |
4 * / | \ / __ | | |/ \ / /_\ \| |
5 * / | \/ /_/ | | | | \/ | \ |
6 * \_______ /\____ | |__|___| /\____|__ /___|
7 * \/ \/ \/ \/
8 *
9 * Copyright (c) Emil Sandstø 2012
10 *******************************************************************************/
11 #ifndef ODINAI_EVENT_MANAGER_H_
12 #define ODINAI_EVENT_MANAGER_H_
13
14 #include <functional>
15 #include <map>
16 #include <string>
17 #include <vector>
18 #include <tuple>
19 #include <memory>
20 #include "OdinAI/Event.h"
21 #include "OdinAI/Timer.h"
22 #include "SharedDefs.h"
23
24 namespace OdinAI
25 {
26
27 typedef std::function<void(const Event*)> EventCallback;
28
32 class EventManager
33 {
34 public:
35 EventManager() {};
36
42 void AddEventListener(const char *eventName, EventCallback callBackfunction);
43
49 void FireEvent(std::shared_ptr<Event> event, uint delay = 0);
50
54 void Update();
55
59 void Release();
60 private:
61 struct EventRecord
62 {
63 std::shared_ptr<Event> event;
64 uint delay; /*< Delay, as given in the FireEvent() call */
65 uint sent; /*< Time point for when the record was created */
66 };
67 std::map< std::string, std::vector<EventCallback> > m_eventListeners;
68 std::vector<EventRecord> m_eventStore;
69 };
70
71 }
72 #endif
OdinAI::EventManager
Definition: EventManager.h:32
OdinAI::EventManager::Update
void Update()
OdinAI::EventManager::AddEventListener
void AddEventListener(const char *eventName, EventCallback callBackfunction)
OdinAI::EventManager::FireEvent
void FireEvent(std::shared_ptr< Event > event, uint delay=0)
OdinAI::EventManager::Release
void Release()