27#ifndef G2O_PROPERTY_H_
28#define G2O_PROPERTY_H_
43 const std::string&
name() {
return _name; }
61 std::stringstream sstr;
78 :
protected std::map<std::string, BaseProperty*> {
80 typedef std::map<std::string, BaseProperty*>
BaseClass;
94 bool eraseProperty(
const std::string& name_);
102 if (it == end())
return nullptr;
103 return dynamic_cast<P*
>(it->second);
105 template <
typename P>
108 if (it == end())
return nullptr;
109 return dynamic_cast<P*
>(it->second);
115 template <
typename P>
116 P*
makeProperty(
const std::string& name_,
const typename P::ValueType& v) {
119 P* p =
new P(name_, v);
123 return dynamic_cast<P*
>(it->second);
130 bool updatePropertyFromString(
const std::string& name,
131 const std::string& value);
137 bool updateMapFromString(
const std::string& values);
139 void writeToCSV(std::ostream& os)
const;
141 using BaseClass::begin;
142 using BaseClass::const_iterator;
143 using BaseClass::end;
144 using BaseClass::iterator;
145 using BaseClass::size;
virtual std::string toString() const =0
const std::string & name()
virtual bool fromString(const std::string &s)=0
a collection of properties mapping from name to the property itself
const P * getProperty(const std::string &name_) const
P * makeProperty(const std::string &name_, const typename P::ValueType &v)
P * getProperty(const std::string &name_)
std::map< std::string, BaseProperty * > BaseClass
BaseClass::const_iterator PropertyMapConstIterator
BaseClass::iterator PropertyMapIterator
Property(const std::string &name_)
void setValue(const T &v)
virtual bool fromString(const std::string &s)
Property(const std::string &name_, const T &v)
virtual std::string toString() const
Property< bool > BoolProperty
Property< std::string > StringProperty
bool convertString(const std::string &s, T &x, bool failIfLeftoverChars=true)
Property< double > DoubleProperty
Property< int > IntProperty
Property< float > FloatProperty