13 #include <boost/shared_ptr.hpp>
14 #include <boost/function.hpp>
15 #include <boost/variant.hpp>
19 namespace MAKVRinTerra
33 typedef boost::shared_ptr<DtFeature>
Ptr;
34 typedef boost::shared_ptr<const DtFeature>
CPtr;
37 typedef boost::variant<
52 String(
const std::string&);
55 const char* c_str()
const;
59 bool operator<(
const String&)
const;
65 Key(
const std::string& name,
unsigned index = 0);
66 Key(
const String& name,
unsigned index = 0);
67 Key(
const char* name,
unsigned index = 0);
68 Key(
const Key& key,
unsigned index = 0);
72 bool operator< (
const Key&)
const;
92 static std::string TypeOfAttribute(
const Attribute&);
98 static Ptr CreateEmptyFeature();
116 virtual CPtr getPtr()
const;
129 virtual unsigned numberOfAttributes(
const Key::String &)
const = 0;
132 virtual bool hasAttribute(
const Key & k)
const;
135 virtual boost::optional<Attribute> attribute(
const Key &)
const = 0;
137 template <
typename T>
138 boost::optional<T> attributeAs(
const Key& k)
const
140 if (boost::optional<Attribute> attr = attribute(k))
143 return boost::optional<T>();
146 template <
typename Feature>
150 template <
typename T>
153 template <
typename From>
154 boost::optional<T> operator()(
const From& from)
const
158 return boost::lexical_cast<T>(from);
160 catch (boost::bad_lexical_cast&)
162 return boost::optional<T>();
168 template <
typename Feature>
174 typedef typename Feature::Key
Key;
176 typename Feature::CPtr
getPtr()
const {
return typename Feature::Ptr(
clone()); }