|
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. | |
| using | LogfileParameters = std::map< std::pair< size_t, std::string >, std::shared_ptr< const XMLInstrumentParameter > > |
| Parameters whose values are taken from the sample logs when ExperimentInfo::populateInstrumentParameters() runs, as declared in the instrument definition and parameter files. | |
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. | |
| void | addLogfileParameter (size_t const componentIndex, std::string const &cacheKey, std::shared_ptr< const XMLInstrumentParameter > const ¶meter) |
| Add a logfile parameter, replacing any existing one with the same cache key on the same component. | |
| 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. | |
| LogfileParameters const & | logfileParameters () const |
| All logfile parameters, in ascending component-index order. | |
| 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 | |
| LogfileParameters | m_logfileParameters |
| 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 35 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 46 of file ParameterInfo.h.
| using Mantid::Geometry::ParameterInfo::LogfileParameters = std::map<std::pair<size_t, std::string>, std::shared_ptr<const XMLInstrumentParameter> > |
Parameters whose values are taken from the sample logs when ExperimentInfo::populateInstrumentParameters() runs, as declared in the instrument definition and parameter files.
Keyed by (component index, cache key), where the cache key is the parameter name qualified by its fitting function if it has one ("IkedaCarpenterPV:Alpha0"), so that two functions on one component do not collide.
Definition at line 54 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(), Mantid::Geometry::ComponentInfo::addTypedParameter(), and Mantid::Geometry::Instrument::legacyParameters().
| 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().
| void Mantid::Geometry::ParameterInfo::addLogfileParameter | ( | size_t const | componentIndex, |
| std::string const & | cacheKey, | ||
| std::shared_ptr< const XMLInstrumentParameter > const & | parameter | ||
| ) |
Add a logfile parameter, replacing any existing one with the same cache key on the same component.
Definition at line 256 of file ParameterInfo.cpp.
References m_logfileParameters.
Referenced by Mantid::Geometry::ComponentInfo::addLogfileParameter().
|
inline |
Iteration over (component index, parameters) pairs, in ascending component-index order.
The ordering is relied upon to make serialization deterministic.
Definition at line 130 of file ParameterInfo.h.
| void Mantid::Geometry::ParameterInfo::clear | ( | ) |
Remove all parameters.
The logfile parameters are kept: they say where values come from rather than being values themselves, and populateInstrumentParameters() may need them again.
Definition at line 247 of file ParameterInfo.cpp.
References m_store.
| 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 131 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(), getRecursive(), and Mantid::Geometry::Instrument::legacyParameters().
| 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 263 of file ParameterInfo.cpp.
References m_logfileParameters, m_store, and name.
| 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.
Referenced by Mantid::Geometry::Instrument::legacyParameters().
| ParameterInfo::LogfileParameters const & Mantid::Geometry::ParameterInfo::logfileParameters | ( | ) | const |
All logfile parameters, in ascending component-index order.
Definition at line 261 of file ParameterInfo.cpp.
References m_logfileParameters.
| 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.
Referenced by Mantid::Geometry::Instrument::legacyParameters().
|
private |
Definition at line 135 of file ParameterInfo.h.
Referenced by addLogfileParameter(), getMemorySize(), and logfileParameters().
|
private |
Definition at line 134 of file ParameterInfo.h.
Referenced by add(), addFittingParameter(), clear(), clearParametersByName(), clearParametersByName(), empty(), get(), getByType(), getMemorySize(), getRecursiveFittingParameter(), insert(), names(), parameters(), and size().