-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.cpp
More file actions
70 lines (65 loc) · 1.57 KB
/
node.cpp
File metadata and controls
70 lines (65 loc) · 1.57 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
70
#include "node.h"
bool EmptyNode::Evaluate (
const Date& date,
const string& event
) const {
return true;
}
bool LogicalOperationNode::Evaluate (
const Date& date,
const string& event
) const {
switch (logical_operation_) {
case LogicalOperation::And:
return left_->Evaluate(date, event) && right_->Evaluate(date, event);
case LogicalOperation::Or:
return left_->Evaluate(date, event) || right_->Evaluate(date, event);
}
return false;
}
bool DateComparisonNode::Evaluate (
const Date& date,
const string& event
) const {
switch (cmp_) {
case Comparison::Less:
return date < date_;
case Comparison::LessOrEqual:
return date <= date_;
case Comparison::Greater:
return date > date_;
case Comparison::GreaterOrEqual:
return date >= date_;
case Comparison::Equal:
return date == date_;
case Comparison::NotEqual:
return date != date_;
}
return false;
}
bool EventComparisonNode::Evaluate (
const Date& date,
const string& event
) const {
// TestFind(event, event_);
switch (cmp_) {
case Comparison::Less:
return event < event_;
case Comparison::LessOrEqual:
return event <= event_;
case Comparison::Greater:
return event > event_;
case Comparison::GreaterOrEqual:
return event >= event_;
case Comparison::Equal:
return event == event_;
case Comparison::NotEqual:
return event != event_;
}
return false;
}
void TestFind(const string s1, const string s2) {
cout << s1 << endl;
cout << s2 << endl;
cout << s1 << "/" << s2 << endl;
}