forked from duyanning/cpps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDependencyGraphEntity.cpp
More file actions
44 lines (35 loc) · 994 Bytes
/
Copy pathDependencyGraphEntity.cpp
File metadata and controls
44 lines (35 loc) · 994 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
#include "std.h"
#include "DependencyGraphEntity.h"
DependencyGraphEntity::DependencyGraphEntity()
{
}
void DependencyGraphEntity::addAction(shared_ptr<Action> action)
{
actions.push_back(action);
}
void DependencyGraphEntity::addPrerequisite(EntityPtr p)
{
prerequisiteList.push_back(p);
}
void DependencyGraphEntity::updatePrerequisites(vector<EntityPtr>& changed)
{
for (auto p : prerequisiteList) {
time_t oldStamp = p->timestamp();
p->update();
if (p->timestamp() > oldStamp)
changed.push_back(p);
}
}
void DependencyGraphEntity::executeActions(EntityPtr target, vector<EntityPtr>& allPre, vector<EntityPtr>& changedPre)
{
for (auto a : actions)
a->execute(target, allPre, changedPre);
}
void DependencyGraphEntity::show(int level, string indent)
{
for (int i = 0; i < level; i++)
cout << indent;
cout << name() << endl;
for (auto p : prerequisiteList)
p->show(level + 1);
}