Mantid
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
Mantid::Geometry::ParameterInfo Class Reference

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 &parameter)
 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 &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.
 
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 &parameter)
 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
 

Detailed Description

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.

Member Typedef Documentation

◆ ComponentParameters

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.

Member Function Documentation

◆ add()

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().

◆ addFittingParameter()

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().

◆ begin()

auto Mantid::Geometry::ParameterInfo::begin ( ) const
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.

◆ clear()

void Mantid::Geometry::ParameterInfo::clear ( )

Remove all parameters.

Definition at line 247 of file ParameterInfo.cpp.

References m_store.

◆ clearParametersByName() [1/2]

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.

References m_store, and name.

◆ clearParametersByName() [2/2]

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.

References m_store, and name.

◆ contains()

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.

References get(), and name.

◆ empty()

bool Mantid::Geometry::ParameterInfo::empty ( ) const

Definition at line 249 of file ParameterInfo.cpp.

References m_store.

◆ end()

auto Mantid::Geometry::ParameterInfo::end ( ) const
inline

Definition at line 114 of file ParameterInfo.h.

◆ get()

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.

References m_store, and name.

Referenced by contains(), and getRecursive().

◆ getByType()

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.

References m_store, and name.

Referenced by getRecursiveByType().

◆ getMemorySize()

size_t Mantid::Geometry::ParameterInfo::getMemorySize ( ) const

Definition at line 256 of file ParameterInfo.cpp.

References m_store, and name.

◆ getRecursive()

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().

◆ getRecursiveByType()

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().

◆ getRecursiveFittingParameter()

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().

◆ insert()

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.

◆ names()

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.

References m_store, and name.

◆ parameters()

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()

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.

Member Data Documentation

◆ m_store

std::map<size_t, ComponentParameters> Mantid::Geometry::ParameterInfo::m_store
private

The documentation for this class was generated from the following files: