Mantid
Loading...
Searching...
No Matches
SplittersWorkspace.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 +
8#include "MantidAPI/Column.h"
12
13using namespace Mantid::Kernel;
14using namespace Mantid::API;
15
16namespace Mantid::DataObjects {
17namespace {
19Kernel::Logger g_log("SplittersWorkspace");
20} // namespace
21
23
24//----------------------------------------------------------------------------------------------
28 this->addColumn("long64", "start");
29 this->addColumn("long64", "stop");
30 this->addColumn("int", "workspacegroup");
31}
32
33/*
34 * Add a Splitter to
35 */
37 Mantid::API::TableRow row = this->appendRow();
38 row << splitter.start().totalNanoseconds();
39 row << splitter.stop().totalNanoseconds();
40 row << splitter.index();
41}
42
44 API::TableRow row = this->getRow(index);
45 int64_t start, stop;
46 int wsgroup;
47 row >> start;
48 row >> stop;
49 row >> wsgroup;
50
51 Kernel::SplittingInterval splitter(Types::Core::DateAndTime(start), Types::Core::DateAndTime(stop), wsgroup);
52
53 return splitter;
54}
55
56size_t SplittersWorkspace::getNumberSplitters() const { return this->rowCount(); }
57
59 bool removed;
60 if (index >= this->rowCount()) {
61 g_log.error() << "Try to delete a non-existing splitter " << index << '\n';
62 removed = false;
63 } else {
64 this->removeRow(index);
65 removed = true;
66 }
67
68 return removed;
69}
70} // namespace Mantid::DataObjects
71
73
74namespace Mantid::Kernel {
75
76template <>
78IPropertyManager::getValue<Mantid::DataObjects::SplittersWorkspace_sptr>(const std::string &name) const {
79 auto *prop =
80 dynamic_cast<PropertyWithValue<Mantid::DataObjects::SplittersWorkspace_sptr> *>(getPointerToProperty(name));
81 if (prop) {
82 return *prop;
83 } else {
84 std::string message =
85 "Attempt to assign property " + name + " to incorrect type. Expected shared_ptr<SplittersWorkspace>.";
86 throw std::runtime_error(message);
87 }
88}
89
90template <>
92IPropertyManager::getValue<Mantid::DataObjects::SplittersWorkspace_const_sptr>(const std::string &name) const {
93 auto const *prop =
94 dynamic_cast<PropertyWithValue<Mantid::DataObjects::SplittersWorkspace_sptr> *>(getPointerToProperty(name));
95 if (prop) {
96 return prop->operator()();
97 } else {
98 std::string message =
99 "Attempt to assign property " + name + " to incorrect type. Expected const shared_ptr<SplittersWorkspace>.";
100 throw std::runtime_error(message);
101 }
102}
103
104} // namespace Mantid::Kernel
std::string name
Definition Run.cpp:60
std::map< DeltaEMode::Type, std::string > index
#define DLLExport
Definitions of the DLLImport compiler directives for MSVC.
Definition System.h:37
#define DECLARE_WORKSPACE(classname)
TableRowHelper appendRow()
Appends a row.
TableRowHelper getRow(size_t row)
Creates a TableRow object for row row.
TableRow represents a row in a TableWorkspace.
Definition TableRow.h:39
SplittersWorkspace : A TableWorkspace to contain TimeSplitters.
void addSplitter(const Kernel::SplittingInterval &splitter) override
Kernel::SplittingInterval getSplitter(size_t index) override
size_t rowCount() const override
Number of rows in the workspace.
void removeRow(size_t index) override
Delets a row if it exists.
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition Logger.h:51
void error(const std::string &msg)
Logs at error level.
Definition Logger.cpp:108
The concrete, templated class for properties.
Class holding a start/end time and a destination for splitting event lists and logs.
int index() const
Return the index (destination of this split time block)
const Types::Core::DateAndTime & start() const
Beginning of the interval.
Definition DateAndTime.h:34
const Types::Core::DateAndTime & stop() const
End of the interval.
Definition DateAndTime.h:36
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< SplittersWorkspace > SplittersWorkspace_sptr
std::shared_ptr< const SplittersWorkspace > SplittersWorkspace_const_sptr