40 result->addParameter(par->clone());
61 if (par->getName() == newPar->
getName())
65 +
"' is already registered");
85 if (par->getName() == name)
102 std::vector<RealParameter*> result;
106 result.push_back(par);
119 "ParameterPool::getUniqueMatch: there is no match for '" + pattern +
"'");
120 if (matches.size() != 1)
122 +
"' is not unique");
132 par->setValue(value);
133 }
catch (
const std::runtime_error& e) {
137 std::ostringstream message;
138 message <<
"ParameterPool::getParameter() -> Warning. No parameter with name '" + name
140 <<
"Available parameters:" << *
this;
152 par->setValue(value);
154 }
catch (
const std::runtime_error& e) {
169 + pattern +
"' is not unique");
174 std::vector<std::string> result;
176 result.push_back(par->getName());
203 ostr <<
"'" << par->getName() <<
"'"
204 <<
":" << par->value() <<
"\n";
210 std::ostringstream ostr;
211 ostr <<
"ParameterPool::find_matched_parameters_error() -> Error! ";
212 ostr <<
"No parameters matching pattern '" << pattern
213 <<
"' have been found. Existing keys are:" << std::endl;
215 ostr <<
"'" << par->getName() <<
"'\n";
221 std::string message)
const
223 std::ostringstream ostr;
224 ostr <<
"ParameterPool::set_value_error() -> Attempt to set value " << value;
225 ostr <<
" for parameter '" << parname <<
"' failed.";
226 ostr <<
" Parameter limits: '" <<
parameter(parname)->
limits() <<
"'.\n";
227 ostr <<
"Original exception message: " << message << std::endl;
234 throw std::runtime_error(
"ParameterPool::check_index() -> Error. Index out of bounds");
Defines the macro ASSERT.
Defines many exception classes in namespace Exceptionss.
Defines class ParameterPool.
Defines class RealParameter.
Defines a few helper functions.
const std::string & getName() const
Container with parameters for IParameterized object.
std::vector< RealParameter * > m_params
virtual void print(std::ostream &ostr) const
RealParameter * parameter(const std::string &name)
Returns parameter with given name.
void report_set_value_error(const std::string &parname, double value, std::string message={}) const
Reports error while setting parname to given value.
void report_find_matched_parameters_error(const std::string &pattern) const
reports error while finding parameters matching given name.
RealParameter & addParameter(RealParameter *newPar)
Adds parameter to the pool, and returns reference to the input pointer.
void setUniqueMatchValue(const std::string &pattern, double value)
Sets value of the one parameter that matches pattern ('*' allowed), or throws.
void copyToExternalPool(const std::string &prefix, ParameterPool *other_pool) const
Copies parameters of given pool to other pool, prepeding prefix to the parameter names.
void clear()
Clears the parameter map.
std::vector< std::string > parameterNames() const
ParameterPool * clone() const
Returns a literal clone.
int setMatchedParametersValue(const std::string &wildcards, double value)
Sets value of the nonzero parameters that match pattern ('*' allowed), or throws.
const RealParameter * operator[](size_t index) const
ParameterPool()
Constructs an empty parameter pool.
void setParameterValue(const std::string &name, double value)
Sets parameter value.
void removeParameter(const std::string &name)
Removes parameter with given name from the pool.
std::vector< RealParameter * > getMatchedParameters(const std::string &pattern) const
Returns nonempty vector of parameters that match the pattern ('*' allowed), or throws.
size_t check_index(size_t index) const
RealParameter * getUniqueMatch(const std::string &pattern) const
Returns the one parameter that matches the pattern (wildcards '*' allowed), or throws.
Wraps a parameter of type double.
RealLimits limits() const
RealParameter * clone(const std::string &new_name="") const
bool matchesPattern(const std::string &text, const std::string &wildcardPattern)
Returns true if text matches pattern with wildcards '*' and '?'.