Partially maps names to constants. More...
#include "keyvalue/key/map/PartialMap.h"
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) |
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 class
es 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. |
OutputType_ | : Same as OutputType. |
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. |
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. |