Maps names to constants. More...
#include "keyvalue/key/map/FlagMap.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 Output. | |
Private Member Functions | |
| virtual string | getName () const =0 |
| Gets Key's name. | |
Maps names to constants.
A string is mapped to a flag (normally an enum). Consider, for instance, key::Device which specifies a logger::Logger type to be build. Users provide a string either "Console", "File" or "Standard". However, inside keyvalue, devices are designated by key::Device::Flag. An error occurs when a string cannot be mapped to a valid output.
Traits derived classes which uses this map must implement a method to perform the mapping. This method has the following signature
OutputType get(const string& name) const;
| OutputType | : (template parameter) Output type. |
| OutputType_ | : Same as OutputType. |
| OutputType map | ( | const value::Variant & | variant | ) | const [inline] |
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 Output.
Must be implemented by real keys which use this map.
| name | : The string to be mapped. |
Implemented in Device, and VectorOutput.
| virtual string getName | ( | ) | const [private, pure virtual] |
Gets Key's name.
Implemented in Traits< VectorOutputBase::Flag, StdSingle, FlagMap >, and Traits< logger::Logger::Device, StdSingle, FlagMap >.
1.6.1