Mantid
Loading...
Searching...
No Matches
AlgorithmProperties.h
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 +
7#pragma once
8
9#include "MantidAPI/DllConfig.h"
12#include "MantidAPI/IFunction.h"
14#include "MantidAPI/Workspace.h"
16
17#include <map>
18#include <optional>
19#include <string>
20
22
23// These convenience functions convert properties of various types into
24// strings to set the relevant property in an AlgorithmRuntimeProps
25
26void MANTID_API_DLL update(std::string const &property, std::string const &value, IAlgorithmRuntimeProps &properties);
27
28void MANTID_API_DLL update(std::string const &property, std::optional<std::string> const &value,
29 IAlgorithmRuntimeProps &properties);
30
31void MANTID_API_DLL update(std::string const &property, bool value, IAlgorithmRuntimeProps &properties);
32
33void MANTID_API_DLL update(std::string const &property, int value, IAlgorithmRuntimeProps &properties);
34
35void MANTID_API_DLL update(std::string const &property, size_t value, IAlgorithmRuntimeProps &properties);
36
37void MANTID_API_DLL update(std::string const &property, double value, IAlgorithmRuntimeProps &properties);
38
39void MANTID_API_DLL update(std::string const &property, std::optional<double> const &value,
40 IAlgorithmRuntimeProps &properties);
41
42void MANTID_API_DLL update(std::string const &property, Workspace_sptr const &workspace,
43 IAlgorithmRuntimeProps &properties);
44
45void MANTID_API_DLL update(std::string const &property, MatrixWorkspace_sptr const &workspace,
46 IAlgorithmRuntimeProps &properties);
47
48void MANTID_API_DLL update(std::string const &property, IFunction_sptr const &function,
49 IAlgorithmRuntimeProps &properties);
50
51void MANTID_API_DLL updateFromMap(IAlgorithmRuntimeProps &properties,
52 std::map<std::string, std::string> const &parameterMap);
53
54std::string MANTID_API_DLL getOutputWorkspace(const Mantid::API::IAlgorithm_sptr &algorithm,
55 std::string const &property);
56
57template <typename VALUE_TYPE>
58void update(std::string const &property, std::vector<VALUE_TYPE> const &values,
59 Mantid::API::IAlgorithmRuntimeProps &properties, bool const convertToString = true) {
60 if (values.size() < 1)
61 return;
62
63 if (convertToString) {
64 auto value = Mantid::Kernel::Strings::simpleJoin(values.cbegin(), values.cend(), ", ");
65 update(property, value, properties);
66 } else {
67 properties.setProperty(property, values);
68 }
69}
70
71} // namespace Mantid::API::AlgorithmProperties
double value
The value of the point.
Definition FitMW.cpp:51
IPeaksWorkspace_sptr workspace
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
DLLExport std::string simpleJoin(ITERATOR_TYPE begin, ITERATOR_TYPE end, const std::string &separator)
Join a set or vector of (something that turns into a string) together into one string,...
Definition Strings.h:53