Mantid
Loading...
Searching...
No Matches
DataBlock.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 +
9
10#include <vector>
11
12namespace Mantid::DataHandling {
13
14// Defines a negative value which is not something which spectra
15// indices can have.
16
18 : m_numberOfPeriods(0), m_numberOfSpectra(0), m_numberOfChannels(0),
19 m_minSpectraID(std::numeric_limits<specnum_t>::max()), m_maxSpectraID(0) {}
20
22 : m_numberOfPeriods(data.dim0()), m_numberOfSpectra(data.dim1()), m_numberOfChannels(data.dim2()),
23 m_minSpectraID(std::numeric_limits<specnum_t>::max()), m_maxSpectraID(0) {}
24
25DataBlock::DataBlock(int numberOfPeriods, size_t numberOfSpectra, size_t numberOfChannels)
26 : m_numberOfPeriods(numberOfPeriods), m_numberOfSpectra(numberOfSpectra), m_numberOfChannels(numberOfChannels),
27 m_minSpectraID(std::numeric_limits<specnum_t>::max()), m_maxSpectraID(0) {}
28
30
32
34
36
38
40
42
43std::unique_ptr<DataBlockGenerator> DataBlock::getGenerator() const {
44 std::vector<SpectrumPair> interval{std::make_pair(m_minSpectraID, m_maxSpectraID)};
45 return std::make_unique<DataBlockGenerator>(interval);
46}
47
48bool DataBlock::operator==(const DataBlock &other) const {
49 return (m_numberOfPeriods == other.m_numberOfPeriods) && (m_numberOfChannels == other.m_numberOfChannels) &&
50 (m_numberOfSpectra == other.m_numberOfSpectra) && (m_minSpectraID == other.m_minSpectraID) &&
51 (m_maxSpectraID == other.m_maxSpectraID);
52}
53
54} // namespace Mantid::DataHandling
DataBlock: The DataBlock class holds information about a contiguous block of spectrum numbers.
Definition: DataBlock.h:26
virtual specnum_t getMaxSpectrumID() const
Definition: DataBlock.cpp:33
virtual size_t getNumberOfChannels() const
Definition: DataBlock.cpp:41
virtual void setMaxSpectrumID(specnum_t minSpecID)
Definition: DataBlock.cpp:35
virtual int getNumberOfPeriods() const
Definition: DataBlock.cpp:39
virtual std::unique_ptr< DataBlockGenerator > getGenerator() const
Definition: DataBlock.cpp:43
virtual size_t getNumberOfSpectra() const
Definition: DataBlock.cpp:37
bool operator==(const DataBlock &other) const
Definition: DataBlock.cpp:48
virtual specnum_t getMinSpectrumID() const
Definition: DataBlock.cpp:29
virtual void setMinSpectrumID(specnum_t minSpecID)
Definition: DataBlock.cpp:31
Templated class implementation of NXDataSet.
Definition: NexusClasses.h:203
int32_t specnum_t
Typedef for a spectrum Number.
Definition: IDTypes.h:16
STL namespace.