List of all members | Public Types | Public Member Functions
properties Struct Reference

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_typeoperator[] (const key_type &k) const
 Direct access to the value type. More...
 
template<typename T >
get (const key_type &k) const
 Casted access to an existing element. More...
 
template<typename 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...
 

Detailed Description

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.

Author
RevKit
Since
1.0

Member Typedef Documentation

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.

Author
RevKit
Since
1.0
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.

See Also
get
set_error_message
Author
RevKit
Since
1.0
typedef std::map<std::string, boost::any> storage_type

Internal storage type used with the internal property map.

Author
RevKit
Since
1.0
typedef storage_type::mapped_type value_type

Value type of the property map, i.e. std::string.

Author
RevKit
Since
1.0

Constructor & Destructor Documentation

Standard constructor.

Creates the property map on base of the storage map

Author
RevKit
Since
1.0

Member Function Documentation

storage_type::const_iterator begin ( ) const

Start iterator for the properties.

Returns
Iterator
Author
RevKit
Since
1.1
void clear ( )

Clears all properties.

Author
RevKit
Since
1.1
storage_type::const_iterator end ( ) const

End iterator for the properties.

Returns
Iterator
Author
RevKit
Since
1.1
T get ( const key_type k) const
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.

Parameters
kKey to access the property map. Must exist.
Returns
The value associated with key k casted to its original type T.
Author
RevKit
Since
1.0
T get ( const key_type k,
const T &  default_value 
) const
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.

Parameters
kKey to access the property map. May not exist.
default_valueIf k does not exist, this value is returned.
Returns
The value associated with key k casted to its original type T. If the key k does not exist, default_value is returned.
Author
RevKit
Since
1.0
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.

Parameters
kKey to access the property map. Must exist.
Returns
The value associated with key k.
Author
RevKit
Since
1.0
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:

p.set( "a unsigned number", 5u );
p.get<unsigned>( "a unsigned number" ); // OK!
p.get<int>( "a unsigned number" ); // FAIL!
p.set( "a signed number", 5 );
p.get<unsigned>( "a signed number" ); // FAIL!
p.get<int>( "a signed number" ); // OK!
Parameters
kKey of the property
valueThe new value of k. If k already existed, the type of value must not change.
Author
RevKit
Since
1.0
unsigned size ( ) const

Number of properties.

Returns
The number of properties
Author
RevKit
Since
1.0

The documentation for this struct was generated from the following file:

Generated on Tue Apr 16 2013 08:12:02 for RevKit by doxygen 1.8.3.1