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} // namespace Mantid::DataObjects
67
69
70namespace Mantid::Kernel {
71
72template <>
74IPropertyManager::getValue<Mantid::DataObjects::SplittersWorkspace_sptr>(const std::string &name) const {
75 auto *prop =
76 dynamic_cast<PropertyWithValue<Mantid::DataObjects::SplittersWorkspace_sptr> *>(getPointerToProperty(name));
77 if (prop) {
78 return *prop;
79 } else {
80 std::string message =
81 "Attempt to assign property " + name + " to incorrect type. Expected shared_ptr<SplittersWorkspace>.";
82 throw std::runtime_error(message);
83 }
84}
85
86template <>
88IPropertyManager::getValue<Mantid::DataObjects::SplittersWorkspace_const_sptr>(const std::string &name) const {
89 auto const *prop =
90 dynamic_cast<PropertyWithValue<Mantid::DataObjects::SplittersWorkspace_sptr> *>(getPointerToProperty(name));
91 if (prop) {
92 return prop->operator()();
93 } else {
94 std::string message =
95 "Attempt to assign property " + name + " to incorrect type. Expected const shared_ptr<SplittersWorkspace>.";
96 throw std::runtime_error(message);
97 }
98}
99
100} // 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
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: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