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#include "MantidAPI/IFunction.h"
11
13
16
17std::string boolToString(bool value) { return value ? "1" : "0"; }
18
19void update(std::string const &property, std::string const &value, IAlgorithmRuntimeProps &properties) {
20 if (!value.empty())
21 properties.setPropertyValue(property, value);
22}
23
24void update(std::string const &property, std::optional<std::string> const &value, IAlgorithmRuntimeProps &properties) {
25 if (value)
26 update(property, value.value(), properties);
27}
28
29void update(std::string const &property, bool value, IAlgorithmRuntimeProps &properties) {
30 properties.setProperty(property, value);
31}
32
33void update(std::string const &property, int value, IAlgorithmRuntimeProps &properties) {
34 properties.setProperty(property, value);
35}
36
37void update(std::string const &property, size_t value, IAlgorithmRuntimeProps &properties) {
38 properties.setProperty(property, value);
39}
40
41void update(std::string const &property, double value, IAlgorithmRuntimeProps &properties) {
42 properties.setProperty(property, value);
43}
44
45void update(std::string const &property, std::optional<double> const &value, IAlgorithmRuntimeProps &properties) {
46 if (value)
47 update(property, value.value(), properties);
48}
49
50void update(std::string const &property, Workspace_sptr const &workspace, IAlgorithmRuntimeProps &properties) {
51 properties.setProperty(property, workspace);
52}
53
54void update(std::string const &property, MatrixWorkspace_sptr const &workspace, IAlgorithmRuntimeProps &properties) {
55 properties.setProperty(property, workspace);
56}
57
58void update(std::string const &property, IFunction_sptr const &function, IAlgorithmRuntimeProps &properties) {
59 properties.setProperty(property, function);
60}
61
62void updateFromMap(IAlgorithmRuntimeProps &properties, std::map<std::string, std::string> const &parameterMap) {
63 for (auto kvp : parameterMap) {
64 update(kvp.first, kvp.second, properties);
65 }
66}
67std::string getOutputWorkspace(const IAlgorithm_sptr &algorithm, std::string const &property) {
68 auto const workspaceName = algorithm->getPropertyValue(property);
69 return workspaceName;
70}
71
72std::vector<std::string> getMultipleOutputWorkspaces(const IAlgorithm_sptr &algorithm, std::string const &property) {
73 std::vector<std::string> workspaceNames = algorithm->getProperty(property);
74 return workspaceNames;
75}
76
77} // 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)
std::vector< std::string > MANTID_API_DLL getMultipleOutputWorkspaces(const Mantid::API::IAlgorithm_sptr &algorithm, std::string const &property)
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:749
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class