echelon  0.8.0
Public Member Functions | List of all members
echelon::attribute_repository< Parent > Class Template Reference

Attribute manager, which should be embedded into a parent object, which supports attributes. More...

#include <attribute_repository.hpp>

Public Member Functions

attribute create (const std::string &name, const type &datatype)
 Creates a new attribute. More...
 
template<typename T >
attribute create (const std::string &name)
 Creates a new attribute. More...
 
template<typename T >
attribute create (const std::string &name, const T &value)
 Creates a new attribute and initializes it with a given value. More...
 
attribute operator[] (const std::string &name) const
 Accessor function for this attribute repository. More...
 
bool exists (const std::string &name) const
 Tests, if an attribute exists. More...
 
attribute require (const std::string &name, const type &datatype)
 Returns the requested attribute, if it already exists, otherwise a new attribute is created. More...
 
template<typename T >
attribute require (const std::string &name)
 Returns the requested attribute, if it already exists, otherwise the attribute is created. More...
 
template<typename T >
attribute require (const std::string &name, const T &value)
 Returns the requested attribute, if it already exists, otherwise a new attribute is created. More...
 

Detailed Description

template<typename Parent>
class echelon::attribute_repository< Parent >

Attribute manager, which should be embedded into a parent object, which supports attributes.

Template Parameters
ParentType of the object into which the attribute repository is embedded.

Member Function Documentation

template<typename Parent>
attribute echelon::attribute_repository< Parent >::create ( const std::string &  name,
const type datatype 
)
inline

Creates a new attribute.

Parameters
namename of the new attribute
datatypevalue type of the new attribute
Returns
a handle to the new attribute
template<typename Parent>
template<typename T >
attribute echelon::attribute_repository< Parent >::create ( const std::string &  name)
inline

Creates a new attribute.

Template Parameters
TC++ type, which should be used to determine the dataset's value type
Parameters
namename of the new attribute
Returns
a handle to the new attribute
template<typename Parent>
template<typename T >
attribute echelon::attribute_repository< Parent >::create ( const std::string &  name,
const T &  value 
)
inline

Creates a new attribute and initializes it with a given value.

Template Parameters
TC++ type, which should be used to determine the dataset's value type
Parameters
namename of the new attribute
valuevalue, which is used to initialize the attribute
Returns
a handle to the new attribute
template<typename Parent>
bool echelon::attribute_repository< Parent >::exists ( const std::string &  name) const
inline

Tests, if an attribute exists.

Parameters
namename of the requested attribute
Returns
true, if the requested attribute exists, false otherwise
template<typename Parent>
attribute echelon::attribute_repository< Parent >::operator[] ( const std::string &  name) const
inline

Accessor function for this attribute repository.

Parameters
namename of the requested attribute
Returns
a handle to the requested attribute
template<typename Parent>
attribute echelon::attribute_repository< Parent >::require ( const std::string &  name,
const type datatype 
)
inline

Returns the requested attribute, if it already exists, otherwise a new attribute is created.

The new attribute is created using the given parameters.

This method allows the user to make a contract with the library, that an object with certain properties exists after the method has terminated.

If the attribute already exists and its datatype differs from its requested value and an exception is thrown, since the contract can't be fulfilled.

Parameters
namename of the requested attribute
datatypevalue type of the new attribute
Exceptions
broken_contract_exceptionis thrown, if the contract can't be fulfilled.
Returns
the requested attribute, if it is already existing, or a new attribute otherwise
template<typename Parent>
template<typename T >
attribute echelon::attribute_repository< Parent >::require ( const std::string &  name)
inline

Returns the requested attribute, if it already exists, otherwise the attribute is created.

The new attribute is created using the given parameters.

This method allows the user to make a contract with the library, that an object with certain properties exists after the method has terminated.

If the attribute already exists and its datatype differs from its requested value and an exception is thrown, since the contract can't be fulfilled.

Parameters
namename of the requested attribute
Template Parameters
TC++ type, which should be used to determine the attribute's value type
Exceptions
broken_contract_exceptionis thrown, if the contract can't be fulfilled.
Returns
the requested attribute, if it is already existing, or a new attribute otherwise
template<typename Parent>
template<typename T >
attribute echelon::attribute_repository< Parent >::require ( const std::string &  name,
const T &  value 
)
inline

Returns the requested attribute, if it already exists, otherwise a new attribute is created.

The new attribute is created using the given parameters and is initialized with the given value.

This method allows the user to make a contract with the library, that an object with certain properties exists after the method has terminated.

If the attribute already exists and its datatype differs from its requested value and an exception is thrown, since the contract can't be fulfilled.

Parameters
namename of the requested attribute
valuevalue, which should be used to intialize the attribute
Template Parameters
TC++ type, which should be used to determine the attribute's value type
Exceptions
broken_contract_exceptionis thrown, if the contract can't be fulfilled.
Returns
the requested attribute, if it is already existing, or a new attribute otherwise

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