Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
lanelet::Attribute Class Reference

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< Velocityas () const
 
template<>
Optional< int > as () const
 
template<>
Optional< bool > as () const
 
template<>
Optional< bool > as () const
 
template<>
Optional< Idas () const
 
template<>
Optional< Idas () const
 
template<>
Optional< Velocityas () 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< IdasId () const
 interpret this attribute as an id More...
 
Optional< int > asInt () const
 interpret this attribute as an int More...
 
Optional< VelocityasVelocity () 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< Cachecache_
 cache for the last queried value More...
 
std::string value_
 internal value of this parameter More...
 

Detailed Description

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.

Member Typedef Documentation

◆ Cache

using lanelet::Attribute::Cache = boost::variant<bool, double, Id, int, Velocity>

Definition at line 37 of file Attribute.h.

◆ ValueOfT

template<typename T >
using lanelet::Attribute::ValueOfT = typename internal::ValueOf<T>::Type
private

Definition at line 34 of file Attribute.h.

Constructor & Destructor Documentation

◆ Attribute() [1/9]

lanelet::Attribute::Attribute ( )
default

◆ Attribute() [2/9]

lanelet::Attribute::Attribute ( const std::string &  value)
inline

Definition at line 40 of file Attribute.h.

◆ Attribute() [3/9]

lanelet::Attribute::Attribute ( std::string &&  value)
inline

Definition at line 41 of file Attribute.h.

◆ Attribute() [4/9]

lanelet::Attribute::Attribute ( const char *  value)
inline

Definition at line 42 of file Attribute.h.

◆ Attribute() [5/9]

lanelet::Attribute::Attribute ( bool  value)

Definition at line 51 of file Attribute.cpp.

◆ Attribute() [6/9]

lanelet::Attribute::Attribute ( Id  value)

Definition at line 49 of file Attribute.cpp.

◆ Attribute() [7/9]

lanelet::Attribute::Attribute ( int  value)

Definition at line 53 of file Attribute.cpp.

◆ Attribute() [8/9]

lanelet::Attribute::Attribute ( double  value)

Definition at line 55 of file Attribute.cpp.

◆ Attribute() [9/9]

lanelet::Attribute::Attribute ( const Velocity value)

Definition at line 57 of file Attribute.cpp.

Member Function Documentation

◆ as() [1/13]

template<>
Optional<double> lanelet::Attribute::as ( ) const
inline

Definition at line 110 of file Attribute.h.

◆ as() [2/13]

template<>
Optional<double> lanelet::Attribute::as ( ) const
inline

Definition at line 115 of file Attribute.h.

◆ as() [3/13]

template<>
Optional<const char*> lanelet::Attribute::as ( ) const
inline

Definition at line 170 of file Attribute.h.

◆ as() [4/13]

template<>
Optional<Id> lanelet::Attribute::as ( ) const
inline

Definition at line 145 of file Attribute.h.

◆ as() [5/13]

template<>
Optional<Velocity> lanelet::Attribute::as ( ) const
inline

Definition at line 150 of file Attribute.h.

◆ as() [6/13]

template<>
Optional<Velocity> lanelet::Attribute::as ( ) const
inline

Definition at line 155 of file Attribute.h.

◆ as() [7/13]

template<>
Optional<Id> lanelet::Attribute::as ( ) const
inline

Definition at line 140 of file Attribute.h.

◆ as() [8/13]

template<>
Optional<int> lanelet::Attribute::as ( ) const
inline

Definition at line 120 of file Attribute.h.

◆ as() [9/13]

template<>
Optional<const char*> lanelet::Attribute::as ( ) const
inline

Definition at line 175 of file Attribute.h.

◆ as() [10/13]

template<>
Optional<int> lanelet::Attribute::as ( ) const
inline

Definition at line 125 of file Attribute.h.

◆ as() [11/13]

template<>
Optional<bool> lanelet::Attribute::as ( ) const
inline

Definition at line 130 of file Attribute.h.

◆ as() [12/13]

template<>
Optional<bool> lanelet::Attribute::as ( ) const
inline

Definition at line 135 of file Attribute.h.

◆ as() [13/13]

template<typename T >
Optional<ValueOfT<T> > lanelet::Attribute::as ( ) const

templated version. Works ony for the as.. above

◆ asBool()

Optional< bool > lanelet::Attribute::asBool ( ) const

interpret this attribute as bool value

Exceptions
ConversionErrorif the attribute could not be interpreted as bool
Returns
bool value

Definition at line 61 of file Attribute.cpp.

◆ asDouble()

Optional< double > lanelet::Attribute::asDouble ( ) const

interpret this attribute as double value

Returns
double if possible to convert the value

Definition at line 81 of file Attribute.cpp.

◆ asId()

Optional< Id > lanelet::Attribute::asId ( ) const

interpret this attribute as an id

Returns
id if possible to convert the value

Definition at line 95 of file Attribute.cpp.

◆ asInt()

Optional< int > lanelet::Attribute::asInt ( ) const

interpret this attribute as an int

Returns
int if possible to convert the value

Definition at line 109 of file Attribute.cpp.

◆ asVelocity()

Optional< Velocity > lanelet::Attribute::asVelocity ( ) const

interpret this attribute as Velocity

Returns
Velocity if possible to convert the value

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.

◆ setValue()

void lanelet::Attribute::setValue ( const std::string &  value)

set the value of this attribute

Parameters
valuenew value

Definition at line 149 of file Attribute.cpp.

◆ value()

const std::string& lanelet::Attribute::value ( ) const
inline

gets the value of this attribute

Returns
value

Definition at line 96 of file Attribute.h.

Member Data Documentation

◆ cache_

std::shared_ptr<Cache> lanelet::Attribute::cache_
mutableprivate

cache for the last queried value

Definition at line 106 of file Attribute.h.

◆ value_

std::string lanelet::Attribute::value_
private

internal value of this parameter

Definition at line 105 of file Attribute.h.


The documentation for this class was generated from the following files:


lanelet2_core
Author(s): Fabian Poggenhans
autogenerated on Thu Mar 6 2025 03:25:52