37 #include <boost/format.hpp> 38 #include <boost/typeof/typeof.hpp> 71 for (BOOST_AUTO(it,p.begin()); it != p.end(); ++it)
72 o <<
"- " << *it << endl;
115 defaultValue(defaultValue),
125 defaultValue(defaultValue),
172 className(className),
178 const string& paramName(it->name);
179 Parameters::const_iterator paramIt(params.find(paramName));
180 if (paramIt != params.end())
182 const string& val(paramIt->second);
183 if (it->comp(val, it->minValue))
184 throw InvalidParameter((boost::format(
"Value %1% of parameter %2% in class %3% is smaller than minimum admissible value %4%") % val % paramName % className % it->minValue).str());
185 if (it->comp(it->maxValue, val))
186 throw InvalidParameter((boost::format(
"Value %1% of parameter %2% in class %3% is larger than maximum admissible value %4%") % val % paramName % className % it->maxValue).str());
201 Parameters::const_iterator paramIt(
parameters.find(paramName));
206 return paramIt->second;
friend std::ostream & operator<<(std::ostream &o, const Parametrizable &p)
Dump the documentation of this object to a stream.
bool FalseLexicalComparison(std::string, std::string)
Return always false.
InvalidParameter(const std::string &reason)
Construct an invalid-parameter exception.
virtual ~Parametrizable()
Virtual destructor, do nothing.
ParametersUsed parametersUsed
parameters whose value has actually been read
Parametrizable()
Construct a documentation of parameters from a description in the source.
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
The documentation of a parameter.
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
const std::string className
name of the class
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.