|
libosmscout 0.1
|
Helper template class for easy access to the value of a certain feature for objects of any type. More...
#include <FeatureReader.h>
Public Member Functions | |
| FeatureValueReader (const TypeConfig &typeConfig) | |
| bool | GetIndex (const FeatureValueBuffer &buffer, size_t &index) const |
| Returns the index of the Feature/FeatureValue within the given FeatureValueBuffer. | |
| V * | GetValue (const FeatureValueBuffer &buffer) const |
| Returns the FeatureValue for the given FeatureValueBuffer. | |
| V | GetValue (const FeatureValueBuffer &buffer, const V &defaultValue) const |
| Returns the FeatureValue for the given FeatureValueBuffer or a defaultValue, if the feature is not set. | |
Helper template class for easy access to the value of a certain feature for objects of any type.
Each type may have stored the feature in request at a different index. The FeatureValueReader caches the index for each type once in the constructor and later on allows access to the feature value in O(1) - without iterating of all feature(values) of an object.
|
explicit |
| bool osmscout::FeatureValueReader< F, V >::GetIndex | ( | const FeatureValueBuffer & | buffer, |
| size_t & | index ) const |
Returns the index of the Feature/FeatureValue within the given FeatureValueBuffer.
| buffer | The FeatureValueBuffer instance |
| index | The index |
References osmscout::TypeInfo::GetIndex(), and osmscout::FeatureValueBuffer::GetType().
| V * osmscout::FeatureValueReader< F, V >::GetValue | ( | const FeatureValueBuffer & | buffer | ) | const |
Returns the FeatureValue for the given FeatureValueBuffer.
| buffer | The FeatureValueBuffer instance |
References osmscout::TypeInfo::GetIndex(), osmscout::FeatureValueBuffer::GetType(), osmscout::FeatureValueBuffer::GetValue(), and osmscout::FeatureValueBuffer::HasFeature().
Referenced by osmscout::LocationDescriptionService::DescribeLocationByHighwayMilestone(), osmscout::PositionAgent::Process(), and osmscout::SpeedAgent::Process().
| V osmscout::FeatureValueReader< F, V >::GetValue | ( | const FeatureValueBuffer & | buffer, |
| const V & | defaultValue ) const |
Returns the FeatureValue for the given FeatureValueBuffer or a defaultValue, if the feature is not set.
| buffer | The FeatureValueBuffer instance |
References osmscout::TypeInfo::GetIndex(), osmscout::FeatureValueBuffer::GetType(), osmscout::FeatureValueBuffer::GetValue(), and osmscout::FeatureValueBuffer::HasFeature().