BornAgain
1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Container with parameters for IParametricComponent object. More...
Public Member Functions | |
ParameterPool () | |
Constructs an empty parameter pool. More... | |
virtual | ~ParameterPool () |
RealParameter & | addParameter (RealParameter *newPar) |
Adds parameter to the pool, and returns reference to the input pointer. More... | |
void | clear () |
Clears the parameter map. More... | |
ParameterPool * | clone () const |
Returns a literal clone. More... | |
void | copyToExternalPool (const std::string &prefix, ParameterPool *other_pool) const |
Copies parameters of given pool to other pool, prepeding prefix to the parameter names. More... | |
bool | empty () const |
std::vector< RealParameter * > | getMatchedParameters (const std::string &pattern) const |
Returns nonempty vector of parameters that match the pattern ('*' allowed), or throws. More... | |
RealParameter * | getUniqueMatch (const std::string &pattern) const |
Returns the one parameter that matches the pattern (wildcards '*' allowed), or throws. More... | |
RealParameter * | operator[] (size_t index) |
const RealParameter * | operator[] (size_t index) const |
RealParameter * | parameter (const std::string &name) |
Returns parameter with given name. More... | |
const RealParameter * | parameter (const std::string &name) const |
Returns parameter with given name. More... | |
std::vector< std::string > | parameterNames () const |
const std::vector< RealParameter * > | parameters () const |
Returns full vector of parameters. More... | |
void | removeParameter (const std::string &name) |
Removes parameter with given name from the pool. More... | |
int | setMatchedParametersValue (const std::string &wildcards, double value) |
Sets value of the nonzero parameters that match pattern ('*' allowed), or throws. More... | |
void | setParameterValue (const std::string &name, double value) |
Sets parameter value. More... | |
void | setUniqueMatchValue (const std::string &pattern, double value) |
Sets value of the one parameter that matches pattern ('*' allowed), or throws. More... | |
size_t | size () const |
Returns number of parameters in the pool. More... | |
virtual void | transferToCPP () |
Used for Python overriding of clone (see swig/tweaks.py) More... | |
Private Member Functions | |
size_t | check_index (size_t index) const |
virtual void | print (std::ostream &ostr) const |
void | report_find_matched_parameters_error (const std::string &pattern) const |
reports error while finding parameters matching given name. More... | |
void | report_set_value_error (const std::string &parname, double value, std::string message={}) const |
Reports error while setting parname to given value. More... | |
Private Attributes | |
std::vector< RealParameter * > | m_params |
Friends | |
std::ostream & | operator<< (std::ostream &ostr, const ParameterPool &obj) |
Container with parameters for IParametricComponent object.
Definition at line 29 of file ParameterPool.h.
|
default |
Constructs an empty parameter pool.
Referenced by clone().
|
virtual |
Definition at line 28 of file ParameterPool.cpp.
References clear().
RealParameter & ParameterPool::addParameter | ( | RealParameter * | newPar | ) |
Adds parameter to the pool, and returns reference to the input pointer.
Returning the input pointer allows us to concatenate function calls like pool->addParameter( new RealParameter(...) ).setLimits(-1,+1).setFixed().setUnit("nm")
Definition at line 57 of file ParameterPool.cpp.
References IParameter< T >::getName(), and m_params.
Referenced by copyToExternalPool().
|
private |
void ParameterPool::clear | ( | ) |
Clears the parameter map.
Definition at line 45 of file ParameterPool.cpp.
References m_params.
Referenced by INode::INode(), ~ParameterPool(), SampleBuilderNode::borrow_builder_parameters(), and SampleBuilderNode::reset().
|
virtual |
Returns a literal clone.
Implements ICloneable.
Definition at line 35 of file ParameterPool.cpp.
References ParameterPool(), and m_params.
void ParameterPool::copyToExternalPool | ( | const std::string & | prefix, |
ParameterPool * | other_pool | ||
) | const |
Copies parameters of given pool to other pool, prepeding prefix to the parameter names.
Definition at line 70 of file ParameterPool.cpp.
References addParameter(), RealParameter::clone(), and m_params.
|
inline |
Definition at line 42 of file ParameterPool.h.
References size().
Referenced by IParametricComponent::IParametricComponent().
std::vector< RealParameter * > ParameterPool::getMatchedParameters | ( | const std::string & | pattern | ) | const |
Returns nonempty vector of parameters that match the pattern ('*' allowed), or throws.
Definition at line 98 of file ParameterPool.cpp.
References m_params, StringUtils::matchesPattern(), and report_find_matched_parameters_error().
Referenced by getUniqueMatch(), and setMatchedParametersValue().
RealParameter * ParameterPool::getUniqueMatch | ( | const std::string & | pattern | ) | const |
Returns the one parameter that matches the pattern (wildcards '*' allowed), or throws.
Definition at line 112 of file ParameterPool.cpp.
References getMatchedParameters().
Referenced by ParticleDistribution::generateParticles(), and ParameterUtils::poolParameterUnits().
RealParameter * ParameterPool::operator[] | ( | size_t | index | ) |
Definition at line 193 of file ParameterPool.cpp.
const RealParameter * ParameterPool::operator[] | ( | size_t | index | ) | const |
Definition at line 188 of file ParameterPool.cpp.
References check_index(), and m_params.
RealParameter * ParameterPool::parameter | ( | const std::string & | name | ) |
Returns parameter with given name.
Definition at line 91 of file ParameterPool.cpp.
References RealSpace::Particles::name().
Referenced by removeParameter(), report_set_value_error(), and setParameterValue().
const RealParameter * ParameterPool::parameter | ( | const std::string & | name | ) | const |
Returns parameter with given name.
Definition at line 80 of file ParameterPool.cpp.
References m_params, and RealSpace::Particles::name().
std::vector< std::string > ParameterPool::parameterNames | ( | ) | const |
|
inline |
Returns full vector of parameters.
Definition at line 51 of file ParameterPool.h.
References m_params.
Referenced by pyfmt2::argumentList().
|
privatevirtual |
void ParameterPool::removeParameter | ( | const std::string & | name | ) |
Removes parameter with given name from the pool.
Definition at line 180 of file ParameterPool.cpp.
References m_params, RealSpace::Particles::name(), parameter(), and ModelView::Utils::remove().
|
private |
reports error while finding parameters matching given name.
Definition at line 206 of file ParameterPool.cpp.
References m_params.
Referenced by getMatchedParameters(), and setMatchedParametersValue().
|
private |
Reports error while setting parname to given value.
Definition at line 218 of file ParameterPool.cpp.
References RealParameter::limits(), and parameter().
Referenced by setMatchedParametersValue(), and setParameterValue().
int ParameterPool::setMatchedParametersValue | ( | const std::string & | wildcards, |
double | value | ||
) |
Sets value of the nonzero parameters that match pattern ('*' allowed), or throws.
Definition at line 145 of file ParameterPool.cpp.
References getMatchedParameters(), report_find_matched_parameters_error(), and report_set_value_error().
Referenced by DistributionHandler::setParameterToMeans(), IParametricComponent::setParameterValue(), DistributionHandler::setParameterValues(), and setUniqueMatchValue().
void ParameterPool::setParameterValue | ( | const std::string & | name, |
double | value | ||
) |
Sets parameter value.
Definition at line 126 of file ParameterPool.cpp.
References RealSpace::Particles::name(), parameter(), and report_set_value_error().
void ParameterPool::setUniqueMatchValue | ( | const std::string & | pattern, |
double | value | ||
) |
Sets value of the one parameter that matches pattern ('*' allowed), or throws.
Definition at line 163 of file ParameterPool.cpp.
References setMatchedParametersValue().
Referenced by ParticleDistribution::generateParticles().
|
inline |
Returns number of parameters in the pool.
Definition at line 41 of file ParameterPool.h.
References m_params.
Referenced by empty().
|
inlinevirtualinherited |
Used for Python overriding of clone (see swig/tweaks.py)
Definition at line 34 of file ICloneable.h.
|
friend |
Definition at line 63 of file ParameterPool.h.
|
private |
Definition at line 83 of file ParameterPool.h.
Referenced by addParameter(), check_index(), clear(), clone(), copyToExternalPool(), getMatchedParameters(), operator[](), parameter(), parameterNames(), parameters(), print(), removeParameter(), report_find_matched_parameters_error(), and size().