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"
11
12using namespace Mantid::Kernel;
13using namespace Mantid::API;
14
15namespace Mantid::DataObjects {
16namespace {
18Kernel::Logger g_log("SplittersWorkspace");
19} // namespace
20//----------------------------------------------------------------------------------------------
24 this->addColumn("long64", "start");
25 this->addColumn("long64", "stop");
26 this->addColumn("int", "workspacegroup");
27}
28
29/*
30 * Add a Splitter to
31 */
33 Mantid::API::TableRow row = this->appendRow();
34 row << splitter.start().totalNanoseconds();
35 row << splitter.stop().totalNanoseconds();
36 row << splitter.index();
37}
38
40 API::TableRow row = this->getRow(index);
41 int64_t start, stop;
42 int wsgroup;
43 row >> start;
44 row >> stop;
45 row >> wsgroup;
46
47 Kernel::SplittingInterval splitter(Types::Core::DateAndTime(start), Types::Core::DateAndTime(stop), wsgroup);
48
49 return splitter;
50}
51
52size_t SplittersWorkspace::getNumberSplitters() const { return this->rowCount(); }
53
55 bool removed;
56 if (index >= this->rowCount()) {
57 g_log.error() << "Try to delete a non-existing splitter " << index << '\n';
58 removed = false;
59 } else {
60 this->removeRow(index);
61 removed = true;
62 }
63
64 return removed;
65}
66
67} // namespace Mantid::DataObjects
68
70
71namespace Mantid::Kernel {
72
73template <>
75IPropertyManager::getValue<Mantid::DataObjects::SplittersWorkspace_sptr>(const std::string &name) const {
76 auto *prop =
77 dynamic_cast<PropertyWithValue<Mantid::DataObjects::SplittersWorkspace_sptr> *>(getPointerToProperty(name));
78 if (prop) {
79 return *prop;
80 } else {
81 std::string message =
82 "Attempt to assign property " + name + " to incorrect type. Expected shared_ptr<SplittersWorkspace>.";
83 throw std::runtime_error(message);
84 }
85}
86
87template <>
89IPropertyManager::getValue<Mantid::DataObjects::SplittersWorkspace_const_sptr>(const std::string &name) const {
90 auto *prop =
91 dynamic_cast<PropertyWithValue<Mantid::DataObjects::SplittersWorkspace_sptr> *>(getPointerToProperty(name));
92 if (prop) {
93 return prop->operator()();
94 } else {
95 std::string message =
96 "Attempt to assign property " + name + " to incorrect type. Expected const shared_ptr<SplittersWorkspace>.";
97 throw std::runtime_error(message);
98 }
99}
100
101} // namespace Mantid::Kernel
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
#define DLLExport
Definitions of the DLLImport compiler directives for MSVC.
Definition: System.h:53
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
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.
API::Column_sptr addColumn(const std::string &type, const std::string &name) override
Creates a new column.
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:52
void error(const std::string &msg)
Logs at error level.
Definition: Logger.cpp:77
The concrete, templated class for properties.
Class holding a start/end time and a destination for splitting event lists and logs.
Definition: TimeSplitter.h:23
Types::Core::DateAndTime stop() const
Return the stop time.
int index() const
Return the index (destination of this split time block)
Types::Core::DateAndTime start() const
Return the start time.
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< SplittersWorkspace > SplittersWorkspace_sptr
std::shared_ptr< const SplittersWorkspace > SplittersWorkspace_const_sptr