Mantid
Loading...
Searching...
No Matches
AlgorithmProperties.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2019 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 +
10
12
15
16std::string boolToString(bool value) { return value ? "1" : "0"; }
17
18void update(std::string const &property, std::string const &value, IAlgorithmRuntimeProps &properties) {
19 if (!value.empty())
20 properties.setPropertyValue(property, value);
21}
22
23void update(std::string const &property, std::optional<std::string> const &value, IAlgorithmRuntimeProps &properties) {
24 if (value)
25 update(property, value.value(), properties);
26}
27
28void update(std::string const &property, bool value, IAlgorithmRuntimeProps &properties) {
29 properties.setProperty(property, value);
30}
31
32void update(std::string const &property, int value, IAlgorithmRuntimeProps &properties) {
33 properties.setProperty(property, value);
34}
35
36void update(std::string const &property, size_t value, IAlgorithmRuntimeProps &properties) {
37 properties.setProperty(property, value);
38}
39
40void update(std::string const &property, double value, IAlgorithmRuntimeProps &properties) {
41 properties.setProperty(property, value);
42}
43
44void update(std::string const &property, std::optional<double> const &value, IAlgorithmRuntimeProps &properties) {
45 if (value)
46 update(property, value.value(), properties);
47}
48
49void update(std::string const &property, Workspace_sptr const &workspace, IAlgorithmRuntimeProps &properties) {
50 properties.setProperty(property, workspace);
51}
52
53void update(std::string const &property, MatrixWorkspace_sptr const &workspace, IAlgorithmRuntimeProps &properties) {
54 properties.setProperty(property, workspace);
55}
56
57void update(std::string const &property, IFunction_sptr const &function, IAlgorithmRuntimeProps &properties) {
58 properties.setProperty(property, function);
59}
60
61void updateFromMap(IAlgorithmRuntimeProps &properties, std::map<std::string, std::string> const &parameterMap) {
62 for (auto kvp : parameterMap) {
63 update(kvp.first, kvp.second, properties);
64 }
65}
66std::string getOutputWorkspace(const IAlgorithm_sptr &algorithm, std::string const &property) {
67 auto const workspaceName = algorithm->getPropertyValue(property);
68 return workspaceName;
69}
70
71} // namespace Mantid::API::AlgorithmProperties
double value
The value of the point.
Definition FitMW.cpp:51
IPeaksWorkspace_sptr workspace
virtual void setPropertyValue(const std::string &, const std::string &) override=0
Sets property value from a string.
void setProperty(const std::string &name, const T &value)
void MANTID_API_DLL updateFromMap(IAlgorithmRuntimeProps &properties, std::map< std::string, std::string > const &parameterMap)
std::string MANTID_API_DLL getOutputWorkspace(const Mantid::API::IAlgorithm_sptr &algorithm, std::string const &property)
void MANTID_API_DLL update(std::string const &property, std::string const &value, IAlgorithmRuntimeProps &properties)
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition IFunction.h:743
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class