An attribute represents one value of a tag of a lanelet primitive. More...
#include <Attribute.h>
Public Types | |
using | Cache = boost::variant< bool, double, Id, int, Velocity > |
Public Member Functions | |
template<> | |
Optional< double > | as () const |
template<> | |
Optional< double > | as () const |
template<> | |
Optional< int > | as () const |
template<> | |
Optional< Velocity > | as () const |
template<> | |
Optional< int > | as () const |
template<> | |
Optional< bool > | as () const |
template<> | |
Optional< bool > | as () const |
template<> | |
Optional< Id > | as () const |
template<> | |
Optional< Id > | as () const |
template<> | |
Optional< Velocity > | as () const |
template<> | |
Optional< const char * > | as () const |
template<> | |
Optional< const char * > | as () const |
template<typename T > | |
Optional< ValueOfT< T > > | as () const |
templated version. Works ony for the as.. above More... | |
Optional< bool > | asBool () const |
interpret this attribute as bool value More... | |
Optional< double > | asDouble () const |
interpret this attribute as double value More... | |
Optional< Id > | asId () const |
interpret this attribute as an id More... | |
Optional< int > | asInt () const |
interpret this attribute as an int More... | |
Optional< Velocity > | asVelocity () const |
interpret this attribute as Velocity More... | |
Attribute ()=default | |
Attribute (bool value) | |
Attribute (const char *value) | |
Attribute (const std::string &value) | |
Attribute (const Velocity &value) | |
Attribute (double value) | |
Attribute (Id value) | |
Attribute (int value) | |
Attribute (std::string &&value) | |
void | setValue (const std::string &value) |
set the value of this attribute More... | |
const std::string & | value () const |
gets the value of this attribute More... | |
Private Types | |
template<typename T > | |
using | ValueOfT = typename internal::ValueOf< T >::Type |
Private Attributes | |
std::shared_ptr< Cache > | cache_ |
cache for the last queried value More... | |
std::string | value_ |
internal value of this parameter More... | |
An attribute represents one value of a tag of a lanelet primitive.
They are internally represented as strings but can be interpreted as numbers.
The result of the last as... is cached, therefore repeated calls to the same as.. function are very cheap.
Definition at line 32 of file Attribute.h.
using lanelet::Attribute::Cache = boost::variant<bool, double, Id, int, Velocity> |
Definition at line 37 of file Attribute.h.
|
private |
Definition at line 34 of file Attribute.h.
|
default |
|
inline |
Definition at line 40 of file Attribute.h.
|
inline |
Definition at line 41 of file Attribute.h.
|
inline |
Definition at line 42 of file Attribute.h.
lanelet::Attribute::Attribute | ( | bool | value | ) |
Definition at line 51 of file Attribute.cpp.
lanelet::Attribute::Attribute | ( | Id | value | ) |
Definition at line 49 of file Attribute.cpp.
lanelet::Attribute::Attribute | ( | int | value | ) |
Definition at line 53 of file Attribute.cpp.
lanelet::Attribute::Attribute | ( | double | value | ) |
Definition at line 55 of file Attribute.cpp.
lanelet::Attribute::Attribute | ( | const Velocity & | value | ) |
Definition at line 57 of file Attribute.cpp.
|
inline |
Definition at line 110 of file Attribute.h.
|
inline |
Definition at line 115 of file Attribute.h.
|
inline |
Definition at line 170 of file Attribute.h.
Definition at line 145 of file Attribute.h.
Definition at line 150 of file Attribute.h.
Definition at line 155 of file Attribute.h.
Definition at line 140 of file Attribute.h.
|
inline |
Definition at line 120 of file Attribute.h.
|
inline |
Definition at line 175 of file Attribute.h.
|
inline |
Definition at line 125 of file Attribute.h.
|
inline |
Definition at line 130 of file Attribute.h.
|
inline |
Definition at line 135 of file Attribute.h.
templated version. Works ony for the as.. above
Optional< bool > lanelet::Attribute::asBool | ( | ) | const |
interpret this attribute as bool value
ConversionError | if the attribute could not be interpreted as bool |
Definition at line 61 of file Attribute.cpp.
Optional< double > lanelet::Attribute::asDouble | ( | ) | const |
interpret this attribute as double value
Definition at line 81 of file Attribute.cpp.
interpret this attribute as an id
Definition at line 95 of file Attribute.cpp.
Optional< int > lanelet::Attribute::asInt | ( | ) | const |
interpret this attribute as an int
Definition at line 109 of file Attribute.cpp.
interpret this attribute as Velocity
The function can understand and correctly parse units in the attribute. "2. km/h", "2.mps", etc. To obtain the velocity as a double, divide it by the desired unit:
double v = attr.asVelocity() / KMH;
Definition at line 123 of file Attribute.cpp.
void lanelet::Attribute::setValue | ( | const std::string & | value | ) |
set the value of this attribute
value | new value |
Definition at line 149 of file Attribute.cpp.
|
inline |
|
mutableprivate |
cache for the last queried value
Definition at line 106 of file Attribute.h.
|
private |
internal value of this parameter
Definition at line 105 of file Attribute.h.