36 #ifndef __POINTMATCHER_PARAMETRIZABLE_H 37 #define __POINTMATCHER_PARAMETRIZABLE_H 44 #include <boost/lexical_cast.hpp> 46 #define BOOST_ASSIGN_MAX_PARAMS 6 47 #include <boost/assign/list_inserter.hpp> 53 template<
typename Target>
57 return std::numeric_limits<Target>::infinity();
58 else if (arg ==
"-inf")
59 return -std::numeric_limits<Target>::infinity();
60 else if (arg ==
"nan")
61 return std::numeric_limits<Target>::quiet_NaN();
67 template<
typename Target>
70 return lexical_cast_scalar_to_string<Target>(
std::string(arg));
75 template<
typename Target,
typename Source>
179 #endif // __POINTMATCHER_PARAMETRIZABLE_H InvalidParameter(const std::string &reason)
Construct an invalid-parameter exception.
virtual ~Parametrizable()
Virtual destructor, do nothing.
std::string toParam(const S &value)
Return the a string value using lexical_cast.
ParametersUsed parametersUsed
parameters whose value has actually been read
Parametrizable()
Construct a documentation of parameters from a description in the source.
std::set< std::string > ParametersUsed
Parameters whose value has been read.
Target lexical_cast_scalar_to_string(const std::string &arg)
A lexical casting function that is an improvements over boost::lexical_cast that can handle "inf"...
bool(* LexicalComparison)(std::string a, std::string b)
A function that returns whether a is smaller than b.
std::string minValue
if bounds are checked, minimum value
std::map< std::string, Parameter > Parameters
Parameters stored as a map of string->string.
LexicalComparison comp
pointer to comparison function
Functions and classes that are not dependant on scalar type are defined in this namespace.
std::string maxValue
if bounds are checked, maxmimu value
Parameters parameters
parameters with their values encoded in string
std::string Parameter
alias
The documentation of a parameter.
friend std::ostream & operator<<(std::ostream &o, const ParameterDoc &p)
Dump the documentation of this parameter to a stream.
Target lexical_cast(const Source &arg)
General case of lexical cast, use boost.
The superclass of classes that are constructed using generic parameters. This class provides the para...
An exception thrown when one tries to fetch the value of an unexisting parameter. ...
std::string getParamValueString(const std::string ¶mName)
Get the value of a parameter, as a string.
std::vector< ParameterDoc > ParametersDoc
The documentation of all parameters.
std::string defaultValue
default value
static bool Comp(std::string a, std::string b)
Return whether a < b, lexically casted to S.
const std::string className
name of the class
double lexical_cast(const std::string &arg)
Special case of lexical cast to float, use lexical_cast_scalar_to_string.
std::string doc
short documentation
const ParametersDoc parametersDoc
documentation of parameters
ParameterDoc(const std::string &name, const std::string &doc, const std::string &defaultValue, const std::string &minValue, const std::string &maxValue, LexicalComparison comp)
Construct a parameter documentation with bounds.