5 #include "../Text/StringTokenizer.h" 17 parameters_(pl.size())
20 for (
size_t i = 0; i <
size(); ++i)
34 for (
size_t i = 0; i < pl.
size(); ++i)
54 for (
size_t i = 0; i <
size(); i++)
67 for (
size_t i = 0; i <
size(); i++)
70 if (p->getName() == name)
81 for (
size_t i = 0; i <
size(); i++)
94 for (
size_t i = 0; i <
size(); i++)
107 for (
size_t i = 0; i <
size(); i++)
110 if (p->getName() == name)
122 for (
size_t i = 0; i < names.size(); i++)
135 for (
const auto& name:names)
158 for (
auto iparam : parameters)
171 for (
auto iparam : parameters)
185 if (parameter <
size())
195 for (
size_t i = 0; i < params.
size(); i++)
210 vector<string> pNames(
size());
211 for (
size_t i = 0; i <
size(); i++)
222 vector<string> pNames;
223 for (
size_t i = 0; i <
size(); i++)
238 pos2 = name.find(g, pos1);
239 if (pos2 == string::npos)
244 pos1 = pos2 + g.length();
247 ((g.length() == 0) || (pos1 == name.length()) || (name.rfind(g) == name.length() - g.length())))
248 pNames.push_back(name);
259 throw ParameterException(
"ParameterList::addParameter. Parameter with name '" + param.
getName() +
"' already exists.", ¶m);
268 throw ParameterException(
"ParameterList::addParameter. Parameter with name '" + param->
getName() +
"' already exists.", param);
269 parameters_.push_back(shared_ptr<Parameter>(param));
297 for (
size_t i = 0; i < params.
size(); i++)
310 for (
size_t i = 0; i < params.
size(); i++)
320 for (
size_t i = 0; i < params.
size(); i++)
342 if ((*it)->hasConstraint() && !(*it)->getConstraint()->isCorrect(p->
getValue()))
359 for (vector<shared_ptr<Parameter>>::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
371 for (vector<shared_ptr<Parameter>>::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
387 for (vector<shared_ptr<Parameter>>::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
400 for (vector<shared_ptr<Parameter>>::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
405 if (p->
getValue() != (*it)->getValue())
417 for (vector<shared_ptr<Parameter>>::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
431 for (vector<shared_ptr<Parameter>>::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
436 if (p->
getValue() != (*it)->getValue())
440 if (updatedParameters)
441 updatedParameters->push_back(pos);
462 for (vector<shared_ptr<Parameter>>::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
472 for (
unsigned int i = 0; i <
size(); i++)
484 for (vector<shared_ptr<Parameter>>::const_iterator it = params.
parameters_.begin(); it < params.
parameters_.end(); it++)
499 if ((*it)->getName() == name)
511 for (
auto it = names.begin(); it != names.end(); ++it)
538 vector<size_t> tmp(indices);
539 sort(tmp.begin(), tmp.end());
540 for (vector<size_t>::reverse_iterator i = tmp.rbegin(); i != tmp.rend(); i++)
554 for (
size_t i = 0; i <
size(); ++i)
565 (out <<
"Name:\tValue:\tConstraint:").endLine();
566 (out <<
"_________________________________________________").endLine();
567 for (
unsigned int i = 0; i <
size(); ++i)
571 out << (
parameters_[i]->hasConstraint() ?
"\t" +
parameters_[i]->getConstraint()->getDescription() : string(
""));
Exception thrown when a parameter is not found, for instance in a ParameterList.
virtual const Parameter & parameter(const std::string &name) const
Get the parameter with name name.
Parameter * clone() const
Create a copy of this object and send a pointer to it.
virtual void includeParameters(const ParameterList ¶ms)
Add parameters to the list. If the parameter already exists, only the value is updated, otherwise the new parameter is added at the end of the list.
virtual bool testParametersValues(const ParameterList ¶ms) const
Tests the parameters from params.
virtual void reset()
Reset the list: delete all parameters.
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 ParameterList createSubList(const std::vector< std::string > &names) const
Get given parameters as a sublist.
virtual double getParameterValue(const std::string &name) const
Get the value of the parameter with name name.
const std::string & nextToken()
Get the next available token. If no token is availbale, throw an Exception.
virtual bool matchParametersValues(const ParameterList ¶ms, std::vector< size_t > *updatedParameters=0)
Update the parameters from params.
bool hasMoreToken() const
Tell if some tokens are still available.
virtual void setAllParameters(const ParameterList ¶ms)
Set the parameters to be equals to params.
virtual void deleteParameters(const std::vector< std::string > &names, bool mustExist=true)
Delete several parameters from the list.
ParameterList & operator=(const ParameterList &pl)
ParameterList()
Build a new ParameterList object.
virtual void shareParameter(const std::shared_ptr< Parameter > ¶m)
Share a parameter at the end of the list.
This class is designed to facilitate the manipulation of parameters.
virtual void setAllParametersValues(const ParameterList ¶ms)
Set the parameters to be equals to params.
virtual void deleteParameter(const std::string &name)
Delete a parameter from 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 ParameterList getCommonParametersWith(const ParameterList ¶ms) const
Get the sublist containing all common parameter between this list and pl.
The parameter list object.
virtual void addParameters(const ParameterList ¶ms)
Add new parameters at the end of the list.
virtual bool hasConstraint() const
Tells if this parameter has a constraint.
virtual std::shared_ptr< const ConstraintInterface > getConstraint() const
Return the constraint associated to this parameter if there is one.
virtual void setValue(double value)
Set the value of this parameter.
virtual std::vector< std::string > getParameterNames() const
Get all parameter names in the list.
ParameterList * clone() const
Create a copy of this object and send a pointer to it.
virtual bool hasParameter(const std::string &name) const
virtual void shareParameters(const ParameterList ¶ms)
Share parameters with a given list. They are added the end of this list.
virtual size_t whichParameterHasName(const std::string &name) const
Get the position of a given parameter according to its name.
virtual const std::string & getName() const
Get the name of this parameter.
virtual OutputStream & endLine()=0
virtual void setParameter(size_t index, const Parameter ¶m)
Change given parameter.
virtual void setParameters(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 addParameter(const Parameter ¶m)
Add a new parameter at the end of the list.
virtual void matchParameters(const ParameterList ¶ms)
Update the parameters from params.
virtual double getValue() const
Get the value of this parameter.
virtual void printParameters(OutputStream &out) const
Print all parameters.
Exception thrown when a value do not match a given constraint.
Index out of bounds exception class.
std::vector< std::shared_ptr< Parameter > > parameters_
The parameter exception base class.
virtual const std::shared_ptr< Parameter > & getParameter(size_t i) const
virtual void setParametersValues(const ParameterList ¶ms)
Update the parameters from the ones in params that have matching names.