35 namespace viros {
namespace topomap {
45 template<
typename Reflector>
67 template<
typename Reflector>
71 r.member(
"Name",
mName,
"");
76 virtual void setName(
const std::string& name) {
80 virtual const std::string&
getName()
const {
100 template<
typename Reflector>
118 template <
typename AttributeClass>
127 template <
typename AttributeClass>
128 boost::shared_ptr<AttributeClass>
getAttribute(
const std::string& name,
bool inherited=
true) {
129 return boost::dynamic_pointer_cast<AttributeClass>(
getAttributeUntyped(name, AttributeClass::CLASS(), inherited));
134 template <
typename AttributeClass>
135 std::map<std::string, boost::shared_ptr<AttributeClass>>
getAllAttributes(
bool inherited=
true) {
136 std::map<std::string, AttributePtr> attributes;
137 typedef boost::shared_ptr<AttributeClass> AttributeClassPtr;
138 std::map<std::string, AttributeClassPtr> tattributes;
141 foreach(
auto& p, attributes)
142 tattributes[p.first] = boost::dynamic_pointer_cast<AttributeClass>(p.second);
153 template <
typename AttributeClass>
155 boost::shared_ptr<AttributeClass> obj = getAttribute<AttributeClass>(name,
false);
157 obj = boost::make_shared<AttributeClass>();
172 template<
typename Reflector>
175 r.member(
"name",
name,
"");
176 r.member(
"classid",
clazz,
"");
std::string mName
Definition: GraphElement.h:85
virtual const GraphElementPtr findElement(const std::string &predicate) const
Definition: GraphElement.h:55
NamedGraphElement(const std::string &name)
Definition: GraphElement.h:65
boost::shared_ptr< AttributeClass > obtainAttribute(const std::string &name)
Similar to getAttribute, but this method will create the attribute, if it does not exist yet...
Definition: GraphElement.h:154
bool operator<(const AttributeKey &other) const
Definition: GraphElement.h:179
virtual void setAttribute(const std::string &name, AttributePtr attribute)
Sets the given object as attribute with the given name.
std::map< std::string, boost::shared_ptr< AttributeClass > > getAllAttributes(bool inherited=true)
Definition: GraphElement.h:135
std::string name
Definition: GraphElement.h:169
boost::shared_ptr< Attribute > AttributePtr
Definition: TopoMapFwd.h:73
virtual void getAllAttributesUntyped(std::map< std::string, AttributePtr > &oAttributes, const mira::Class &clazz, bool inherited=true)
NamedGraphElement(const std::string &prefix, int)
virtual ~GraphElement()
Definition: GraphElement.h:43
AttributedGraphElement(const std::string &prefix, int)
Definition: GraphElement.h:95
Definition: GraphElement.h:167
void reflect(Reflector &r)
Definition: GraphElement.h:46
virtual ~AttributedGraphElement()
virtual AttributePtr getAttributeUntyped(const std::string &name, const mira::Class &clazz, bool inherited=true)
Returns NULL, if no such attribute exsits.
virtual const std::string & getName() const
Definition: GraphElement.h:80
empty base class for all graph elements (Nodes, GatewayNodes and Links)
Definition: GraphElement.h:40
virtual void removeAttribute(const std::string &name, const mira::Class &attrClass)
Removes the attribute with the given name and type.
void reflect(Reflector &r)
Definition: GraphElement.h:173
std::string clazz
Definition: GraphElement.h:170
boost::shared_ptr< GraphElement > GraphElementPtr
Definition: TopoMapFwd.h:80
AttributedGraphElement(const std::string &name)
Definition: GraphElement.h:96
void removeAttribute(const std::string &name)
same as above, but easier interface, where datatype is specified as template parameter ...
Definition: GraphElement.h:119
Definition: MetricCostmapTopoMapPlanner.h:45
std::map< AttributeKey, AttributePtr > mAttributes
Definition: GraphElement.h:185
virtual GraphElementPtr findElement(const std::string &predicate)
Definition: GraphElement.h:51
virtual void setName(const std::string &name)
Definition: GraphElement.h:76
void reflect(Reflector &r)
Definition: GraphElement.h:101
static volatile uint32 sID
Definition: GraphElement.h:87
Definition: GraphElement.h:60
void reflect(Reflector &r)
Definition: GraphElement.h:68
Definition: GraphElement.h:91
boost::shared_ptr< AttributeClass > getAttribute(const std::string &name, bool inherited=true)
Returns NULL, if no such attribute exsits.
Definition: GraphElement.h:128