-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvent.cpp
More file actions
46 lines (36 loc) · 658 Bytes
/
Copy pathEvent.cpp
File metadata and controls
46 lines (36 loc) · 658 Bytes
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
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "stdafx.h"
#include "Event.h"
namespace SimpleEvents {
Event::Event()
: is_active_(true)
, callback_id_(0)
, is_completed_(false)
{
}
Event::~Event()
{
}
Event::CallbackHolder Event::add_callback(CallbackT callback)
{
callbacks_[++callback_id_] = callback;
return CallbackHolder(*this, callback_id_);
}
void Event::remove_callback(CallbackId callback_id)
{
callbacks_.erase(callback_id);
}
void Event::on_complete()
{
if (is_active_)
{
if (!is_completed_)
{
is_completed_ = true;
for each (auto callback in callbacks_)
{
callback.second();
}
}
}
}
} // namespace SimpleEvents