-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAction.cpp
More file actions
54 lines (42 loc) · 1017 Bytes
/
Action.cpp
File metadata and controls
54 lines (42 loc) · 1017 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
47
48
49
50
51
52
53
54
#include <stdexcept>
#include "Action.h"
#include "Process.h"
namespace IMSim {
Action::Action(Event* event, ACTION_CALLBACK callback, TIME interval) {
this->event = event;
this->callback = callback;
this->interval = interval;
this->data = NULL;
}
Action::Action(Event* event, ACTION_CALLBACK callback, TIME interval, void* data) {
this->event = event;
this->callback = callback;
this->interval = interval;
this->data = data;
}
Action* Action::execute() {
if( this->event != NULL )
{
if( this->callback == NULL )
this->event->activate();
else
{
Process *p = dynamic_cast<Process *>(this->event);
if( p != NULL )
p->activate(this->callback, this->data);
else
throw std::runtime_error("Attempt to use Event as a Process");
}
}
return this;
}
Event* Action::getEvent() {
return this->event;
}
ACTION_CALLBACK Action::getCallback() {
return this->callback;
}
TIME Action::getInterval() {
return this->interval;
}
}