Mantid
Loading...
Searching...
No Matches
SingleCountValidator.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
9namespace Mantid::API {
10
17SingleCountValidator::SingleCountValidator(const bool &mustBeSingleCount)
18 : MatrixWorkspaceValidator(), m_mustBeSingleCount(mustBeSingleCount) {}
19
21Kernel::IValidator_sptr SingleCountValidator::clone() const { return std::make_shared<SingleCountValidator>(*this); }
22
31 auto blockSize = ws->histogram(0).size();
32
34 if (blockSize == 1)
35 return "";
36 else
37 return "The workspace must contain single counts for all spectra";
38 } else {
39 if (blockSize != 1)
40 return "";
41 else
42 return "The workspace must not contain single counts";
43 }
44}
45
46} // namespace Mantid::API
An interface for those validators that require the MatrixWorkspace interface.
Kernel::IValidator_sptr clone() const override
Clone the current state.
const bool m_mustBeSingleCount
A flag indicating whether this validator requires that the workspace be contain only single counts or...
SingleCountValidator(const bool &mustBeSingleCounts=true)
Constructor.
std::string checkValidity(const MatrixWorkspace_sptr &ws) const override
Check for validity.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.
Definition: IValidator.h:26