Mantid
Loading...
Searching...
No Matches
IMDEventWorkspace.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
9#include "MantidAPI/Sample.h"
12
13using Mantid::coord_t;
14using namespace Mantid::Geometry;
15
16namespace Mantid::API {
17
18//-----------------------------------------------------------------------------------------------
21
22//-----------------------------------------------------------------------------------------------
27
28//-----------------------------------------------------------------------------------------------
34
35//-----------------------------------------------------------------------------------------------
42bool IMDEventWorkspace::threadSafe() const { return !this->isFileBacked(); }
43
44const std::string IMDEventWorkspace::toString() const {
45 std::ostringstream os;
47
48 // Now box controller details
49 std::vector<std::string> stats = getBoxControllerStats();
50 for (auto const &stat : stats) {
51 os << stat << "\n";
52 }
53
55
56 os << "Events: " << getNPoints() << "\n";
57 return os.str();
58}
59
60//-----------------------------------------------------------------------------------------------
61
62} // namespace Mantid::API
63
64namespace Mantid::Kernel {
67template <>
69IPropertyManager::getValue<Mantid::API::IMDEventWorkspace_sptr>(const std::string &name) const {
70 auto *prop = dynamic_cast<PropertyWithValue<Mantid::API::IMDEventWorkspace_sptr> *>(getPointerToProperty(name));
71 if (prop) {
72 return *prop;
73 } else {
74 std::string message =
75 "Attempt to assign property " + name + " to incorrect type. Expected shared_ptr<IMDEventWorkspace>.";
76 throw std::runtime_error(message);
77 }
78}
79
82template <>
84IPropertyManager::getValue<Mantid::API::IMDEventWorkspace_const_sptr>(const std::string &name) const {
85 auto const *prop =
86 dynamic_cast<PropertyWithValue<Mantid::API::IMDEventWorkspace_const_sptr> *>(getPointerToProperty(name));
87 if (prop) {
88 return prop->operator()();
89 } else {
90 // Every other class with this behaviour allows you to get a shared_ptr<T>
91 // property as a shared_ptr<const T>. This class should be consistent, so
92 // try that:
93 auto const *nonConstProp =
94 dynamic_cast<PropertyWithValue<Mantid::API::IMDEventWorkspace_sptr> *>(getPointerToProperty(name));
95 if (nonConstProp) {
96 return nonConstProp->operator()();
97 } else {
98 std::string message =
99 "Attempt to assign property " + name + " to incorrect type. Expected const shared_ptr<IMDEventWorkspace>.";
100 throw std::runtime_error(message);
101 }
102 }
103}
104
105} // namespace Mantid::Kernel
std::string name
Definition Run.cpp:60
double value
The value of the point.
Definition FitMW.cpp:51
const std::string toString() const override
Serializes the object to a string.
bool threadSafe() const override
Is the workspace thread-safe.
virtual std::vector< std::string > getBoxControllerStats() const =0
Returns some information about the box controller, to be displayed in the GUI, for example.
void setFileNeedsUpdating(bool value)
Sets the marker set to true when a file-backed workspace needs its back-end file updated (by calling ...
virtual bool isFileBacked() const =0
bool m_fileNeedsUpdating
Marker set to true when a file-backed workspace needs its back-end file updated (by calling SaveMD(Up...
Basic MD Workspace Abstract Class.
const std::string toString() const override
Serializes the object to a string.
virtual uint64_t getNPoints() const =0
Get the number of points associated with the workspace.
Small class that allows a MDEventWorkspace or a MDHistoWorkspace to hold several ExperimentInfo class...
const std::string toString() const
Returns a string description of the object.
The concrete, templated class for properties.
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
std::shared_ptr< const IMDEventWorkspace > IMDEventWorkspace_const_sptr
Shared pointer to Mantid::API::IMDEventWorkspace (const version)
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
Definition MDTypes.h:27