42 #include "../Text/StringTokenizer.h"
54 parameters_(pl.size())
57 for (
size_t i = 0; i <
size(); i++)
71 for (
size_t i = 0; i < pl.
size(); i++)
91 for (
size_t i = 0; i <
size(); i++)
104 for (
size_t i = 0; i <
size(); i++)
107 if (p->getName() == name)
118 for (
size_t i = 0; i <
size(); i++)
131 for (
size_t i = 0; i <
size(); i++)
144 for (
size_t i = 0; i <
size(); i++)
147 if (p->getName() == name)
159 for (
size_t i = 0; i < names.size(); i++)
172 for (
const auto& name:names)
195 for (
auto iparam : parameters)
208 for (
auto iparam : parameters)
222 if (parameter <
size())
232 for (
size_t i = 0; i < params.
size(); i++)
247 vector<string> pNames(
size());
248 for (
size_t i = 0; i <
size(); i++)
259 vector<string> pNames;
260 for (
size_t i = 0; i <
size(); i++)
275 pos2 = name.find(g, pos1);
276 if (pos2 == string::npos)
281 pos1 = pos2 + g.length();
284 ((g.length() == 0) || (pos1 == name.length()) || (name.rfind(g) == name.length() - g.length())))
285 pNames.push_back(name);
296 throw ParameterException(
"ParameterList::addParameter. Parameter with name '" + param.
getName() +
"' already exists.", ¶m);
305 throw ParameterException(
"ParameterList::addParameter. Parameter with name '" + param->
getName() +
"' already exists.", param);
306 parameters_.push_back(shared_ptr<Parameter>(param));
334 for (
size_t i = 0; i < params.
size(); i++)
347 for (
size_t i = 0; i < params.
size(); i++)
357 for (
size_t i = 0; i < params.
size(); i++)
379 if ((*it)->hasConstraint() && !(*it)->getConstraint()->isCorrect(p->
getValue()))
396 for (vector<shared_ptr<Parameter> >::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
408 for (vector<shared_ptr<Parameter> >::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
424 for (vector<shared_ptr<Parameter> >::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
437 for (vector<shared_ptr<Parameter> >::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
442 if (p->
getValue() != (*it)->getValue())
454 for (vector<shared_ptr<Parameter> >::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
468 for (vector<shared_ptr<Parameter> >::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
473 if (p->
getValue() != (*it)->getValue())
477 if (updatedParameters)
478 updatedParameters->push_back(pos);
499 for (vector<shared_ptr<Parameter> >::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
509 for (
unsigned int i = 0; i <
size(); i++)
521 for (vector<shared_ptr<Parameter> >::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
536 if ((*it)->getName() == name)
548 for (
auto it = names.begin(); it != names.end(); ++it)
575 vector<size_t> tmp(indices);
576 sort(tmp.begin(), tmp.end());
577 for (vector<size_t>::reverse_iterator i = tmp.rbegin(); i != tmp.rend(); i++)
591 for (
size_t i = 0; i <
size(); i++)
602 (out <<
"Name:\tValue:\tConstraint:").endLine();
603 (out <<
"_________________________________________________").endLine();
604 for (
unsigned int i = 0; i <
size(); i++)
608 out << (
parameters_[i]->hasConstraint() ?
"\t" +
parameters_[i]->getConstraint()->getDescription() : string(
""));
Exception thrown when a value do not match a given constraint.
Index out of bounds exception class.
virtual OutputStream & endLine()=0
The parameter exception base class.
The parameter list object.
virtual bool hasParameter(const std::string &name) const
virtual const Parameter & getParameter(const std::string &name) const
Get the parameter with name name.
ParameterList()
Build a new ParameterList object.
virtual void addParameters(const ParameterList ¶ms)
Add new parameters at the end of the list.
virtual ParameterList getCommonParametersWith(const ParameterList ¶ms) const
Get the sublist containing all common parameter between this list and pl.
virtual std::vector< std::string > getMatchingParameterNames(const std::string &pattern) const
Get all parameter names matching with the given name. Up to now, only "*" jokers are available.
virtual void matchParameters(const ParameterList ¶ms)
Update the parameters from params.
virtual ParameterList shareSubList(const std::vector< std::string > &names) const
Share given parameters as a sublist.
virtual void setParameters(const ParameterList ¶ms)
Update the parameters from params.
virtual std::vector< std::string > getParameterNames() const
Get all parameter names in the list.
virtual void setParameterValue(const std::string &name, double value)
Set the value of parameter with name name to be equal to value.
virtual double getParameterValue(const std::string &name) const
Get the value of the parameter with name name.
virtual void addParameter(const Parameter ¶m)
Add a new parameter at the end of the list.
ParameterList * clone() const
Create a copy of this object and send a pointer to it.
virtual void shareParameter(const std::shared_ptr< Parameter > ¶m)
Share a parameter at the end of the list.
virtual void includeParameters(const ParameterList ¶ms)
Add parameters to the list. If the parameter already exists, only the value is updated,...
virtual void deleteParameter(const std::string &name)
Delete a parameter from the list.
virtual void setParametersValues(const ParameterList ¶ms)
Update the parameters from the ones in params that have matching names.
virtual void reset()
Reset the list: delete all parameters.
virtual bool matchParametersValues(const ParameterList ¶ms, std::vector< size_t > *updatedParameters=0)
Update the parameters from params.
virtual bool testParametersValues(const ParameterList ¶ms) const
Tests the parameters from params.
virtual void shareParameters(const ParameterList ¶ms)
Share parameters with a given list. They are added the end of this list.
ParameterList & operator=(const ParameterList &pl)
virtual void deleteParameters(const std::vector< std::string > &names, bool mustExist=true)
Delete several parameters from the list.
virtual void setAllParameters(const ParameterList ¶ms)
Set the parameters to be equals to params.
virtual const std::shared_ptr< Parameter > & getSharedParameter(size_t i) const
virtual void setParameter(size_t index, const Parameter ¶m)
Change given parameter.
virtual void printParameters(OutputStream &out) const
Print all parameters.
virtual size_t whichParameterHasName(const std::string &name) const
Get the position of a given parameter according to its name.
virtual ParameterList createSubList(const std::vector< std::string > &names) const
Get given parameters as a sublist.
virtual void setAllParametersValues(const ParameterList ¶ms)
Set the parameters to be equals to params.
std::vector< std::shared_ptr< Parameter > > parameters_
Exception thrown when a parameter is not found, for instance in a ParameterList.
This class is designed to facilitate the manipulation of parameters.
virtual void setValue(double value)
Set the value of this parameter.
virtual const std::shared_ptr< Constraint > getConstraint() const
Return the constraint associated to this parameter if there is one.
virtual double getValue() const
Get the value of this parameter.
Parameter * clone() const
Create a copy of this object and send a pointer to it.
virtual const std::string & getName() const
Get the name of this parameter.
virtual bool hasConstraint() const
Tells if this parameter has a constraint.
const std::string & nextToken()
Get the next available token. If no token is availbale, throw an Exception.
bool hasMoreToken() const
Tell if some tokens are still available.