Traits< ElementType, ConverterType, MapType > Class Template Reference

Real keys must derive from adequate instance of this template class. More...

#include "keyvalue/key/Traits.h"

Inheritance diagram for Traits< ElementType, ConverterType, MapType >:
Inheritance graph
[legend]

List of all members.

Public Types

enum  { isBasicOrEnum_ = util::IsBasicOrEnum<ElementType>::value_ }
typedef Traits< ElementType,
ConverterType, MapType > 
Traits_
typedef ConverterType
< typename MapType
< ElementType >::OutputType_ > 
ConverterType_
typedef ConverterType_::InputType_ InputType_
typedef ConverterType_::OutputType_ OutputType_

Public Member Functions

 Traits (const string &name)
 Initializes Key's name.
string getName () const
 Gets Key's name.
void setName (const string &name)
 Sets name.

Detailed Description

template<typename ElementType, template< typename > class ConverterType = StdSingle, template< typename > class MapType = Default>
class keyvalue::key::Traits< ElementType, ConverterType, MapType >

Real keys must derive from adequate instance of this template class.

Keys have more than a just name: Each of them is associated to a value which need to be processed. The processing depends on many types which are passed as template parameters stored inside this class.

The input value stored in the DataSet, can be either value::Single, value::Vector or value::Matrix. It must be converted to another kind of container suitable for the core library. For instance, a key named "Length" might be associated to a value::Single type of input which must be converted to a double. On the same way, a key named "Lengths" might be associated to an input of type value::Vector which should be converted to a std::vector<double>.

To allow more flexibility, conversions are responsibility of converter classes. Traits takes a converter ConverterType as a parameter. KeyValue library provides three standard implementations: StdSingle, StdVector and StdMatrix.

Without get into details, notice that ConverterType is a template depending on a type T. Essentially, StdSingle<T> converts from value::Single to T; StdVector<T> converts from value::Vector to std::vector<T>; StdMatrix<T> converts from value::Matrix to std::vector<std::vector<T>>. Bridge developers might implement converters whose output is more suitable for the core library (e.g. a converter from value::Matrix to boost::matrix<T>). (For more details, in particular, the requirements on converters, see StdSingle, StdVector and StdMatrix documentation.)

In some cases, the value contains strings (names) which must be mapped to corresponding instances of ElementType. For instance, the value associated to the key 'Logger' is supposed to be a logger::Logger. The user refers to the correct logger::Logger object through its name (e.g. 'GlobalLogger'). In this case, there must be a map that, provided the name, retrieves a pointer to the corresponding object. Indeed, this mapping is performed with Repository's help. Other kinds of maps are available.

Traits takes a map, MapType, and it implies constraints on Traits' derived classes. For more details see the relevant map documentation.

If MapType is not specified, then Default will be selected.

Finally, values associated to some keys are expected to fulfill certain criteria (e.g. a price cannot be negative.) Therefore, some sanity checks on the value might be needed. Those checks are performed by Checker which is a template class that Traits derives from.

Parameters:
ElementType : (template parameter) Type of elements in converter's output;
ConverterType : (template template parameter) Type of container converter.
MapType : (template parameter) Type of map. (See description above.)
Return values:
Traits_ : Complete instance of Traits;
ConverterType_ : Complete instance of ConverterType;
InputType_ : Converter's input type;
OutputType_ : Converter's output type.

Constructor & Destructor Documentation

Traits ( const string &  name  )  [inline]

Initializes Key's name.

Parameters:
name : The Key's name.

Member Function Documentation

string getName (  )  const [inline]

Gets Key's name.

Returns:
The Key's name.

Reimplemented from Key.

void setName ( const string &  name  )  [inherited]

Sets name.

Parameters:
name : The name.

Generated on Sat Mar 20 15:08:31 2010 for KeyValue by  doxygen 1.6.1