10#include "MantidAPI/DllConfig.h"
13#include <boost/lexical_cast.hpp>
42 const std::string &idf_name) {
44 if (algProperty->isDefault()) {
45 auto defaults = instrument->getNumberParameter(idf_name);
46 if (defaults.empty()) {
47 throw std::runtime_error(
"No data could be retrieved from the parameters "
48 "and argument wasn't provided: " +
51 return static_cast<T
>(defaults[0]);
53 return static_cast<T
>(boost::lexical_cast<double, std::string>(algProperty->value()));
73 const std::string &idf_name) {
75 if (algProperty->isDefault()) {
76 auto defaults = instrument->getNumberParameter(idf_name);
77 if (!defaults.empty()) {
78 return std::optional<T>(
static_cast<T
>(defaults[0]));
83 double value = boost::lexical_cast<double, std::string>(algProperty->value());
84 return std::optional<T>(
static_cast<T
>(
value));
102 std::string
const &idf_name) {
104 if constexpr (std::is_same_v<T, std::string>) {
105 if (!algProperty->isDefault()) {
106 return algProperty->
value();
109 if (defaults.empty()) {
110 throw std::runtime_error(
"No data could be retrieved from the parameters "
111 "and argument wasn't provided: " +
116 if (!algProperty->isDefault()) {
117 return static_cast<T
>(boost::lexical_cast<double, std::string>(algProperty->value()));
120 if (defaults.empty()) {
121 throw std::runtime_error(
"No data could be retrieved from the parameters "
122 "and argument wasn't provided: " +
125 return static_cast<T
>(defaults[0]);
143 std::string
const &idf_name) {
145 if constexpr (std::is_same_v<T, std::string>) {
146 if (!algProperty->isDefault()) {
147 return algProperty->
value();
150 if (defaults.empty()) {
155 if (!algProperty->isDefault()) {
156 return static_cast<T
>(boost::lexical_cast<double, std::string>(algProperty->value()));
159 if (defaults.empty()) {
162 return static_cast<T
>(defaults[0]);
171 const std::string &propName,
173 const std::string &idf_name);
176MANTID_API_DLL std::optional<std::string>
179 const std::string &idf_name);
double value
The value of the point.
Base class from which all concrete algorithm classes should be derived.
Kernel::Property * getPointerToProperty(const std::string &name) const override
Get a property by name.
ComponentInfo : Provides a component centric view on to the instrument.
std::vector< std::string > getStringParameter(const size_t componentIndex, const std::string &name, bool recursive=true) const
std::vector< double > getNumberParameter(const size_t componentIndex, const std::string &name, bool recursive=true) const
virtual std::string value() const =0
Returns the value of the property as a string.
T checkForMandatoryInstrumentDefault(const Mantid::API::Algorithm *const alg, const std::string &propName, const Mantid::Geometry::Instrument_const_sptr &instrument, const std::string &idf_name)
BoostOptionalToAlgorithmProperty : Checks for default values of an algorithm property if the user has...
std::optional< T > checkForOptionalInstrumentDefault(const Mantid::API::Algorithm *const alg, const std::string &propName, const Mantid::Geometry::Instrument_const_sptr &instrument, const std::string &idf_name)
Checks for the default values of an optional algorithm property associated with an instrument compone...
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
Helper class which provides the Collimation Length for SANS instruments.