-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvent.cpp
More file actions
69 lines (51 loc) · 1.78 KB
/
Event.cpp
File metadata and controls
69 lines (51 loc) · 1.78 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdexcept>
#include <stdlib.h>
#include <stdio.h>
#include "Event.h"
#include "Calendar.h"
#include "Simulation.h"
#include "Continuous/Condition.h"
#include "Continuous/ConditionsContainer.h"
#include "Action.h"
#include "Continuous/BlockContainer.h"
namespace IMSim {
void Event::activate() {
this->action();
}
void Event::terminate() {
DEBUG(("EVENT [ %d ] terminate called", this->getId()), this->getSimulation()->getCalendar()->now());
if( this->getSimulation()->getCalendar()->getCurrentlyRunning() &&
this->getSimulation()->getCalendar()->getCurrentlyRunning()->getEvent() != this )
delete this;
}
void Event::schedule() {
this->_schedule(this->now());
}
void Event::schedule(PRIORITY priority) {
this->_schedule(this->now(), 0, priority);
}
void Event::scheduleAt(TIME at, PRIORITY priority) {
this->_schedule(at, 0, priority);
}
void Event::scheduleOmnipresent(TIME from, TIME interval, PRIORITY priority) {
this->_schedule(from, interval, priority, true);
}
void Event::schedulePeriodically(TIME from, TIME interval, PRIORITY priority) {
this->_schedule(from, interval, priority);
}
void Event::_schedule(TIME at, TIME interval, PRIORITY priority, bool omnipresent, ACTION_CALLBACK callback, void* data) {
this->getSimulation()->getCalendar()->schedule(new Action(this, callback, interval, data), at, priority, omnipresent);
}
void Event::addCondition(Condition* condition) {
this->getConditionsContainer()->addCondition(condition);
}
ConditionsContainer* Event::getConditionsContainer() {
return this->getSimulation()->getConditionsContainer();
}
BlockContainer* Event::getBlockContainer() {
return this->getSimulation()->getBlockContainer();
}
TIME Event::now() {
return this->getSimulation()->now();
}
}