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 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;
88 clearPositionSensitiveCaches();
93 m_map.swap(other.m_map);
94 clearPositionSensitiveCaches();
97 void clearParametersByName(
const std::string &name);
100 void clearParametersByName(
const std::string &name,
const IComponent *comp);
103 void add(
const std::string &type,
const IComponent *comp,
const std::string &name,
const std::string &
value,
104 const std::string *
const pDescription =
nullptr,
const std::string &visible =
"true");
122 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true") {
123 auto param =
create(type, name, pVisible);
124 auto typedParam = std::dynamic_pointer_cast<ParameterType<T>>(param);
126 typedParam->setValue(
value);
127 this->add(comp, param, pDescription);
131 void add(
const IComponent *comp,
const std::shared_ptr<Parameter> &par,
132 const std::string *
const pDescription =
nullptr);
136 void addPositionCoordinate(
const IComponent *comp,
const std::string &name,
const double value,
137 const std::string *
const pDescription =
nullptr);
139 void addRotationParam(
const IComponent *comp,
const std::string &name,
const double deg,
140 const std::string *
const pDescription =
nullptr);
142 void addDouble(
const IComponent *comp,
const std::string &name,
const std::string &
value,
143 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
145 void addDouble(
const IComponent *comp,
const std::string &name,
double value,
146 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
148 void addInt(
const IComponent *comp,
const std::string &name,
const std::string &
value,
149 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
151 void addInt(
const IComponent *comp,
const std::string &name,
int value,
152 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
154 void addBool(
const IComponent *comp,
const std::string &name,
const std::string &
value,
155 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
157 void addBool(
const IComponent *comp,
const std::string &name,
bool value,
158 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
160 void addString(
const IComponent *comp,
const std::string &name,
const std::string &
value,
161 const std::string *
const pDescription =
nullptr,
const std::string &pVisible =
"true");
163 void addV3D(
const IComponent *comp,
const std::string &name,
const std::string &
value,
164 const std::string *
const pDescription =
nullptr);
167 const std::string *
const pDescription =
nullptr);
170 const std::string *
const pDescription =
nullptr);
176 bool contains(
const IComponent *comp,
const std::string &name,
const std::string &type =
"")
const;
178 bool contains(
const IComponent *comp,
const char *name,
const char *type =
"")
const;
182 std::shared_ptr<Parameter> get(
const IComponent *comp,
const std::string &name,
const std::string &type =
"")
const;
184 std::shared_ptr<Parameter> get(
const IComponent *comp,
const char *name,
const char *type =
"")
const;
186 std::shared_ptr<Parameter> getByType(
const IComponent *comp,
const std::string &type)
const;
189 std::shared_ptr<Parameter> getRecursive(
const IComponent *comp,
const std::string &name,
190 const std::string &type =
"")
const;
193 std::shared_ptr<Parameter> getRecursive(
const IComponent *comp,
const char *name,
const char *type =
"")
const;
196 std::shared_ptr<Parameter> getRecursiveByType(
const IComponent *comp,
const std::string &type)
const;
205 template <
class T> std::vector<T>
getType(
const std::string &compName,
const std::string &name)
const {
206 std::vector<T> retval;
209 for (it = m_map.begin(); it != m_map.end(); ++it) {
210 if (compName == it->first->getName()) {
211 std::shared_ptr<Parameter> param = get(it->first, name);
213 retval.emplace_back(param->value<T>());
219 const std::string getDescription(
const std::string &compName,
const std::string &name)
const;
221 const std::string getShortDescription(
const std::string &compName,
const std::string &name)
const;
224 std::string getString(
const IComponent *comp,
const std::string &name,
bool recursive =
false)
const;
227 std::vector<std::string>
getString(
const std::string &compName,
const std::string &name)
const {
228 return getType<std::string>(compName, name);
237 std::vector<double>
getDouble(
const std::string &compName,
const std::string &name)
const {
238 return getType<double>(compName, name);
247 std::vector<Kernel::V3D>
getV3D(
const std::string &compName,
const std::string &name)
const {
248 return getType<Kernel::V3D>(compName, name);
252 std::set<std::string> names(
const IComponent *comp)
const;
254 std::string asString()
const;
257 void clearPositionSensitiveCaches();
267 void saveNexus(::NeXus::File *file,
const std::string &group)
const;
273 const std::vector<std::string> &getParameterFilenames()
const;
275 void addParameterFilename(
const std::string &filename);
284 bool hasDetectorInfo(
const Instrument *instrument)
const;
285 bool hasComponentInfo(
const Instrument *instrument)
const;
293 void setInstrument(
const Instrument *instrument);
296 std::shared_ptr<Parameter>
create(
const std::string &className,
const std::string &name,
297 const std::string &visible =
"true")
const;
307 bool relErr(
double x1,
double x2,
double errorVal)
const;
315 std::unique_ptr<Kernel::Cache<const ComponentID, Kernel::V3D>>
m_cacheLocMap;
317 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)