|
Mantid
|
ParameterInfo : the named parameters of an instrument, addressed by component index. More...
#include <ParameterInfo.h>
Public Types | |
| using | ComponentParameters = std::multimap< std::string, std::shared_ptr< Parameter >, Kernel::CaseInsensitiveStringComparator > |
| Parameters of a single component, ordered by name. | |
Public Member Functions | |
| void | add (size_t const componentIndex, std::shared_ptr< Parameter > const ¶meter) |
| Add a parameter, replacing any existing parameter of the same name on the same component. | |
| bool | addFittingParameter (size_t const componentIndex, std::shared_ptr< Parameter > const ¶meter, std::string const &fittingFunction) |
| Add a fitting parameter, deduplicating by (name, function) rather than by name alone so that two functions on one component may each declare a parameter of the same short name. | |
| auto | begin () const |
| Iteration over (component index, parameters) pairs, in ascending component-index order. | |
| void | clear () |
| Remove all parameters. | |
| void | clearParametersByName (size_t const componentIndex, std::string const &name) |
| Remove every parameter of this name from one component. | |
| void | clearParametersByName (std::string const &name) |
| Remove every parameter of this name from every component. | |
| bool | contains (size_t const componentIndex, std::string const &name, std::string const &type="") const |
| Does a parameter of this name (and optionally this type) exist on this component? | |
| bool | empty () const |
| auto | end () const |
| std::shared_ptr< Parameter > | get (size_t const componentIndex, std::string const &name, std::string const &type="") const |
| The named parameter on this component, or a null shared pointer if there is none. | |
| std::shared_ptr< Parameter > | getByType (size_t const componentIndex, std::string const &type) const |
| The first parameter of this type on this component, or a null shared pointer. | |
| size_t | getMemorySize () const |
| std::shared_ptr< Parameter > | getRecursive (ComponentInfo const &componentInfo, size_t const componentIndex, std::string const &name, std::string const &type="") const |
| As get(), but walking up the component hierarchy until a match is found. | |
| std::shared_ptr< Parameter > | getRecursiveByType (ComponentInfo const &componentInfo, size_t const componentIndex, std::string const &type) const |
| As getByType(), but walking up the component hierarchy until a match is found. | |
| std::shared_ptr< Parameter > | getRecursiveFittingParameter (ComponentInfo const &componentInfo, size_t const componentIndex, std::string const &name, std::string const &fittingFunction) const |
| Find a fitting parameter by (short name, function) walking up the component hierarchy. | |
| void | insert (size_t const componentIndex, std::shared_ptr< Parameter > const ¶meter) |
| Insert a parameter without add()'s add-or-replace deduplication. | |
| std::set< std::string > | names (size_t const componentIndex) const |
| The names of the parameters on this component. | |
| ComponentParameters const & | parameters (size_t const componentIndex) const |
| All parameters on one component, non-recursive, ordered by name. | |
| size_t | size () const |
| The total number of parameters across all components. | |
Private Attributes | |
| std::map< size_t, ComponentParameters > | m_store |
ParameterInfo : the named parameters of an instrument, addressed by component index.
This is the Instrument 2.0 replacement for ParameterMap's storage.
It uses the same index keys as ComponentInfo.
Recursive (parent-inheriting) lookups take a ComponentInfo reference and walk ComponentInfo::parent(), because the hierarchy is not stored here.
Definition at line 33 of file ParameterInfo.h.
| using Mantid::Geometry::ParameterInfo::ComponentParameters = std::multimap<std::string, std::shared_ptr<Parameter>, Kernel::CaseInsensitiveStringComparator> |
Parameters of a single component, ordered by name.
A multimap because two parameters on one component may share a short name: fitting parameters are deduplicated by (name, function), so e.g. IkedaCarpenterPV:Alpha0 and IkedaCarpenterMD:Alpha0 coexist.
The comparator is case-insensitive to match the legacy lookup semantics, which compare parameter names with strcasecmp throughout.
Definition at line 44 of file ParameterInfo.h.
| void Mantid::Geometry::ParameterInfo::add | ( | size_t const | componentIndex, |
| std::shared_ptr< Parameter > const & | parameter | ||
| ) |
Add a parameter, replacing any existing parameter of the same name on the same component.
Matches the legacy ParameterMap::add() add-or-replace behaviour.
Definition at line 43 of file ParameterInfo.cpp.
References m_store.
Referenced by Mantid::Geometry::ComponentInfo::addParameter(), and Mantid::Geometry::ComponentInfo::addTypedParameter().
| bool Mantid::Geometry::ParameterInfo::addFittingParameter | ( | size_t const | componentIndex, |
| std::shared_ptr< Parameter > const & | parameter, | ||
| std::string const & | fittingFunction | ||
| ) |
Add a fitting parameter, deduplicating by (name, function) rather than by name alone so that two functions on one component may each declare a parameter of the same short name.
Returns true if an existing parameter was replaced, false if new entry.
Definition at line 58 of file ParameterInfo.cpp.
References Mantid::Geometry::FitParameter::getFunction(), and m_store.
Referenced by Mantid::Geometry::ComponentInfo::addFittingParameter().
|
inline |
Iteration over (component index, parameters) pairs, in ascending component-index order.
The ordering is relied upon to make serialization deterministic.
Definition at line 113 of file ParameterInfo.h.
| void Mantid::Geometry::ParameterInfo::clear | ( | ) |
| void Mantid::Geometry::ParameterInfo::clearParametersByName | ( | size_t const | componentIndex, |
| std::string const & | name | ||
| ) |
Remove every parameter of this name from one component.
Definition at line 237 of file ParameterInfo.cpp.
| void Mantid::Geometry::ParameterInfo::clearParametersByName | ( | std::string const & | name | ) |
Remove every parameter of this name from every component.
Definition at line 225 of file ParameterInfo.cpp.
| bool Mantid::Geometry::ParameterInfo::contains | ( | size_t const | componentIndex, |
| std::string const & | name, | ||
| std::string const & | type = "" |
||
| ) | const |
Does a parameter of this name (and optionally this type) exist on this component?
Definition at line 91 of file ParameterInfo.cpp.
| bool Mantid::Geometry::ParameterInfo::empty | ( | ) | const |
Definition at line 249 of file ParameterInfo.cpp.
References m_store.
|
inline |
Definition at line 114 of file ParameterInfo.h.
| std::shared_ptr< Parameter > Mantid::Geometry::ParameterInfo::get | ( | size_t const | componentIndex, |
| std::string const & | name, | ||
| std::string const & | type = "" |
||
| ) | const |
The named parameter on this component, or a null shared pointer if there is none.
Definition at line 95 of file ParameterInfo.cpp.
Referenced by contains(), and getRecursive().
| std::shared_ptr< Parameter > Mantid::Geometry::ParameterInfo::getByType | ( | size_t const | componentIndex, |
| std::string const & | type | ||
| ) | const |
The first parameter of this type on this component, or a null shared pointer.
Definition at line 111 of file ParameterInfo.cpp.
Referenced by getRecursiveByType().
| size_t Mantid::Geometry::ParameterInfo::getMemorySize | ( | ) | const |
Definition at line 256 of file ParameterInfo.cpp.
| std::shared_ptr< Parameter > Mantid::Geometry::ParameterInfo::getRecursive | ( | ComponentInfo const & | componentInfo, |
| size_t const | componentIndex, | ||
| std::string const & | name, | ||
| std::string const & | type = "" |
||
| ) | const |
As get(), but walking up the component hierarchy until a match is found.
Definition at line 126 of file ParameterInfo.cpp.
References get(), Mantid::Geometry::ComponentInfo::hasParent(), index, name, and Mantid::Geometry::ComponentInfo::parent().
| std::shared_ptr< Parameter > Mantid::Geometry::ParameterInfo::getRecursiveByType | ( | ComponentInfo const & | componentInfo, |
| size_t const | componentIndex, | ||
| std::string const & | type | ||
| ) | const |
As getByType(), but walking up the component hierarchy until a match is found.
Definition at line 139 of file ParameterInfo.cpp.
References getByType(), Mantid::Geometry::ComponentInfo::hasParent(), index, and Mantid::Geometry::ComponentInfo::parent().
| std::shared_ptr< Parameter > Mantid::Geometry::ParameterInfo::getRecursiveFittingParameter | ( | ComponentInfo const & | componentInfo, |
| size_t const | componentIndex, | ||
| std::string const & | name, | ||
| std::string const & | fittingFunction | ||
| ) | const |
Find a fitting parameter by (short name, function) walking up the component hierarchy.
Examines every entry on each level.
Definition at line 153 of file ParameterInfo.cpp.
References Mantid::Geometry::FitParameter::getFunction(), Mantid::Geometry::ComponentInfo::hasParent(), index, m_store, name, and Mantid::Geometry::ComponentInfo::parent().
| void Mantid::Geometry::ParameterInfo::insert | ( | size_t const | componentIndex, |
| std::shared_ptr< Parameter > const & | parameter | ||
| ) |
Insert a parameter without add()'s add-or-replace deduplication.
For rekeying an existing ParameterMap, whose contents have already had the legacy deduplication rules applied: re-running them here would collapse the same-named fitting parameters that addFittingParameter() deliberately keeps distinct. Prefer add() elsewhere.
Definition at line 84 of file ParameterInfo.cpp.
References m_store.
| std::set< std::string > Mantid::Geometry::ParameterInfo::names | ( | size_t const | componentIndex | ) | const |
The names of the parameters on this component.
Names differing only in case collapse to one entry, consistent with add()'s case-insensitive deduplication.
Definition at line 184 of file ParameterInfo.cpp.
| ParameterInfo::ComponentParameters const & Mantid::Geometry::ParameterInfo::parameters | ( | size_t const | componentIndex | ) | const |
All parameters on one component, non-recursive, ordered by name.
Returns a reference to a static empty container when the component has no parameters.
Definition at line 196 of file ParameterInfo.cpp.
References m_store.
| size_t Mantid::Geometry::ParameterInfo::size | ( | ) | const |
The total number of parameters across all components.
Definition at line 251 of file ParameterInfo.cpp.
References m_store.
|
private |
Definition at line 117 of file ParameterInfo.h.
Referenced by add(), addFittingParameter(), clear(), clearParametersByName(), clearParametersByName(), empty(), get(), getByType(), getMemorySize(), getRecursiveFittingParameter(), insert(), names(), parameters(), and size().