Public Types | Public Member Functions | Private Types | Private Member Functions

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 
typedef boost::is_same
< OutputType, ptime >::type 
typedef boost::is_same
< OutputType, unsigned int >

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;

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().

variant : A value::Variant containing the input string to be mapped.
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.

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

Gets Key's name.

The Key's name.