PartialMap< OutputType > Class Template Reference

Partially maps names to constants. More...

#include "keyvalue/key/map/PartialMap.h"

List of all members.

Public Types

typedef OutputType OutputType_

Public Member Functions

OutputType map (const value::Variant &variant) const
 Performs the mapping.
virtual OutputType get (const string &name) const =0
 Performs the mapping from string to OutputType.

Private Types

typedef boost::is_same
< OutputType, double >::type 
IsDouble_
typedef boost::is_same
< OutputType, ptime >::type 
IsPtime_
typedef boost::is_same
< OutputType, unsigned int >
::type 
IsUInt_

Private Member Functions

virtual string getName () const =0
 Gets Key's name.
 BOOST_STATIC_ASSERT (IsDouble_::value||IsPtime_::value||IsUInt_::value)

Detailed Description

template<typename OutputType>
class keyvalue::key::PartialMap< OutputType >

Partially maps names to constants.

Use this map, when a special double, ptime or unsigned int value has a name.

For instance, when asked for the number of edges of a regular polygon, the answer must be an unsigned int greater than 2. For some special values (not all) there correspond a polygon name (e.g 'Triangle' for 3 or 'Square' for 4). There is no special name for a regular polygon with 1111 edges.

Traits derived classes which uses this map must implement a method to perform the mapping. This method has the following signature

Output get(const string& name) const;

Parameters:
OutputType : (template parameter) Output type.
Return values:
OutputType_ : Same as OutputType.

Member Function Documentation

OutputType map ( const value::Variant variant  )  const

Performs the mapping.

This method converts the input from value::Variant to string and calls get().

Parameters:
variant : A value::Variant containing the input string to be mapped.
Returns:
The mapping result.
virtual OutputType get ( const string &  name  )  const [pure virtual]

Performs the mapping from string to OutputType.

Must be implemented by real keys which use this map.

Parameters:
name : The string to be mapped.
Returns:
The mapping result.
virtual string getName (  )  const [private, pure virtual]

Gets Key's name.

Returns:
The Key's name.

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