Mantid
Loading...
Searching...
No Matches
AlgorithmAdapter.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2011 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//-----------------------------------------------------------------------------
10// Includes
11//-----------------------------------------------------------------------------
12#include "MantidAPI/Algorithm.h"
13
14#include <boost/python/wrapper.hpp>
15#include <map>
16
17namespace Mantid {
18namespace PythonInterface {
19
27template <typename BaseAlgorithm> class AlgorithmAdapter : public BaseAlgorithm {
28 using SuperClass = BaseAlgorithm;
29
30public:
32 AlgorithmAdapter(PyObject *self);
33
36 AlgorithmAdapter() = delete;
37
40
43
47 const std::string name() const override;
49 int version() const override;
51 const std::string summary() const override;
53 const std::string category() const override;
55 const std::vector<std::string> seeAlso() const override;
57
58 const std::string alias() const override;
60
62 const std::string aliasDeprecated() const override;
63
64 const std::string helpURL() const override;
66 bool isRunning() const override;
68 void cancel() override;
70 bool checkGroups() override;
72 std::map<std::string, std::string> validateInputs() override;
74
75 // -- Deprecated methods --
77 void setWikiSummary(const std::string &summary);
78
87 static void declarePyAlgProperty(boost::python::object &self, Kernel::Property *prop, const std::string &doc = "");
90 static void declarePyAlgProperty(boost::python::object &self, const std::string &name,
91 const boost::python::object &defaultValue,
92 const boost::python::object &validator = boost::python::object(),
93 const std::string &doc = "", const int direction = Kernel::Direction::Input);
94
96 static void declarePyAlgProperty(boost::python::object &self, const std::string &name,
97 const boost::python::object &defaultValue, const std::string &doc,
98 const int direction = Kernel::Direction::Input);
99
101 static void declarePyAlgProperty(boost::python::object &self, const std::string &name,
102 const boost::python::object &defaultValue, const int direction);
103
104protected:
109 inline PyObject *getSelf() const { return m_self; }
110
111private:
113 void init() override;
115 void exec() override;
116
118 using SuperClass::declareProperty;
119
121 PyObject *m_self;
123 PyObject *m_isRunningObj;
124
126 std::string m_wikiSummary;
127};
128} // namespace PythonInterface
129} // namespace Mantid
Base class for properties.
Definition: Property.h:94
Provides a layer class for boost::python to allow C++ virtual functions to be overridden in a Python ...
const std::string helpURL() const override
Optional documentation URL of the algorithm, empty string if not overridden.
void setWikiSummary(const std::string &summary)
Set the summary text.
void cancel() override
Allow the cancel method to be overridden.
AlgorithmAdapter(const AlgorithmAdapter &)=delete
Disable copy operator.
PyObject * m_self
The Python portion of the object.
std::string m_wikiSummary
Here for deprecated setWikiSummary method.
std::map< std::string, std::string > validateInputs() override
Returns the validateInputs result of the algorithm.
AlgorithmAdapter()=delete
Disable default constructor - The PyObject must be supplied to construct the object.
const std::string alias() const override
Allow the method returning the algorithm aliases to be overridden.
AlgorithmAdapter & operator=(const AlgorithmAdapter &)=delete
Disable assignment operator.
const std::string name() const override
Returns the name of the algorithm.
PyObject * m_isRunningObj
A pointer to an overridden isRunning method.
bool checkGroups() override
A return of false will allow processing workspace groups as a whole.
const std::string aliasDeprecated() const override
Returns optional documentation URL of the algorithm.
const std::string summary() const override
Returns the summary for the algorithm.
void exec() override
Private exec for this algorithm.
int version() const override
Returns a version of the algorithm.
PyObject * getSelf() const
Returns the PyObject that owns this wrapper, i.e.
const std::vector< std::string > seeAlso() const override
Returns seeAlso related algorithms.
static void declarePyAlgProperty(boost::python::object &self, Kernel::Property *prop, const std::string &doc="")
Declare a preconstructed property.
const std::string category() const override
Returns a category of the algorithm.
void init() override
Private init for this algorithm.
bool isRunning() const override
Allow the isRunning method to be overridden.
Helper class which provides the Collimation Length for SANS instruments.
@ Input
An input workspace.
Definition: Property.h:53