Mantid
Loading...
Searching...
No Matches
PeakColumn.h
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 +
7#pragma once
8
9#include "MantidAPI/Column.h"
12
13#include <boost/variant.hpp>
14#include <list>
15
16namespace Mantid {
17namespace DataObjects {
18
28template <class T> class MANTID_DATAOBJECTS_DLL PeakColumn : public Mantid::API::Column {
29
30public:
32 PeakColumn(std::vector<T> &peaks, const std::string &name);
33
35 size_t size() const override { return m_peaks.size(); }
36
38 const std::type_info &get_type_info() const override;
39
41 const std::type_info &get_pointer_type_info() const override;
42
43 bool getReadOnly() const override;
44
46 void print(size_t index, std::ostream &s) const override;
47
48 void read(size_t index, const std::string &text) override;
49
51 void read(const size_t index, std::istringstream &in) override;
52
54 bool isBool() const override;
55
56 bool isNumber() const override;
57
59 long int sizeOfData() const override;
60
62 PeakColumn *clone() const override;
63
65 double toDouble(size_t i) const override;
66
68 void fromDouble(size_t i, double value) override;
69
71 const std::vector<T> &data() const { return m_peaks; }
72
73 bool equals(const Column &otherColumn, double tolerance) const override {
74 (void)otherColumn;
75 (void)tolerance;
76 throw std::runtime_error("equals not implemented, to compare use CompareWorkspace");
77 }
78
79protected:
81 void resize(size_t count) override;
83 void insert(size_t index) override;
85 void remove(size_t index) override;
87 void *void_pointer(size_t index) override;
89 const void *void_pointer(size_t index) const override;
90
91private:
93 std::vector<T> &m_peaks;
96
98 using CacheValueType = boost::variant<double, int, std::string, Kernel::V3D>;
100 mutable std::list<CacheValueType> m_oldRows;
102 void setPeakHKLOrRunNumber(const size_t index, const double val);
103};
104
105} // namespace DataObjects
106} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
int count
counter
Definition: Matrix.cpp:37
double tolerance
Column is the base class for columns of TableWorkspace.
Definition: Column.h:35
PeakColumn : a Column sub-class used to display peak information as a TableWorkspace.
Definition: PeakColumn.h:28
bool equals(const Column &otherColumn, double tolerance) const override
Definition: PeakColumn.h:73
const std::vector< T > & data() const
Reference to the data.
Definition: PeakColumn.h:71
std::vector< T > & m_peaks
Reference to the peaks object saved in the PeaksWorkspace.
Definition: PeakColumn.h:93
int m_hklPrec
Precision of hkl in table workspace.
Definition: PeakColumn.h:95
std::list< CacheValueType > m_oldRows
Definition: PeakColumn.h:100
boost::variant< double, int, std::string, Kernel::V3D > CacheValueType
Type of the row cache value.
Definition: PeakColumn.h:98
size_t size() const override
Number of individual elements in the column.
Definition: PeakColumn.h:35
Helper class which provides the Collimation Length for SANS instruments.