10#include "MantidAPI/DllConfig.h"
12#include <boost/lexical_cast.hpp>
13#include <boost/optional.hpp>
40 const std::string &idf_name) {
42 if (algProperty->isDefault()) {
43 auto defaults = instrument->getNumberParameter(idf_name);
44 if (defaults.empty()) {
45 throw std::runtime_error(
"No data could be retrieved from the parameters "
46 "and argument wasn't provided: " +
49 return static_cast<T
>(defaults[0]);
51 return static_cast<T
>(boost::lexical_cast<double, std::string>(algProperty->value()));
71 const std::string &idf_name) {
73 if (algProperty->isDefault()) {
74 auto defaults = instrument->getNumberParameter(idf_name);
75 if (!defaults.empty()) {
76 return boost::optional<T>(
static_cast<T
>(defaults[0]));
78 return boost::optional<T>();
81 double value = boost::lexical_cast<double, std::string>(algProperty->value());
82 return boost::optional<T>(
static_cast<T
>(
value));
91 const std::string &propName,
93 const std::string &idf_name);
96MANTID_API_DLL boost::optional<std::string>
99 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.
T checkForMandatoryInstrumentDefault(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...
boost::optional< T > checkForOptionalInstrumentDefault(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.