Public Types | Public Member Functions

Traits< ElementType, ConverterType, MapType > Class Template Reference

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

#include <keyvalue/key/Traits.h>

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

List of all members.

Public Types

enum  { isBasicOrEnum = util::IsBasicOrEnum<ElementType>::value }
typedef Traits< ElementType,
ConverterType, MapType > 
typedef ConverterType
< typename MapType
< ElementType >::OutputType_ > 
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.
string getName () const
 Gets 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 instantiations of this template class.

Keys have more than just a 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 a value::Single, value::Vector or value::Matrix. The content 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 double. On the same way, a key named "Lengths" might be associated to an input of type value::Vector which should be converted to 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 values of type 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 which 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.

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 instantiation of Traits;
ConverterType_ : Complete instantiation of ConverterType;
InputType_ : Converter's input type;
OutputType_ : Converter's output type.

Constructor & Destructor Documentation

Traits ( const string &  name  ) 

Initializes Key's name.

name : The Key's name.

Member Function Documentation

string getName (  )  const

Gets Key's name.

The Key's name.
string getName (  )  const [inherited]

Gets name.

The name.
void setName ( const string &  name  )  [inherited]

Sets name.

name : The name.