-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.cpp
More file actions
32 lines (25 loc) · 1.12 KB
/
node.cpp
File metadata and controls
32 lines (25 loc) · 1.12 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
#include "node.h"
bool EmptyNode::Evaluate(const Date& date, const string& event) const {
return true;
}
DateComparisonNode::DateComparisonNode(Comparison cmp, const Date& date)
: comparison(cmp), dateStored(date) {}
bool DateComparisonNode::Evaluate(const Date& date, const string& event) const {
return Compare<const Date&>(date, dateStored, comparison);
}
EventComparisonNode::EventComparisonNode(Comparison cmp, const string& event)
: comparison(cmp), eventStored(event) {}
bool EventComparisonNode::Evaluate(const Date& date, const string& event) const {
return Compare<const string&>(event, eventStored, comparison);
}
LogicalOperationNode::LogicalOperationNode(
LogicalOperation op,
shared_ptr<Node> lhs,
shared_ptr<Node> rhs) : op(op), leftOperand(lhs), rightOperand(rhs) {}
bool LogicalOperationNode::Evaluate(const Date& date, const string& event) const {
if (op == LogicalOperation::Or) {
return leftOperand->Evaluate(date, event) || rightOperand->Evaluate(date, event);
} else {
return leftOperand->Evaluate(date, event) && rightOperand->Evaluate(date, event);
}
}