-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.cpp
46 lines (38 loc) · 1.73 KB
/
node.cpp
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
//
// node.cpp
// DataBaseCourseProject
//
// Created by Sergei Ziuzev on 3/15/22.
// Copyright © 2022 Sergei Ziuzev. All rights reserved.
//
#include "headers/node.hpp"
EmptyNode::EmptyNode() { }
EmptyNode::~EmptyNode() { }
bool EmptyNode::Evaluate(const Date& date, const std::string& event) {
return true;
}
DateComparisonNode::DateComparisonNode(const Comparison& cmp, const Date& date): _comparison(cmp), _date(date) { }
DateComparisonNode::~DateComparisonNode() { }
bool DateComparisonNode::Evaluate(const Date& date, const std::string& event) {
return ComparisonValue(_comparison, date, _date);
}
EventComparisonNode::EventComparisonNode(Comparison cmp, const std::string& value): _comparison(cmp), _value(value) { }
EventComparisonNode::~EventComparisonNode() { }
bool EventComparisonNode::Evaluate(const Date& date, const std::string& event) {
return ComparisonValue(_comparison, event, _value);
}
LogicalOperationNode::LogicalOperationNode (
const LogicalOperation& logical_operation,
const std::shared_ptr<Node>& left,
const std::shared_ptr<Node>& right
): _logical_operation(logical_operation), _left(left), _right(right) { }
LogicalOperationNode::~LogicalOperationNode () { }
bool LogicalOperationNode::Evaluate(const Date& date, const std::string& event) {
switch (_logical_operation) {
case LogicalOperation::Or:
return _left->Evaluate(date, event) || _right->Evaluate(date, event);
case LogicalOperation::And:
return _left->Evaluate(date, event) && _right->Evaluate(date, event);
}
return false;
}