properties Struct Reference

Property Map for storing settings and statistical information. More...

List of all members.

Public Types

typedef std::map< std::string,
boost::any > 
storage_type
 Internal storage type used with the internal property map.
typedef
boost::associative_property_map
< storage_type
property_map_type
 Internal property map type which makes use of the storage type.
typedef boost::property_traits
< property_map_type >
::value_type 
value_type
 Value type of the property map, i.e. std::string.
typedef boost::property_traits
< property_map_type >
::key_type 
key_type
 Key type of the property map, i.e. boost::any.
typedef boost::shared_ptr
< properties
ptr
 Smart Pointer version of this class.

Public Member Functions

 properties ()
 Standard constructor.
value_typeoperator[] (const key_type &k) const
 Direct access to the value type.
template<typename T >
get (const key_type &k) const
 Casted access to an existing element.
template<typename T >
get (const key_type &k, const T &default_value) const
 Casted access to an existing element with fall-back option.
void set (const key_type &k, const value_type &value)
 Adds or modifies a value in the property map.
storage_type::const_iterator begin () const
 Start iterator for the properties.
storage_type::const_iterator end () const
 End iterator for the properties.
unsigned size () const
 Number of properties.
void clear ()
 Clears all properties.

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 boost::property_traits<property_map_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::associative_property_map<storage_type> property_map_type

Internal property map type which makes use of the storage type.

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 boost::property_traits<property_map_type>::value_type value_type

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

Author:
RevKit
Since:
1.0

Constructor & Destructor Documentation

properties (  ) 

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:
k Key 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:
k Key to access the property map. May not exist.
default_value If 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
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:
k Key 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:

 properties p;
 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:
k Key of the property
value The 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 Dec 21 2010 21:52:13 for RevKit by doxygen 1.7.1