Property Map for storing settings and statistical information. More...
Public Types | |
typedef std::map< std::string, boost::any > | storage_type |
Internal storage type used with the internal property map. More... | |
typedef storage_type::mapped_type | value_type |
Value type of the property map, i.e. std::string . More... | |
typedef storage_type::key_type | key_type |
Key type of the property map, i.e. boost::any . More... | |
typedef boost::shared_ptr < properties > | ptr |
Smart Pointer version of this class. More... | |
Public Member Functions | |
properties () | |
Standard constructor. More... | |
const value_type & | operator[] (const key_type &k) const |
Direct access to the value type. More... | |
template<typename T > | |
T | get (const key_type &k) const |
Casted access to an existing element. More... | |
template<typename T > | |
T | get (const key_type &k, const T &default_value) const |
Casted access to an existing element with fall-back option. More... | |
void | set (const key_type &k, const value_type &value) |
Adds or modifies a value in the property map. More... | |
storage_type::const_iterator | begin () const |
Start iterator for the properties. More... | |
storage_type::const_iterator | end () const |
End iterator for the properties. More... | |
unsigned | size () const |
Number of properties. More... | |
void | clear () |
Clears all properties. More... | |
Property Map for storing settings and statistical information.
In this data structure settings and statistical data can be stored. The key to access data is always of type std::string
and the value can be of any type. To be type-safe, the getter corresponding get functions have to be provided with a type.
typedef storage_type::key_type key_type |
Key type of the property map, i.e. boost::any
.
There are pre-defined getter methods, which can be called with a type identifier for explicit casting.
typedef boost::shared_ptr<properties> ptr |
Smart Pointer version of this class.
Inside the framework, always the Smart Pointer version is used. To have an easy access, there are special functions provided which take the smart pointer as parameter and check as well if it can be dereferenced.
typedef std::map<std::string, boost::any> storage_type |
Internal storage type used with the internal property map.
typedef storage_type::mapped_type value_type |
Value type of the property map, i.e. std::string
.
properties | ( | ) |
Standard constructor.
Creates the property map on base of the storage map
storage_type::const_iterator begin | ( | ) | const |
Start iterator for the properties.
void clear | ( | ) |
Clears all properties.
storage_type::const_iterator end | ( | ) | const |
End iterator for the properties.
|
inline |
Casted access to an existing element.
With T
you can specify the type of the element. Note, that it has to be the original used type, e.g. there is a difference even between int
and unsigned
.
The type is determined automatically using the set method.
k | Key to access the property map. Must exist. |
k
casted to its original type T
.
|
inline |
Casted access to an existing element with fall-back option.
The same as get(const key_type& k), but if k
does not exist, a default value is returned, which has to be of type T
.
k | Key to access the property map. May not exist. |
default_value | If k does not exist, this value is returned. |
k
casted to its original type T
. If the key k
does not exist, default_value
is returned.const value_type& operator[] | ( | const key_type & | k | ) | const |
Direct access to the value type.
Since the value_type
is of type boost::any
, it is not recommended to use this operator, but rather get and set.
k | Key to access the property map. Must exist. |
k
.void set | ( | const key_type & | k, |
const value_type & | value | ||
) |
Adds or modifies a value in the property map.
This methods sets the value located at key k
to value
. If the key does not exist, it will be created. Be careful which type was used, especially with typed constants:
k | Key of the property |
value | The new value of k . If k already existed, the type of value must not change. |
unsigned size | ( | ) | const |
Number of properties.