Mantid
Loading...
Searching...
No Matches
IEventWorkspace.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
10namespace Mantid {
11
12namespace API {
13
14const std::string IEventWorkspace::toString() const {
15 std::ostringstream os;
16 os << MatrixWorkspace::toString() << "\n";
17
18 os << "Events: " + std::to_string(getNumberEvents());
19 switch (getEventType()) {
20 case WEIGHTED:
21 os << " (weighted)\n";
22 break;
23 case WEIGHTED_NOTIME:
24 os << " (weighted, no times)\n";
25 break;
26 case TOF:
27 os << "\n";
28 break;
29 }
30 return os.str();
31}
32} // namespace API
33
35/*
36 * In order to be able to cast PropertyWithValue classes correctly a definition
37 *for the PropertyWithValue<IEventWorkspace> is required
38 *
39 */
40namespace Kernel {
41
42template <>
44IPropertyManager::getValue<Mantid::API::IEventWorkspace_sptr>(const std::string &name) const {
45 auto *prop = dynamic_cast<PropertyWithValue<Mantid::API::IEventWorkspace_sptr> *>(getPointerToProperty(name));
46 if (prop) {
47 return *prop;
48 } else {
49 std::string message =
50 "Attempt to assign property " + name + " to incorrect type. Expected shared_ptr<IEventWorkspace>.";
51 throw std::runtime_error(message);
52 }
53}
54
55template <>
57IPropertyManager::getValue<Mantid::API::IEventWorkspace_const_sptr>(const std::string &name) const {
58 auto *prop = dynamic_cast<PropertyWithValue<Mantid::API::IEventWorkspace_sptr> *>(getPointerToProperty(name));
59 if (prop) {
60 return prop->operator()();
61 } else {
62 std::string message =
63 "Attempt to assign property " + name + " to incorrect type. Expected const shared_ptr<IEventWorkspace>.";
64 throw std::runtime_error(message);
65 }
66}
67} // namespace Kernel
68
69// namespace Kernel
70} // namespace Mantid
71
virtual EventType getEventType() const =0
const std::string toString() const override
Serializes the object to a string.
virtual std::size_t getNumberEvents() const =0
const std::string toString() const override
String description of state.
std::shared_ptr< const IEventWorkspace > IEventWorkspace_const_sptr
shared pointer to Mantid::API::IEventWorkspace (const version)
std::shared_ptr< IEventWorkspace > IEventWorkspace_sptr
shared pointer to Mantid::API::IEventWorkspace
@ WEIGHTED_NOTIME
Definition: IEventList.h:18
Helper class which provides the Collimation Length for SANS instruments.
std::string to_string(const wide_integer< Bits, Signed > &n)