9#include "MantidGeometry/DllConfig.h"
19#include <unordered_map>
25template <
class KEYTYPE,
class VALUETYPE>
class Cache;
31class InstrumentMetadata;
47 using Entry = std::pair<ComponentID, std::shared_ptr<Parameter>>;
55 inline bool empty()
const {
return m_parameterInfo->empty(); }
57 inline int size()
const {
return static_cast<int>(m_parameterInfo->size()); }
59 size_t getMemorySize()
const;
61 static const std::string &pos();
62 static const std::string &posx();
63 static const std::string &posy();
64 static const std::string &posz();
65 static const std::string &rot();
66 static const std::string &rotx();
67 static const std::string &roty();
68 static const std::string &rotz();
69 static const std::string &pDouble();
70 static const std::string &pInt();
71 static const std::string &pBool();
72 static const std::string &pString();
73 static const std::string &pV3D();
74 static const std::string &pQuat();
75 static const std::string &scale();
77 const std::string diff(
const ParameterMap &
rhs,
const bool &firstDiffOnly =
false,
const bool relative =
false,
78 const double doubleTolerance = Kernel::Tolerance)
const;
87 m_parameterInfo->clear();
90 clearPositionSensitiveCaches();
96 m_parameterInfo.swap(other.m_parameterInfo);
97 m_idToIndex.swap(other.m_idToIndex);
98 m_indexToId.swap(other.m_indexToId);
99 clearPositionSensitiveCaches();
102 void clearParametersByName(
const std::string &
name);
105 void clearParametersByName(
const std::string &
name,
const IComponent *comp);
108 void add(
const std::string &type,
const IComponent *comp,
const std::string &
name,
const std::string &
value,
109 const std::string *
const pDescription =
nullptr,
const std::string &visible =
"true");
127 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true") {
129 auto typedParam = std::dynamic_pointer_cast<ParameterType<T>>(param);
131 typedParam->setValue(
value);
132 this->add(comp, param, pDescription);
136 void add(
const IComponent *comp,
const std::shared_ptr<Parameter> &par,
137 const std::string *
const pDescription =
nullptr);
142 void addFittingParameter(
const IComponent *comp,
const std::string &
name,
const std::string &fittingFunction,
143 const std::string &
value,
const std::string *
const pDescription =
nullptr,
144 const std::string &pVisible =
"true");
153 void add(
const std::string &type,
const size_t componentIndex,
const std::string &
name,
const std::string &
value,
154 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
155 void add(
const size_t componentIndex,
const std::shared_ptr<Parameter> &par,
156 const std::string *
const pDescription =
nullptr);
157 void addFittingParameter(
const size_t componentIndex,
const std::string &
name,
const std::string &fittingFunction,
158 const std::string &
value,
const std::string *
const pDescription =
nullptr,
159 const std::string &pVisible =
"true");
164 void addPositionCoordinate(
const IComponent *comp,
const std::string &
name,
const double value,
165 const std::string *
const pDescription =
nullptr);
167 void addRotationParam(
const IComponent *comp,
const std::string &
name,
const double deg,
168 const std::string *
const pDescription =
nullptr);
171 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
174 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
177 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
180 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
183 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
186 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
189 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
192 const std::string *
const pDescription =
nullptr);
195 const std::string *
const pDescription =
nullptr);
198 const std::string *
const pDescription =
nullptr);
204 bool contains(
const IComponent *comp,
const std::string &
name,
const std::string &type =
"")
const;
206 bool contains(
const IComponent *comp,
const char *
name,
const char *type =
"")
const;
210 std::shared_ptr<Parameter> get(
const IComponent *comp,
const std::string &
name,
const std::string &type =
"")
const;
212 std::shared_ptr<Parameter> get(
const IComponent *comp,
const char *
name,
const char *type =
"")
const;
214 std::shared_ptr<Parameter> getByType(
const IComponent *comp,
const std::string &type)
const;
217 std::shared_ptr<Parameter> getRecursive(
const IComponent *comp,
const std::string &
name,
218 const std::string &type =
"")
const;
221 std::shared_ptr<Parameter> getRecursive(
const IComponent *comp,
const char *
name,
const char *type =
"")
const;
224 std::shared_ptr<Parameter> getRecursiveByType(
const IComponent *comp,
const std::string &type)
const;
229 std::shared_ptr<Parameter> getRecursiveFittingParameter(
const IComponent *comp,
const std::string &
name,
230 const std::string &fittingFunction)
const;
239 template <
class T> std::vector<T>
getType(
const std::string &compName,
const std::string &
name)
const {
240 std::vector<T> retval;
242 for (
auto const &entry : entries()) {
243 if (compName == entry.first->getName()) {
244 std::shared_ptr<Parameter>
const param = get(entry.first,
name);
246 retval.emplace_back(param->value<T>());
253 const std::string getDescription(
const std::string &compName,
const std::string &
name)
const;
255 const std::string getShortDescription(
const std::string &compName,
const std::string &
name)
const;
258 std::string getString(
const IComponent *comp,
const std::string &
name,
bool recursive =
false)
const;
261 std::vector<std::string>
getString(
const std::string &compName,
const std::string &
name)
const {
262 return getType<std::string>(compName,
name);
271 std::vector<double>
getDouble(
const std::string &compName,
const std::string &
name)
const {
272 return getType<double>(compName,
name);
281 std::vector<Kernel::V3D>
getV3D(
const std::string &compName,
const std::string &
name)
const {
282 return getType<Kernel::V3D>(compName,
name);
286 std::set<std::string> names(
const IComponent *comp)
const;
288 std::string asString()
const;
291 void clearPositionSensitiveCaches();
301 void saveNexus(Nexus::File *file,
const std::string &
group)
const;
307 const std::vector<std::string> &getParameterFilenames()
const;
309 void addParameterFilename(
const std::string &filename);
312 std::vector<Entry> entries()
const;
314 bool hasDetectorInfo(
const Instrument *instrument)
const;
315 bool hasComponentInfo(
const Instrument *instrument)
const;
324 void setInstrument(
const Instrument *instrument);
350 std::shared_ptr<ParameterInfo> rekey(
const std::unordered_map<Geometry::IComponent const *, size_t> &idToIndex);
353 std::shared_ptr<Parameter>
create(
const std::string &className,
const std::string &
name,
354 const std::string &visible =
"true")
const;
359 void buildInstrumentMetadata();
361 bool relErr(
double x1,
double x2,
double errorVal)
const;
377 std::unordered_map<Geometry::IComponent const *, size_t>
m_idToIndex;
382 std::unique_ptr<Kernel::Cache<const ComponentID, Kernel::V3D>>
m_cacheLocMap;
384 std::unique_ptr<Kernel::Cache<const ComponentID, Kernel::Quat>>
m_cacheRotMap;
const std::vector< double > & rhs
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
Mantid::Kernel::Quat(ComponentInfo::* rotation)(const size_t) const
ComponentInfo : Provides a component centric view on to the instrument.
Geometry::DetectorInfo is an intermediate step towards a DetectorInfo that is part of Instrument-2....
base class for Geometric IComponent
Parameter map iterator typedef.
void clear()
Clears the map.
ParameterMap & operator=(ParameterMap *rhs)
Assignment operator.
std::vector< Kernel::V3D > getV3D(const std::string &compName, const std::string &name) const
Returns a Kernel::V3D parameter as vector's first element if exists and an empty vector if it doesn't...
bool empty() const
Returns true if the map is empty, false otherwise.
std::vector< ComponentID > m_indexToId
Reverse of m_idToIndex.
std::shared_ptr< ParameterInfo > m_parameterInfo
The parameter store, owner of the parameter info.
std::unordered_map< Geometry::IComponent const *, size_t > m_idToIndex
Component pointer to index translation.
std::shared_ptr< Geometry::InstrumentMetadata > m_instrumentMetadata
std::vector< T > getType(const std::string &compName, const std::string &name) const
Get the values of a given parameter of all the components that have the name: compName.
const std::shared_ptr< Geometry::InstrumentMetadata > & sharedInstrumentMetadata() const
const std::shared_ptr< ParameterInfo > & sharedParameterInfo() const
The parameter store this map owns.
const std::shared_ptr< Geometry::DetectorInfo > & sharedDetectorInfo() const
const std::shared_ptr< Geometry::ComponentInfo > & sharedComponentInfo() const
std::vector< std::string > getString(const std::string &compName, const std::string &name) const
Returns a string parameter as vector's first element if exists and an empty vector if it doesn't.
std::pair< ComponentID, std::shared_ptr< Parameter > > Entry
A stored parameter together with the component it belongs to.
int size() const
Return the size of the map.
std::vector< std::string > m_parameterFileNames
internal list of parameter files loaded
std::unique_ptr< Kernel::Cache< const ComponentID, Kernel::V3D > > m_cacheLocMap
internal cache map instance for cached position values
void add(const std::string &type, const IComponent *comp, const std::string &name, const T &value, const std::string *const pDescription=nullptr, const std::string &pVisible="true")
Method for adding a parameter providing its value of a particular type.
std::unique_ptr< Kernel::Cache< const ComponentID, Kernel::Quat > > m_cacheRotMap
internal cache map instance for cached rotation values
std::vector< double > getDouble(const std::string &compName, const std::string &name) const
Returns a double parameter as vector's first element if exists and an empty vector if it doesn't.
const std::vector< Geometry::ComponentID > & componentIds() const
std::shared_ptr< Geometry::DetectorInfo > m_detectorInfo
The 2.0 instrument layers, co-owned with the ExperimentInfo that built them.
std::shared_ptr< Geometry::ComponentInfo > m_componentInfo
void swap(ParameterMap &other)
method swaps two parameter maps contents each other.
Base class for parameters of an instrument.
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
std::shared_ptr< ParameterMap > ParameterMap_sptr
ParameterMap shared pointer typedef.
std::shared_ptr< const ParameterMap > ParameterMap_const_sptr
ParameterMap constant shared pointer typedef.
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.
constexpr bool operator==(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr bool operator!=(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)