Mantid
Loading...
Searching...
No Matches
SampleValidator.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#include "MantidAPI/Sample.h"
12
13namespace Mantid::API {
15
21SampleValidator::SampleValidator(const unsigned int flags) : m_requires(flags) {}
22
26std::string SampleValidator::getType() const { return "Sample"; }
27
31Kernel::IValidator_sptr SampleValidator::clone() const { return std::make_shared<SampleValidator>(*this); }
32
40 const auto &shape = value->sample().getShape();
41 std::list<std::string> missing;
42 if ((m_requires & Shape) && !shape.hasValidShape())
43 missing.emplace_back("shape");
44 const auto &material = shape.material();
45 if ((m_requires & Material) && material.name().empty())
46 missing.emplace_back("material");
47
48 if (missing.empty())
49 return "";
50 else {
51 return "The sample is missing the following properties: " + join(missing.begin(), missing.end(), ",");
52 }
53}
54
55} // namespace Mantid::API
double value
The value of the point.
Definition: FitMW.cpp:51
SampleValidator(const unsigned int flags=(Shape|Material))
Construct a validator with a set of requirements.
Kernel::IValidator_sptr clone() const override
std::string checkValidity(const MatrixWorkspace_sptr &value) const override
Check if the workspace satisfies the validation requirements.
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
Definition: Material.h:50
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
DLLExport std::string join(ITERATOR_TYPE begin, ITERATOR_TYPE end, const std::string &separator, typename std::enable_if<!(std::is_same< typename std::iterator_traits< ITERATOR_TYPE >::iterator_category, std::random_access_iterator_tag >::value)>::type *=nullptr)
Join a set or vector of (something that turns into a string) together into one string,...
Definition: Strings.h:84
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.
Definition: IValidator.h:26