SUNENGINE 0.0.2
A simple and bright C++ game engine.
 
Loading...
Searching...
No Matches
AlarmableManager.h
1#ifndef AlarmableManager_H
2#define AlarmableManager_H
3
4#include <map>
5
6class Alarmable;
7
15class AlarmableManager
16{
17public:
22 enum class ALARM_ID { ALARM_0, ALARM_1, ALARM_2 };
23
27 static const int ALARM_NUMBER = 3;
28
29private:
33 using AlarmEvent = std::pair<Alarmable*, ALARM_ID>;
34
38 using TimeLineMap = std::multimap<float, AlarmEvent>;
39
44
45public:
46 AlarmableManager() = default;
47 AlarmableManager(const AlarmableManager&) = delete;
48 AlarmableManager& operator=(const AlarmableManager&) = delete;
49 ~AlarmableManager();
50
57 void Register(Alarmable* al, ALARM_ID id, float t);
58
64 void Deregister(Alarmable* al, ALARM_ID id);
65
69 void ProcessAlarms();
70
74 using StorageMapRef = TimeLineMap::iterator;
75};
76
77#endif
Base class for objects that can have alarms triggered in the game loop.
Definition Alarmable.h:19
void Register(Alarmable *al, ALARM_ID id, float t)
Registers an alarm for a GameObject.
Definition AlarmableManager.cpp:11
static const int ALARM_NUMBER
The number of alarms.
Definition AlarmableManager.h:27
std::pair< Alarmable *, ALARM_ID > AlarmEvent
Type alias for the alarm event pair.
Definition AlarmableManager.h:33
void ProcessAlarms()
Processes all alarms; triggers and removes expired alarms.
Definition AlarmableManager.cpp:21
TimeLineMap timeline
The timeline map of alarms.
Definition AlarmableManager.h:43
ALARM_ID
Enum class representing the alarm IDs.
Definition AlarmableManager.h:22
std::multimap< float, AlarmEvent > TimeLineMap
Type alias for the timeline map of alarms.
Definition AlarmableManager.h:38
TimeLineMap::iterator StorageMapRef
Type alias for the storage map iterator.
Definition AlarmableManager.h:74
void Deregister(Alarmable *al, ALARM_ID id)
Deregisters an alarm for a GameObject.
Definition AlarmableManager.cpp:16