Mantid
Loading...
Searching...
No Matches
WorkspaceSingleValue.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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 +
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
14
15namespace Mantid {
16
17namespace DataObjects {
22class MANTID_DATAOBJECTS_DLL WorkspaceSingleValue : public API::HistoWorkspace {
23public:
26 const std::string id() const override { return "WorkspaceSingleValue"; }
27
28 WorkspaceSingleValue(double value = 0.0, double error = 0.0,
29 const Parallel::StorageMode storageMode = Parallel::StorageMode::Cloned);
30
32 std::unique_ptr<WorkspaceSingleValue> clone() const { return std::unique_ptr<WorkspaceSingleValue>(doClone()); }
34 std::unique_ptr<WorkspaceSingleValue> cloneEmpty() const {
35 return std::unique_ptr<WorkspaceSingleValue>(doCloneEmpty());
36 }
38
40 bool isRaggedWorkspace() const override { return false; }
41
43 std::size_t size() const override { return 1; }
44
46 std::size_t blocksize() const override { return 1; }
48 std::size_t getNumberBins(const std::size_t &index) const override {
50 return 1;
51 }
53 std::size_t getMaxNumberBins() const override { return 1; }
54
56 std::size_t getNumberHistograms() const override { return 1; }
57
58 Histogram1D &getSpectrum(const size_t index) override {
59 invalidateCommonBinsFlag();
60 return getSpectrumWithoutInvalidation(index);
61 }
62 const Histogram1D &getSpectrum(const size_t /*index*/) const override { return data; }
63
64 void generateHistogram(const std::size_t index, const MantidVec &X, MantidVec &Y, MantidVec &E,
65 bool skipError = false) const override;
66
68 size_t getNumDims() const override;
69
70protected:
73
74private:
75 WorkspaceSingleValue *doClone() const override { return new WorkspaceSingleValue(*this); }
76 WorkspaceSingleValue *doCloneEmpty() const override { return new WorkspaceSingleValue(); }
77
78 // allocates space in a new workspace - does nothing in this case
79 void init(const std::size_t &NVectors, const std::size_t &XLength, const std::size_t &YLength) override;
80 void init(const HistogramData::Histogram &histogram) override;
81 Histogram1D &getSpectrumWithoutInvalidation(const size_t index) override;
83 Histogram1D data{HistogramData::Histogram::XMode::Points, HistogramData::Histogram::YMode::Counts};
84};
85
87using WorkspaceSingleValue_sptr = std::shared_ptr<WorkspaceSingleValue>;
88using WorkspaceSingleValue_const_sptr = std::shared_ptr<const WorkspaceSingleValue>;
89
90} // namespace DataObjects
91} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
double error
Definition: IndexPeaks.cpp:133
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition: System.h:64
HistoWorkspace is an abstract base class for MatrixWorkspace types that are NOT event workspaces.
1D histogram implementation.
Definition: Histogram1D.h:18
Concrete workspace implementation.
std::size_t size() const override
Returns the number of single indexable items in the workspace.
bool isRaggedWorkspace() const override
Returns true if the workspace is ragged (has differently sized spectra).
const Histogram1D & getSpectrum(const size_t) const override
Return the underlying ISpectrum ptr (const version) at the given workspace index.
std::size_t getMaxNumberBins() const override
Returns the maximum number of bins in a workspace.
WorkspaceSingleValue & operator=(const WorkspaceSingleValue &other)=delete
std::size_t getNumberBins(const std::size_t &index) const override
Returns the number of bins for a given histogram index.
const std::string id() const override
Gets the name of the workspace type.
WorkspaceSingleValue * doCloneEmpty() const override
Virtual cloneEmpty method.
Histogram1D & getSpectrum(const size_t index) override
Return the underlying ISpectrum ptr at the given workspace index.
std::size_t blocksize() const override
Returns the size of each block of data returned by the dataX accessors.
std::unique_ptr< WorkspaceSingleValue > cloneEmpty() const
Returns a default-initialized clone of the workspace.
WorkspaceSingleValue * doClone() const override
Virtual clone method. Not implemented to force implementation in children.
std::unique_ptr< WorkspaceSingleValue > clone() const
Returns a clone of the workspace.
std::size_t getNumberHistograms() const override
std::shared_ptr< WorkspaceSingleValue > WorkspaceSingleValue_sptr
shared pointer to the WorkspaceSingleValue class
std::shared_ptr< const WorkspaceSingleValue > WorkspaceSingleValue_const_sptr
Helper class which provides the Collimation Length for SANS instruments.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
Definition: cow_ptr.h:172