9#include "MantidGeometry/DllConfig.h"
15#include "tbb/concurrent_unordered_map.h"
23template <
class KEYTYPE,
class VALUETYPE>
class Cache;
40using component_map_it = tbb::concurrent_unordered_multimap<ComponentID, std::shared_ptr<Parameter>>::iterator;
41using component_map_cit = tbb::concurrent_unordered_multimap<ComponentID, std::shared_ptr<Parameter>>::const_iterator;
46 using pmap = tbb::concurrent_unordered_multimap<ComponentID, std::shared_ptr<Parameter>>;
48 using pmap_it = tbb::concurrent_unordered_multimap<ComponentID, std::shared_ptr<Parameter>>::iterator;
50 using pmap_cit = tbb::concurrent_unordered_multimap<ComponentID, std::shared_ptr<Parameter>>::const_iterator;
57 inline bool empty()
const {
return m_map.empty(); }
59 inline int size()
const {
return static_cast<int>(m_map.size()); }
61 size_t getMemorySize()
const;
63 static const std::string &pos();
64 static const std::string &posx();
65 static const std::string &posy();
66 static const std::string &posz();
67 static const std::string &rot();
68 static const std::string &rotx();
69 static const std::string &roty();
70 static const std::string &rotz();
71 static const std::string &pDouble();
72 static const std::string &pInt();
73 static const std::string &pBool();
74 static const std::string &pString();
75 static const std::string &pV3D();
76 static const std::string &pQuat();
77 static const std::string &scale();
79 const std::string diff(
const ParameterMap &
rhs,
const bool &firstDiffOnly =
false,
const bool relative =
false,
80 const double doubleTolerance = Kernel::Tolerance)
const;
90 clearPositionSensitiveCaches();
95 m_map.swap(other.m_map);
96 clearPositionSensitiveCaches();
99 void clearParametersByName(
const std::string &
name);
102 void clearParametersByName(
const std::string &
name,
const IComponent *comp);
105 void add(
const std::string &type,
const IComponent *comp,
const std::string &
name,
const std::string &
value,
106 const std::string *
const pDescription =
nullptr,
const std::string &visible =
"true");
124 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true") {
126 auto typedParam = std::dynamic_pointer_cast<ParameterType<T>>(param);
128 typedParam->setValue(
value);
129 this->add(comp, param, pDescription);
133 void add(
const IComponent *comp,
const std::shared_ptr<Parameter> &par,
134 const std::string *
const pDescription =
nullptr);
139 void addFittingParameter(
const IComponent *comp,
const std::string &
name,
const std::string &fittingFunction,
140 const std::string &
value,
const std::string *
const pDescription =
nullptr,
141 const std::string &pVisible =
"true");
145 void addPositionCoordinate(
const IComponent *comp,
const std::string &
name,
const double value,
146 const std::string *
const pDescription =
nullptr);
148 void addRotationParam(
const IComponent *comp,
const std::string &
name,
const double deg,
149 const std::string *
const pDescription =
nullptr);
152 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
155 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
158 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
161 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
164 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
167 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
170 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
173 const std::string *
const pDescription =
nullptr);
176 const std::string *
const pDescription =
nullptr);
179 const std::string *
const pDescription =
nullptr);
185 bool contains(
const IComponent *comp,
const std::string &
name,
const std::string &type =
"")
const;
187 bool contains(
const IComponent *comp,
const char *
name,
const char *type =
"")
const;
191 std::shared_ptr<Parameter> get(
const IComponent *comp,
const std::string &
name,
const std::string &type =
"")
const;
193 std::shared_ptr<Parameter> get(
const IComponent *comp,
const char *
name,
const char *type =
"")
const;
195 std::shared_ptr<Parameter> getByType(
const IComponent *comp,
const std::string &type)
const;
198 std::shared_ptr<Parameter> getRecursive(
const IComponent *comp,
const std::string &
name,
199 const std::string &type =
"")
const;
202 std::shared_ptr<Parameter> getRecursive(
const IComponent *comp,
const char *
name,
const char *type =
"")
const;
205 std::shared_ptr<Parameter> getRecursiveByType(
const IComponent *comp,
const std::string &type)
const;
210 std::shared_ptr<Parameter> getRecursiveFittingParameter(
const IComponent *comp,
const std::string &
name,
211 const std::string &fittingFunction)
const;
220 template <
class T> std::vector<T>
getType(
const std::string &compName,
const std::string &
name)
const {
221 std::vector<T> retval;
224 for (it = m_map.begin(); it != m_map.end(); ++it) {
225 if (compName == it->first->getName()) {
226 std::shared_ptr<Parameter> param = get(it->first,
name);
228 retval.emplace_back(param->value<T>());
234 const std::string getDescription(
const std::string &compName,
const std::string &
name)
const;
236 const std::string getShortDescription(
const std::string &compName,
const std::string &
name)
const;
239 std::string getString(
const IComponent *comp,
const std::string &
name,
bool recursive =
false)
const;
242 std::vector<std::string>
getString(
const std::string &compName,
const std::string &
name)
const {
243 return getType<std::string>(compName,
name);
252 std::vector<double>
getDouble(
const std::string &compName,
const std::string &
name)
const {
253 return getType<double>(compName,
name);
262 std::vector<Kernel::V3D>
getV3D(
const std::string &compName,
const std::string &
name)
const {
263 return getType<Kernel::V3D>(compName,
name);
267 std::set<std::string> names(
const IComponent *comp)
const;
269 std::string asString()
const;
272 void clearPositionSensitiveCaches();
282 void saveNexus(Nexus::File *file,
const std::string &
group)
const;
288 const std::vector<std::string> &getParameterFilenames()
const;
290 void addParameterFilename(
const std::string &filename);
299 bool hasDetectorInfo(
const Instrument *instrument)
const;
300 bool hasComponentInfo(
const Instrument *instrument)
const;
308 void setInstrument(
const Instrument *instrument);
311 std::shared_ptr<Parameter>
create(
const std::string &className,
const std::string &
name,
312 const std::string &visible =
"true")
const;
322 bool relErr(
double x1,
double x2,
double errorVal)
const;
330 std::unique_ptr<Kernel::Cache<const ComponentID, Kernel::V3D>>
m_cacheLocMap;
332 std::unique_ptr<Kernel::Cache<const ComponentID, Kernel::Quat>>
m_cacheRotMap;
const std::vector< double > & rhs
double value
The value of the point.
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
pmap_it begin()
access iterators. begin;
void clear()
Clears the map.
std::unique_ptr< Geometry::DetectorInfo > m_detectorInfo
Pointer to the DetectorInfo wrapper.
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...
tbb::concurrent_unordered_multimap< ComponentID, std::shared_ptr< Parameter > >::iterator pmap_it
Parameter map iterator typedef.
bool empty() const
Returns true if the map is empty, false otherwise.
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.
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.
int size() const
Return the size of the map.
std::vector< std::string > m_parameterFileNames
internal list of parameter files loaded
pmap_it end()
access iterators. end;
pmap m_map
internal parameter map instance
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
tbb::concurrent_unordered_multimap< ComponentID, std::shared_ptr< Parameter > >::const_iterator pmap_cit
Parameter map iterator typedef.
std::unique_ptr< Geometry::ComponentInfo > m_componentInfo
Pointer to the ComponentInfo wrapper.
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.
tbb::concurrent_unordered_multimap< ComponentID, std::shared_ptr< Parameter > >::const_iterator component_map_cit
tbb::concurrent_unordered_multimap< ComponentID, std::shared_ptr< Parameter > >::iterator component_map_it
Parameter map iterator typedef.
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.
Generate a tableworkspace to store the calibration results.
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)