GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/PhoenixGraph/src/Node_impl.h Lines: 76 77 98.7 %
Date: 2023-10-11 10:52:07 Branches: 41 48 85.4 %

Line Branch Exec Source
1
/***************************************
2
	Auteur : Pierre Aubert
3
	Mail : pierre.aubert@lapp.in2p3.fr
4
	Licence : CeCILL-C
5
****************************************/
6
7
#ifndef __NODE_H_IMPL__
8
#define __NODE_H_IMPL__
9
10
#include <sstream>
11
12
#include "Node.h"
13
14
///Convert a type into a string
15
/**	@param val : value to be converted
16
 * 	@return converted string
17
*/
18
template<typename T>
19
104
std::string node_convertToString(const T & val){
20
208
	std::stringstream str;
21
104
	str << val;
22
23
312
	std::string varStr(str.str()), outputStr(""), strCheck(" \t\n/.:");
24
208
	for(size_t i(0lu); i < varStr.size(); ++i){
25
104
		char ch = varStr[i];
26
104
		bool isNotFound(true);
27

728
		for(size_t j(0lu); j < strCheck.size() && isNotFound; ++j){
28
624
			isNotFound &= ch != strCheck[j];
29
		}
30
104
		if(isNotFound){
31
104
			outputStr += ch;
32
		}
33
	}
34
208
	return outputStr;
35
}
36
37
///Default constructor of Node
38
/**	@param name : name of th current Node
39
*/
40
template<typename T, typename UIdx>
41
26
Node<T, UIdx>::Node(const std::string & name){
42
26
	initialisationNode();
43
26
	p_name = name;
44
26
}
45
///Constructor of Node
46
/**	@param data : data of the current Node
47
 * 	@param name : name of th current Node
48
*/
49
template<typename T, typename UIdx>
50
26
Node<T, UIdx>::Node(const T & data, const std::string & name){
51
26
	initialisationNode();
52
26
	p_name = name;
53
26
	p_data = data;
54
26
}
55
56
///Copy constructor of Node
57
/**	@param other : class to copy
58
*/
59
template<typename T, typename UIdx>
60
Node<T, UIdx>::Node(const Node<T, UIdx> & other){
61
	copyNode(other);
62
}
63
64
///Destructor of Node
65
template<typename T, typename UIdx>
66
104
Node<T, UIdx>::~Node(){
67
68
}
69
70
///Definition of equal operator of Node
71
/**	@param other : class to copy
72
 * 	@return copied class
73
*/
74
template<typename T, typename UIdx>
75
26
Node<T, UIdx> & Node<T, UIdx>::operator = (const Node<T, UIdx> & other){
76
26
	copyNode(other);
77
26
	return *this;
78
}
79
80
///Add a child to the current Node
81
/**	@param child : index of the corresponding child Node
82
*/
83
template<typename T, typename UIdx>
84
24
void Node<T, UIdx>::addChild(UIdx child){
85
24
	p_listChild.push_back(child);
86
24
}
87
88
///Add a parent to the current Node
89
/**	@param parent : index of the corresponding parent Node
90
*/
91
template<typename T, typename UIdx>
92
24
void Node<T, UIdx>::addParent(UIdx parent){
93
24
	p_listParent.push_back(parent);
94
24
}
95
96
///Remove connection with child
97
/**	@param child : index of the child to be removed
98
*/
99
template<typename T, typename UIdx>
100
1
void Node<T, UIdx>::removeChild(UIdx child){
101
1
	listindex_remove(p_listChild, child);
102
1
}
103
104
///Remove connection with parent
105
/**	@param parent : index of the parent to be removed
106
*/
107
template<typename T, typename UIdx>
108
1
void Node<T, UIdx>::removeParent(UIdx parent){
109
1
	listindex_remove(p_listParent, parent);
110
1
}
111
112
///Set the list of children of the Node
113
/**	@param listChild : list of children of the Node
114
*/
115
template<typename T, typename UIdx>
116
void Node<T, UIdx>::setListChild(const std::list<UIdx> & listChild){p_listChild = listChild;}
117
118
///Set the list of parents of the Node
119
/**	@param listParent : list of parents of the Node
120
*/
121
template<typename T, typename UIdx>
122
void Node<T, UIdx>::setListParent(const std::list<UIdx> & listParent){p_listParent = listParent;}
123
124
///Set the index of the Node
125
/**	@param index : index of the Node
126
*/
127
template<typename T, typename UIdx>
128
26
void Node<T, UIdx>::setIndex(UIdx index){p_index = index;}
129
130
///Set the name of the Node
131
/**	@param name : name of the Node
132
*/
133
template<typename T, typename UIdx>
134
void Node<T, UIdx>::setName(const std::string & name){p_name = name;}
135
136
///Say if the node is updated
137
/**	@param isUpdated : true if the Node is updated, false otherwise
138
*/
139
template<typename T, typename UIdx>
140
26
void Node<T, UIdx>::setIsUpdated(bool isUpdated){p_isUpdated = isUpdated;}
141
142
///Set the data of the Node
143
/**	@param data : data of the Node
144
*/
145
template<typename T, typename UIdx>
146
void Node<T, UIdx>::setData(const T & data){p_data = data;}
147
148
///Get the list of children of the Node
149
/**	@return list of children of the Node
150
*/
151
template<typename T, typename UIdx>
152
42
const std::list<UIdx> & Node<T, UIdx>::getListChild() const{return p_listChild;}
153
154
///Get the list of children of the Node
155
/**	@return list of children of the Node
156
*/
157
template<typename T, typename UIdx>
158
10
std::list<UIdx> & Node<T, UIdx>::getListChild(){return p_listChild;}
159
160
///Get the list of parents of the Node
161
/**	@return list of parents of the Node
162
*/
163
template<typename T, typename UIdx>
164
5
const std::list<UIdx> & Node<T, UIdx>::getListParent() const{return p_listParent;}
165
166
///Get the list of parents of the Node
167
/**	@return list of parents of the Node
168
*/
169
template<typename T, typename UIdx>
170
9
std::list<UIdx> & Node<T, UIdx>::getListParent(){return p_listParent;}
171
172
///Get the index of the Node
173
/**	@return index of the Node
174
*/
175
template<typename T, typename UIdx>
176
UIdx Node<T, UIdx>::getIndex() const{return p_index;}
177
178
///Get the name of the Node
179
/**	@return name of the Node
180
*/
181
template<typename T, typename UIdx>
182
const std::string & Node<T, UIdx>::getName() const{return p_name;}
183
184
///Get the name of the Node
185
/**	@return name of the Node
186
*/
187
template<typename T, typename UIdx>
188
std::string & Node<T, UIdx>::getName(){return p_name;}
189
190
///Say if the node is updated
191
/**	@return true if the Node is updated, false otherwise
192
*/
193
template<typename T, typename UIdx>
194
10
bool Node<T, UIdx>::getIsUpdated() const{return p_isUpdated;}
195
196
///Say if the node is updated
197
/**	@return true if the Node is updated, false otherwise
198
*/
199
template<typename T, typename UIdx>
200
8
bool & Node<T, UIdx>::getIsUpdated(){return p_isUpdated;}
201
202
///Get the data of the Node
203
/**	@return data of the Node
204
*/
205
template<typename T, typename UIdx>
206
const T & Node<T, UIdx>::getData() const{return p_data;}
207
208
///Get the data of the Node
209
/**	@return data of the Node
210
*/
211
template<typename T, typename UIdx>
212
T & Node<T, UIdx>::getData(){return p_data;}
213
214
///Say if the current Node has no parent
215
/**	@return true if the current Node has no parent, false otherwise
216
*/
217
template<typename T, typename UIdx>
218
41
bool Node<T, UIdx>::isStart() const{return p_listParent.size() == 0lu;}
219
220
///Say if the current Node has no child
221
/**	@return true if the current Node has no child, false otherwise
222
*/
223
template<typename T, typename UIdx>
224
25
bool Node<T, UIdx>::isEnd() const{return p_listChild.size() == 0lu;}
225
226
///Get the dot name of the current Node
227
/**	@return dot name of the current Node
228
*/
229
template<typename T, typename UIdx>
230
104
std::string Node<T, UIdx>::getDotName() const{
231
104
	std::string body("");
232
104
	body += "node";
233
104
	body += node_convertToString(p_index);
234
104
	return body;
235
}
236
237
///Get the dot definition name of the current Node
238
/**	@return dot definition name of the current Node
239
*/
240
template<typename T, typename UIdx>
241
36
std::string Node<T, UIdx>::getDotDefinition() const{
242
36
	std::string body("");
243
72
	std::string strName(p_name);
244
36
	if(strName == ""){
245
		strName = node_convertToString(p_index);
246
	}
247

36
	body += "\t" + getDotName() + "[label=\"" + strName + "\"][color=\"blue\"]";
248
36
	if(isStart()){
249
16
		body += "[shape=octagon]";
250
20
	}else if(isEnd()){
251
6
		body += "[shape=cylinder]";
252
	}else{
253
14
		body += "[shape=record]";
254
	}
255
36
	body += ";\n";
256
72
	return body;
257
}
258
259
///Copy function of Node
260
/**	@param other : class to copy
261
*/
262
template<typename T, typename UIdx>
263
26
void Node<T, UIdx>::copyNode(const Node<T, UIdx> & other){
264
26
	p_listChild = other.p_listChild;
265
26
	p_listParent = other.p_listParent;
266
26
	p_index = other.p_index;
267
26
	p_name = other.p_name;
268
26
	p_isUpdated = other.p_isUpdated;
269
26
	p_data = other.p_data;
270
26
}
271
272
///Initialisation function of the class Node
273
template<typename T, typename UIdx>
274
52
void Node<T, UIdx>::initialisationNode(){
275
52
	p_name = "";
276
52
	p_isUpdated = false;
277
52
}
278
279
280
281
282
283
#endif
284
285
286