Mantid
Loading...
Searching...
No Matches
AlgorithmHasProperty.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 <memory>
11#include <utility>
12
13namespace Mantid::API {
14
16AlgorithmHasProperty::AlgorithmHasProperty(std::string propName) : m_propName(std::move(propName)) {}
17
22std::string AlgorithmHasProperty::getType() const { return "AlgorithmHasProperty"; }
23
25Kernel::IValidator_sptr AlgorithmHasProperty::clone() const { return std::make_shared<AlgorithmHasProperty>(*this); }
26
33std::string AlgorithmHasProperty::checkValidity(const std::shared_ptr<IAlgorithm> &value) const {
34 std::string message;
35 if (value->existsProperty(m_propName)) {
36 Kernel::Property *p = value->getProperty(m_propName);
37 if (!p->isValid().empty()) {
38 message = "Algorithm object contains the required property \"" + m_propName +
39 "\" but it has an invalid value: " + p->value();
40 }
41 } else {
42 message = "Algorithm object does not have the required property \"" + m_propName + "\"";
43 }
44
45 return message;
46}
47
48} // namespace Mantid::API
double value
The value of the point.
Definition: FitMW.cpp:51
Kernel::IValidator_sptr clone() const override
Make a copy of the present type of validator.
std::string m_propName
Store the property name.
AlgorithmHasProperty(std::string propName)
Constructor.
std::string checkValidity(const std::shared_ptr< IAlgorithm > &value) const override
Checks the value based on the validator's rules.
std::string getType() const
Get a string representation of the type.
Base class for properties.
Definition: Property.h:94
virtual std::string isValid() const
Overridden function that checks whether the property, if not overriden returns "".
Definition: Property.cpp:82
virtual std::string value() const =0
Returns the value of the property as a string.
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.
Definition: IValidator.h:26
STL namespace.