Mantid
Loading...
Searching...
No Matches
MementoTableWorkspace.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
11#include "MantidKernel/Logger.h"
12
13namespace Mantid::DataObjects {
14
15DECLARE_WORKSPACE(MementoTableWorkspace)
16
17
23bool MementoTableWorkspace::expectedColumn(const Mantid::API::Column_const_sptr &expected,
24 const Mantid::API::Column_const_sptr &candidate) {
25 if (expected->name() != candidate->name()) {
26 return false;
27 } else if (expected->type() != candidate->type()) {
28 return false;
29 } else {
30 return true;
31 }
32}
33
43 MementoTableWorkspace theStandard;
44 size_t nCols = theStandard.columnCount();
45 if (nCols != candidate.columnCount()) {
46 return false;
47 }
48 for (size_t i = 0; i < nCols; i++) {
49 if (!expectedColumn(theStandard.getColumn(i), candidate.getColumn(i))) {
50 return false;
51 }
52 }
53 return true;
54}
55
58 // Configure the columns as part of the construction.
59 this->addColumn("str", "WSName");
60 this->addColumn("str", "ISName");
61 this->addColumn("int", "RunNumber");
62 this->addColumn("str", "ShapeXML");
63 this->addColumn("double", "a");
64 this->addColumn("double", "b");
65 this->addColumn("double", "c");
66 this->addColumn("double", "alpha");
67 this->addColumn("double", "beta");
68 this->addColumn("double", "gamma");
69 this->addColumn("str", "Status");
70}
71} // namespace Mantid::DataObjects
#define DECLARE_WORKSPACE(classname)
ITableWorkspace is an implementation of Workspace in which the data are organised in columns of same ...
virtual Column_sptr getColumn(const std::string &name)=0
Gets the shared pointer to a column by name.
virtual size_t columnCount() const =0
Number of columns in the workspace.
Variation on the TableWorkspace with a set of pre-defined columns used to store diffs on Workspaces.
static bool isMementoWorkspace(const Mantid::API::ITableWorkspace &candidate)
Determines whether a given table workspace has columns in the same order, and exactly matching those ...
static bool expectedColumn(const Mantid::API::Column_const_sptr &expected, const Mantid::API::Column_const_sptr &candidate)
Determines whether the provided column has the same name and type as expected.
TableWorkspace is an implementation of Workspace in which the data are organised in columns of same s...
size_t columnCount() const override
Number of columns in the workspace.
API::Column_sptr addColumn(const std::string &type, const std::string &name) override
Creates a new column.
API::Column_sptr getColumn(const std::string &name) override
Gets the shared pointer to a column.
std::shared_ptr< const Column > Column_const_sptr
Definition: Column.h:229
Helper class which provides the Collimation Length for SANS instruments.