39 result->addParameter(par->clone());
60 if (par->getName() == newPar->
getName())
61 throw std::runtime_error(
"ParameterPool::addParameter() -> Error. "
63 + newPar->
getName() +
"' is already registered");
83 if (par->getName() ==
name)
100 std::vector<RealParameter*> result;
104 result.push_back(par);
116 throw std::runtime_error(
"ParameterPool::getUniqueMatch: there is no match for '" + pattern
118 if (matches.size() != 1)
119 throw std::runtime_error(
"ParameterPool::getUniqueMatch: pattern '" + pattern
120 +
"' is not unique");
130 par->setValue(value);
131 }
catch (
const std::runtime_error& e) {
135 std::ostringstream message;
136 message <<
"ParameterPool::getParameter() -> Warning. No parameter with name '" +
name
138 <<
"Available parameters:" << *
this;
139 throw std::runtime_error(message.str());
150 par->setValue(value);
152 }
catch (
const std::runtime_error& e) {
166 throw std::runtime_error(
"ParameterPool::setUniqueMatchValue: pattern '" + pattern
167 +
"' is not unique");
172 std::vector<std::string> result;
174 result.push_back(par->getName());
201 ostr <<
"'" << par->getName() <<
"'"
202 <<
":" << par->value() <<
"\n";
208 std::ostringstream ostr;
209 ostr <<
"ParameterPool::find_matched_parameters_error() -> Error! ";
210 ostr <<
"No parameters matching pattern '" << pattern
211 <<
"' have been found. Existing keys are:" << std::endl;
213 ostr <<
"'" << par->getName() <<
"'\n";
214 throw std::runtime_error(ostr.str());
219 std::string message)
const
221 std::ostringstream ostr;
222 ostr <<
"ParameterPool::set_value_error() -> Attempt to set value " << value;
223 ostr <<
" for parameter '" << parname <<
"' failed.";
224 ostr <<
" Parameter limits: '" <<
parameter(parname)->
limits() <<
"'.\n";
225 ostr <<
"Original exception message: " << message << std::endl;
226 throw std::runtime_error(ostr.str());
232 throw std::runtime_error(
"ParameterPool::check_index() -> Error. Index out of bounds");
Defines the macro ASSERT.
Defines a few helper functions.
Defines class ParameterPool.
Defines class RealParameter.
const std::string & getName() const
Container with parameters for IParametricComponent 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.
RealParameter * operator[](size_t index)
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
MVVM_MODEL_EXPORT bool remove(const std::string &path)
Removes file or empty directory.
QString const & name(EShape k)
bool matchesPattern(const std::string &text, const std::string &wildcardPattern)
Returns true if text matches pattern with wildcards '*' and '?'.