MIRA
TopoMap.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2013,
3  Neuroinformatics and Cognitive Robotics Labs at TU Ilmenau, Germany
4 
5 All rights reserved.
6 
7 Copying, resale, or redistribution, with or without modification, is strictly
8 prohibited.
9 
10 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
11 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
12 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
13 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
14 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES,
15 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 */
17 
26 #pragma once
27 
28 #include <topomap/Node.h>
29 #include <topomap/GatewayNode.h>
30 #include <topomap/Link.h>
31 
32 namespace viros { namespace topomap {
33 
35 
36 class TopoMap
37 {
38 public:
39  TopoMap();
40 
41  static TopoMapPtr create() {
42  return boost::make_shared<TopoMap>();
43  }
44 
45  template<typename Reflector>
46  void reflect(Reflector& r)
47  {
48  r.member("Root", mRoot, "Root node of the map");
49  }
50 
51 public:
52 
54  void clear();
55 
56 
57  NodePtr getRoot() { return mRoot; }
58 
63  template <typename Visitor>
64  void visitNodes(Visitor&& visitor)
65  {
66  mRoot->visitChildNodes(visitor, true);
67  }
68 
69 public:
70 
72  GraphElementPtr findElement(const std::string& predicate);
73  const GraphElementPtr findElement(const std::string& predicate) const;
74 
75 
76 public:
77 
83 
84 public:
85 
86  NodePtr createNode(NodePtr parent = NodePtr());
88  LinkPtr createLink(GatewayNodePtr from, GatewayNodePtr to, bool bidirektional=true, double costs=0.0);
89 
90 public:
91 
92  void dumpGraphviz(std::ostream& os, bool hideIntraLinks=false);
93 
94 private:
95  NodePtr mRoot;
96  std::map<GraphElementPtr,std::string> mNames;
97 };
98 
99 
101 
102 } } // namespace
void clear()
removes all content and starts with an empty graph
boost::shared_ptr< Link > LinkPtr
Definition: TopoMapFwd.h:89
GraphElementPtr findElement(const std::string &predicate)
Returns the graph element with the given predicate, or NULL if no such element exists.
GatewayNodePtr createGatewayNode(NodePtr node)
boost::shared_ptr< GatewayNode > GatewayNodePtr
Definition: TopoMapFwd.h:87
static NodePtr lowestCommonAncestor(NodePtr m, NodePtr n)
Returns the lowest common ancestor of the two nodes, or rises an XLogical exception, if both nodes are not part of the same TopoMap.
void visitNodes(Visitor &&visitor)
Calls the operator()(NodePtr node) of the given visitor for each node (recurses the tree recursively ...
Definition: TopoMap.h:64
Definition: TopoMap.h:36
NodePtr getRoot()
Definition: TopoMap.h:57
NodePtr createNode(NodePtr parent=NodePtr())
void reflect(Reflector &r)
Definition: TopoMap.h:46
void dumpGraphviz(std::ostream &os, bool hideIntraLinks=false)
boost::shared_ptr< GraphElement > GraphElementPtr
Definition: TopoMapFwd.h:80
boost::shared_ptr< TopoMap > TopoMapPtr
Definition: TopoMapFwd.h:91
boost::shared_ptr< Node > NodePtr
Definition: TopoMapFwd.h:84
Definition: MetricCostmapTopoMapPlanner.h:45
static TopoMapPtr create()
Definition: TopoMap.h:41
LinkPtr createLink(GatewayNodePtr from, GatewayNodePtr to, bool bidirektional=true, double costs=0.0)