PhoenixGraph  01.0.0
Set of tools to simplify graph manipulation
Loading...
Searching...
No Matches
Node_impl.h
Go to the documentation of this file.
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
15
18template<typename T>
19std::string node_convertToString(const T & val){
20 std::stringstream str;
21 str << val;
22
23 std::string varStr(str.str()), outputStr(""), strCheck(" \t\n/.:-");
24 for(size_t i(0lu); i < varStr.size(); ++i){
25 char ch = varStr[i];
26 bool isNotFound(true);
27 for(size_t j(0lu); j < strCheck.size() && isNotFound; ++j){
28 isNotFound &= ch != strCheck[j];
29 }
30 if(isNotFound){
31 outputStr += ch;
32 }
33 }
34 return outputStr;
35}
36
38
40template<typename T, typename UIdx>
41Node<T, UIdx>::Node(const std::string & name){
43 p_name = name;
44}
45
46
49template<typename T, typename UIdx>
50Node<T, UIdx>::Node(const T & data, const std::string & name){
52 p_name = name;
53 p_data = data;
54}
55
57
59template<typename T, typename UIdx>
61 copyNode(other);
62}
63
65template<typename T, typename UIdx>
69
71
74template<typename T, typename UIdx>
76 copyNode(other);
77 return *this;
78}
79
81
83template<typename T, typename UIdx>
84void Node<T, UIdx>::addChild(UIdx child){
85 p_listChild.push_back(child);
86}
87
89
91template<typename T, typename UIdx>
92void Node<T, UIdx>::addParent(UIdx parent){
93 p_listParent.push_back(parent);
94}
95
97
99template<typename T, typename UIdx>
102}
103
105
107template<typename T, typename UIdx>
110}
111
113
115template<typename T, typename UIdx>
116void Node<T, UIdx>::setListChild(const std::list<UIdx> & listChild){p_listChild = listChild;}
117
119
121template<typename T, typename UIdx>
122void Node<T, UIdx>::setListParent(const std::list<UIdx> & listParent){p_listParent = listParent;}
123
125
127template<typename T, typename UIdx>
128void Node<T, UIdx>::setIndex(UIdx index){p_index = index;}
129
131
133template<typename T, typename UIdx>
134void Node<T, UIdx>::setName(const std::string & name){p_name = name;}
135
137
139template<typename T, typename UIdx>
140void Node<T, UIdx>::setIsUpdated(bool isUpdated){p_isUpdated = isUpdated;}
141
143
145template<typename T, typename UIdx>
146void Node<T, UIdx>::setData(const T & data){p_data = data;}
147
149
151template<typename T, typename UIdx>
152const std::list<UIdx> & Node<T, UIdx>::getListChild() const{return p_listChild;}
153
155
157template<typename T, typename UIdx>
158std::list<UIdx> & Node<T, UIdx>::getListChild(){return p_listChild;}
159
161
163template<typename T, typename UIdx>
164const std::list<UIdx> & Node<T, UIdx>::getListParent() const{return p_listParent;}
165
167
169template<typename T, typename UIdx>
170std::list<UIdx> & Node<T, UIdx>::getListParent(){return p_listParent;}
171
173
175template<typename T, typename UIdx>
176UIdx Node<T, UIdx>::getIndex() const{return p_index;}
177
179
181template<typename T, typename UIdx>
182const std::string & Node<T, UIdx>::getName() const{return p_name;}
183
185
187template<typename T, typename UIdx>
188std::string & Node<T, UIdx>::getName(){return p_name;}
189
191
193template<typename T, typename UIdx>
195
197
199template<typename T, typename UIdx>
201
203
205template<typename T, typename UIdx>
206const T & Node<T, UIdx>::getData() const{return p_data;}
207
209
211template<typename T, typename UIdx>
213
215
217template<typename T, typename UIdx>
218bool Node<T, UIdx>::isStart() const{return p_listParent.size() == 0lu;}
219
221
223template<typename T, typename UIdx>
224bool Node<T, UIdx>::isEnd() const{return p_listChild.size() == 0lu;}
225
227
229template<typename T, typename UIdx>
230std::string Node<T, UIdx>::getDotName() const{
231 std::string body("");
232 body += "node";
234 return body;
235}
236
238
240template<typename T, typename UIdx>
242 std::string body("");
243 std::string strName(p_name);
244 if(strName == ""){
245 strName = node_convertToString(p_index);
246 }
247 body += "\t" + getDotName() + "[label=\"" + strName + "\"][color=\"blue\"]";
248 if(isStart()){
249 body += "[shape=octagon]";
250 }else if(isEnd()){
251 body += "[shape=cylinder]";
252 }else{
253 body += "[shape=record]";
254 }
255 body += ";\n";
256 return body;
257}
258
260
262template<typename T, typename UIdx>
264 p_listChild = other.p_listChild;
266 p_index = other.p_index;
267 p_name = other.p_name;
268 p_isUpdated = other.p_isUpdated;
269 p_data = other.p_data;
270}
271
273template<typename T, typename UIdx>
275 p_name = "";
276 p_isUpdated = false;
277}
278
279
280
281
282
283#endif
284
285
286
std::string node_convertToString(const T &val)
Convert a type into a string.
Definition Node_impl.h:19
void setName(const std::string &name)
Set the name of the Node.
Definition Node_impl.h:134
const std::list< UIdx > & getListParent() const
Get the list of parents of the Node.
Definition Node_impl.h:164
const T & getData() const
Get the data of the Node.
Definition Node_impl.h:206
void setIsUpdated(bool isUpdated)
Say if the node is updated.
Definition Node_impl.h:140
std::string getDotName() const
Get the dot name of the current Node.
Definition Node_impl.h:230
std::string p_name
Name of the current Node.
Definition Node.h:69
void setData(const T &data)
Set the data of the Node.
Definition Node_impl.h:146
std::list< UIdx > p_listParent
List of parent Node.
Definition Node.h:65
void setListChild(const std::list< UIdx > &listChild)
Set the list of children of the Node.
Definition Node_impl.h:116
std::string getDotDefinition() const
Get the dot definition name of the current Node.
Definition Node_impl.h:241
Node & operator=(const Node< T, UIdx > &other)
Definition of equal operator of Node.
Definition Node_impl.h:75
void removeParent(UIdx parent)
Remove connection with parent.
Definition Node_impl.h:108
void addChild(UIdx child)
Add a child to the current Node.
Definition Node_impl.h:84
Node(const std::string &name="")
Default constructor of Node.
Definition Node_impl.h:41
const std::list< UIdx > & getListChild() const
Get the list of children of the Node.
Definition Node_impl.h:152
UIdx getIndex() const
Get the index of the Node.
Definition Node_impl.h:176
void setIndex(UIdx index)
Set the index of the Node.
Definition Node_impl.h:128
void addParent(UIdx parent)
Add a parent to the current Node.
Definition Node_impl.h:92
virtual ~Node()
Destructor of Node.
Definition Node_impl.h:66
void copyNode(const Node< T, UIdx > &other)
Copy function of Node.
Definition Node_impl.h:263
void setListParent(const std::list< UIdx > &listParent)
Set the list of parents of the Node.
Definition Node_impl.h:122
bool p_isUpdated
Check if the current Node has been already updated.
Definition Node.h:71
bool isEnd() const
Say if the current Node has no child.
Definition Node_impl.h:224
void initialisationNode()
Initialisation function of the class Node.
Definition Node_impl.h:274
bool getIsUpdated() const
Say if the node is updated.
Definition Node_impl.h:194
const std::string & getName() const
Get the name of the Node.
Definition Node_impl.h:182
std::list< UIdx > p_listChild
List of children Node.
Definition Node.h:63
void removeChild(UIdx child)
Remove connection with child.
Definition Node_impl.h:100
T p_data
Data of the node.
Definition Node.h:73
bool isStart() const
Say if the current Node has no parent.
Definition Node_impl.h:218
UIdx p_index
Index of the current Node.
Definition Node.h:67
void listindex_remove(std::list< UIdx > &listIndex, UIdx index)
Remove index from listIndex.