50 independentParameters_(),
51 aliasListenersRegister_()
80 AbstractParametrizable::operator=(ap);
130 throw Exception(
"AbstractParameterAliasable::aliasParameters. Parameter " + p2 +
" does not exist in independent parameters. Perhaps it is already aliased to a parameter and can't be aliased twice.");
132 string id =
"__alias_" + p2 +
"_to_" + p1;
133 string idCheck =
"__alias_" + p1 +
"_to_" + p2;
136 throw Exception(
"AbstractParameterAliasable::aliasParameters. Trying to alias parameter " + p2 +
" to " + p1 +
", but parameter " + p1 +
" is already aliased to parameter " + p2 +
".");
153 ApplicationTools::displayWarning(
"Aliasing parameter " + p2 +
" to " + p1 +
" with different constraints. They get the intersection of both constraints : " + nc->getDescription());
178 for (
size_t i = 0; i < pl.
size(); i++)
180 if (unparsedParams.find(pl[i].getName()) == unparsedParams.end())
184 size_t unp_s = unparsedParams.size();
187 auto it = unparsedParams.begin();
188 while (it != unparsedParams.end())
201 unique_ptr<Parameter> p2(pp->
clone());
202 p2->setName(it->first);
208 it = unparsedParams.erase(it);
211 if (unparsedParams.size() == unp_s)
212 throw Exception(
"Error, there is a cycle in aliasing starting with " + unparsedParams.begin()->first);
214 unp_s = unparsedParams.size();
228 string id =
"__alias_" + p2 +
"_to_" + p1;
231 throw Exception(
"AbstractParameterAliasable::unaliasParameters. Parameter " + p2 +
" is not aliased to parameter " + p1 +
".");
249 currentName = it->second->getName();
251 it->second->rename(prefix + currentName.substr(
getNamespace().size()));
253 it->second->rename(prefix + currentName);
262 vector<string> aliases;
268 if (it->second->getFrom() == name)
270 string alias = it->second->getAlias();
271 aliases.push_back(alias);
274 vector<string> chainAliases =
getAlias(alias);
285 map<string, string> aliases;
291 string name = it->second->getFrom();
293 vector<string> alias =
getAlias(name);
295 for (
size_t i = 0; i < alias.size(); i++)
297 aliases[alias[i]] = name;
352 if (it->second->getName() == name)
354 from = it->second->getFrom();
A partial implementation of the Parametrizable interface.
virtual std::vector< std::string > getAlias(const std::string &name) const
virtual ~AbstractParameterAliasable()
void unaliasParameters(const std::string &p1, const std::string &p2)
Detach two parameters previously set as 'aliased'.
std::string getFrom(const std::string &name) const
AbstractParameterAliasable & operator=(const AbstractParameterAliasable &ap)
virtual std::map< std::string, std::string > getAliases() const
AbstractParameterAliasable(const std::string &prefix)
void aliasParameters(const std::string &p1, const std::string &p2)
alias the parameters.
ParameterList getAliasedParameters(const ParameterList &pl) const
Return the list of the names of the parameters that are aliased (directly or not) to one of the param...
void setNamespace(const std::string &prefix)
Set the namespace for the parameter names.
ParameterList getFromParameters(const ParameterList &pl) const
Return the list of the names of the parameters from which the parameters of the list are aliased (dir...
ParameterList independentParameters_
std::map< std::string, AliasParameterListener * > aliasListenersRegister_
A partial implementation of the Parametrizable interface.
ParameterList & getParameters_()
Get all parameters available.
const ParameterList & getParameters() const
Get all parameters available.
void setNamespace(const std::string &prefix)
Set the namespace for the parameter names.
const std::shared_ptr< Parameter > & getSharedParameter(const std::string &name) const
bool hasParameter(const std::string &name) const
Tell if there is a parameter with specified name.
size_t getNumberOfParameters() const
Get the number of parameters.
std::string getNamespace() const
const Parameter & getParameter(const std::string &name) const
Get the parameter with specified name.
bool matchParametersValues(const ParameterList ¶meters)
Update the parameters from parameters.
std::string getParameterNameWithoutNamespace(const std::string &name) const
Resolves a parameter name according to the current namespace.
Parameter & getParameter_(const std::string &name)
Inner listener class used by AbstractParameterAliasable.
AliasParameterListener * clone() const
Create a copy of this object and send a pointer to it.
void setParameterList(ParameterList *pl)
virtual Clonable * clone() const =0
Create a copy of this object and send a pointer to it.
Exception base class. Overload exception constructor (to control the exceptions mechanism)....
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.
virtual void addParameter(const Parameter ¶m)
Add a new parameter at the end of the list.
virtual void shareParameter(const std::shared_ptr< Parameter > ¶m)
Share a parameter at the end of the list.
virtual void deleteParameter(const std::string &name)
Delete a parameter from the list.
virtual void shareParameters(const ParameterList ¶ms)
Share parameters with a given list. They are added the end of this list.
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 removeParameterListener(const std::string &listenerId)
Remove all listeners with a given id from 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 void setConstraint(std::shared_ptr< Constraint > constraint)
Set a constraint to this parameter.
virtual void addParameterListener(ParameterListener *listener, bool attachListener=true)
Add a new listener to this parameter.
virtual bool hasConstraint() const
Tells if this parameter has a constraint.
bool startsWith(const std::string &s, const std::string &pattern)
Tell is a string begins with a certain motif.
std::string toString(T t)
General template method to convert to a string.