Mantid
Loading...
Searching...
No Matches
AlgorithmProperty.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 <boost/python/class.hpp>
11#include <boost/python/make_constructor.hpp>
12
18using namespace boost::python;
19
20namespace {
30AlgorithmProperty *createPropertyWithValidatorAndDirection(const std::string &name, IValidator *validator,
31 unsigned int direction) {
32 return new AlgorithmProperty(name, validator->clone(), direction);
33}
34
42AlgorithmProperty *createPropertyWithValidator(const std::string &name, IValidator *validator) {
43 return createPropertyWithValidatorAndDirection(name, validator, Mantid::Kernel::Direction::Input);
44}
45} // namespace
46
48 // AlgorithmProperty has base PropertyWithValue<std::shared_ptr<IAlgorithm>>
49 // which must be exported
50 using HeldType = std::shared_ptr<IAlgorithm>;
51 PropertyWithValueExporter<HeldType>::define("AlgorithmPropertyWithValue");
52
53 class_<AlgorithmProperty, bases<PropertyWithValue<HeldType>>, boost::noncopyable>("AlgorithmProperty", no_init)
54 .def(init<const std::string &>(args("name")))
55 // These variants require the validator object to be cloned
56 .def("__init__",
57 make_constructor(&createPropertyWithValidator, default_call_policies(), args("name", "validator")))
58 .def("__init__", make_constructor(&createPropertyWithValidatorAndDirection, default_call_policies(),
59 args("name", "validator", "direction")));
60}
void export_AlgorithmProperty()
Define an algorithm property that can be used to supply an algorithm object to a subsequent algorithm...
IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:45
IValidator is the basic interface for all validators for properties.
Definition: IValidator.h:43
virtual IValidator_sptr clone() const =0
Make a copy of the present type of validator.
The concrete, templated class for properties.
@ Input
An input workspace.
Definition: Property.h:53
A helper struct to export PropertyWithValue<> types to Python.
static void define(const char *pythonClassName)