-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroundedCondition.hpp
More file actions
96 lines (81 loc) · 2.15 KB
/
GroundedCondition.hpp
File metadata and controls
96 lines (81 loc) · 2.15 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// GroundedCondition Class file for Task Planner
// Author : Prateek Parmeshwar
#pragma once
using namespace std;
class GroundedCondition
{
private:
string predicate;
list<string> arg_values;
bool truth = true;
public:
GroundedCondition(string predicate, list<string> arg_values, bool truth = true)
{
this->predicate = predicate;
this->truth = truth; // fixed
for (string l : arg_values)
{
this->arg_values.push_back(l);
}
}
GroundedCondition(const GroundedCondition& gc)
{
this->predicate = gc.predicate;
this->truth = gc.truth; // fixed
for (string l : gc.arg_values)
{
this->arg_values.push_back(l);
}
}
string get_predicate() const
{
return this->predicate;
}
list<string> get_arg_values() const
{
return this->arg_values;
}
bool get_truth() const
{
return this->truth;
}
void set_truth(bool val)
{
this->truth = val;
}
friend ostream& operator<<(ostream& os, const GroundedCondition& pred)
{
os << pred.toString() << " ";
return os;
}
bool operator==(const GroundedCondition& rhs) const
{
if (this->predicate != rhs.predicate || this->arg_values.size() != rhs.arg_values.size())
return false;
auto lhs_it = this->arg_values.begin();
auto rhs_it = rhs.arg_values.begin();
while (lhs_it != this->arg_values.end() && rhs_it != rhs.arg_values.end())
{
if (*lhs_it != *rhs_it)
return false;
++lhs_it;
++rhs_it;
}
if (this->truth != rhs.get_truth()) // fixed
return false;
return true;
}
string toString() const
{
string temp = "";
temp += this->predicate;
temp += "(";
for (string l : this->arg_values)
{
temp += l + ",";
}
temp = temp.substr(0, temp.length() - 1);
temp += ")";
return temp;
}
};