-
Notifications
You must be signed in to change notification settings - Fork 0
/
Labelling.cpp
134 lines (118 loc) · 2.9 KB
/
Labelling.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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* @file Labelling.cpp
* @class Labelling
* @brief Class representing a single labelling assignment
* @author Federico Cerutti <[email protected]>
* @copyright GNU Public License v2
*/
#include "Labelling.h"
/**
* @var Label Labelling::lab_in
* @brief Label representing an `in` argument
*/
const Label Labelling::lab_in = "in";
/**
* @var Label Labelling::lab_out
* @brief Label representing an `out` argument
*/
const Label Labelling::lab_out = "out";
/**
* @var Label Labelling::lab_undec
* @brief Label representing an `undec` argument
*/
const Label Labelling::lab_undec = "undec";
/**
* @brief Constructor
*/
Labelling::Labelling()
{
this->labelling = map<Argument *, Label>();
this->in = SetArguments();
this->out = SetArguments();
this->undec = SetArguments();
}
/**
* @brief Add a new label to this set of labelling
* @param[in] arg The argument to which this labelling applies
* @param[in] l The label. Valid values for are:
* * Labelling::lab_in
* * Labelling::lab_out
* * Labelling::lab_undec
*/
void Labelling::add_label(Argument * arg, Label l)
{
this->labelling.insert(pair<Argument *, Label>(arg, l));
if (l.compare(Labelling::lab_in) == 0)
this->in.add_Argument(arg);
else if (l.compare(Labelling::lab_out) == 0)
this->out.add_Argument(arg);
else if (l.compare(Labelling::lab_undec) == 0)
this->undec.add_Argument(arg);
}
/**
* @brief Check whether an argument is in this labelling or not
* @param[in] arg A pointer to an Argument
* @retval bool
*/
bool Labelling::exists_argument_labelling(Argument *arg)
{
return (this->labelling.find(arg) != this->labelling.end());
}
/**
* @brief Returns the label of a given argument
* @param[in] arg A pointer to an argument
* @retval Label
*/
Label Labelling::get_label(Argument *arg)
{
return this->labelling.at(arg);
}
/**
* @brief Returns the set of arguments labelled as `in`
* @retval SetArguments *
*/
SetArguments *Labelling::inargs()
{
return &(this->in);
}
/**
* @brief Returns the set of arguments labelled as `out`
* @retval SetArguments *
*/
SetArguments *Labelling::outargs()
{
return &(this->out);
}
/**
* @brief Returns the set of arguments labelled as `undec`
* @retval SetArguments *
*/
SetArguments *Labelling::undecargs()
{
return &(this->undec);
}
/**
* @brief Check whether or not this labelling is empty
* @retval bool
*/
bool Labelling::empty()
{
return this->labelling.empty() && this->in.empty() && this->out.empty() && this->undec.empty();
}
/**
* @brief Clone this labelling into a new one
* @param[out] other A pointer to a Labelling which will be the clone of this one
* @retval void
*/
void Labelling::clone(Labelling *other)
{
map<Argument *, Label>::iterator it;
for (it = this->labelling.begin(); it != this->labelling.end(); it++)
{
other->add_label((*it).first, (*it).second);
}
}
Labelling::~Labelling()
{
// TODO Auto-generated destructor stub
}