1 #ifndef __DIADES__GRAPH__GRAPHNODESETTABLE__HH__ 2 #define __DIADES__GRAPH__GRAPHNODESETTABLE__HH__ 23 return "Graph::NodeElement";
26 using Children = std::map<Node, std::unique_ptr<NodeElement>>;
51 "NodeElement: the node is not valid");
62 NodeElement(
Node n,
const T & inf) : _node(n), _inf(inf), _tag(true), _children() {
109 "getInfo: the current nodeElement does not contain any information");
119 "getInfo: the current nodeElement does not contain any information");
166 typename Children::iterator it;
168 std::tie(it, notFound) = _children.emplace(n,
new NodeElement(n));
170 return it->second.get();
181 auto it = _children.find(n);
182 return (it == _children.end()) ?
nullptr : it->second.get();
193 auto it = _children.find(n);
194 return (it == _children.end()) ?
nullptr : it->second.get();
202 inline ostream& operator<<(ostream &os, const NodeElement<T> & nodeElement) {
203 os <<
"***************************************************" << endl;
204 os <<
"Start NodeElement: " << &nodeElement << endl;
205 os <<
"***************************************************" << endl;
206 os <<
"\t node: " << nodeElement.
node() << endl;
207 os <<
"\t children: " << endl;
208 for (
auto it = nodeElement.children().begin();
209 it != nodeElement.children().end();
213 os <<
"***************************************************" << endl;
214 os <<
"End NodeElement: " << &nodeElement << endl;
215 os <<
"***************************************************" << endl;
228 template <
typename T>
233 return "Graph::GraphNodeSetTable";
274 while (nodeSetIt != ns.
end() && (currentNodeElement !=
nullptr)) {
275 currentNodeElement = currentNodeElement->
getChild(*nodeSetIt);
278 found = currentNodeElement !=
nullptr && currentNodeElement->
isTagged();
280 return currentNodeElement->
getInfo();
304 while (nodeSetIt != ns.
end() && (currentNodeElement !=
nullptr)) {
305 currentNodeElement = currentNodeElement->
getChild(*nodeSetIt);
308 found = currentNodeElement !=
nullptr && currentNodeElement->
isTagged();
310 return currentNodeElement->
getInfo();
339 while (nodeSetIt != ns.
end()) {
342 if (nextNodeSetIt == ns.
end()) {
345 if (!currentNodeElement->
isTagged()) {
346 currentNodeElement->
setInfo(info);
354 return currentNodeElement->
getInfo();
GraphNodeSetTable()
info object that is returned in case an specific info is not found, undetermined value ...
T & setInfo(const T &inf)
const T & getInfo(const GraphNodeSet &ns, bool &found) const
T _inf
node of the NodeElement
NodeElement * insertChildIfNotFound(Node n, bool &found)
NodeElement(Node n, const T &inf)
NodeElement * getChild(Node n)
Diades::Utils::Exception< GraphNodeSetTable > Exception
typename NodeElement< T >::Children Children
NodeElement()
list of node children
T & getInfo(const GraphNodeSet &ns, bool &found)
const NodeElement * getChild(Node n) const
Diades::Utils::Exception< NodeElement > Exception
std::map< Node, std::unique_ptr< NodeElement > > Children
#define require(Exception, expr, message)
Namespace of the Diades project.
set< Node >::const_iterator Iterator
bool _tag
informtaion of the NodeElement
boost::adjacency_list Graph
Children _children
is the information there or not ?
const Children & children() const
const T & getInfo() const
T _defaultInfo
root of the tree, if it is tagged then it encodes the presence of the empty set
T & insertIfNotFound(const GraphNodeSet &ns, const T &info, bool &found)
const Node & node() const