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 +
11#include <boost/python/class.hpp>
12#include <boost/python/make_constructor.hpp>
13
19using namespace boost::python;
20
21namespace {
31AlgorithmProperty *createPropertyWithValidatorAndDirection(const std::string &name, IValidator const *validator,
32 unsigned int direction) {
33 return new AlgorithmProperty(name, validator->clone(), direction);
34}
35
43AlgorithmProperty *createPropertyWithValidator(const std::string &name, IValidator const *validator) {
44 return createPropertyWithValidatorAndDirection(name, validator, Mantid::Kernel::Direction::Input);
45}
46} // namespace
47
49 // AlgorithmProperty has base PropertyWithValue<std::shared_ptr<IAlgorithm>>
50 // which must be exported
51 using HeldType = std::shared_ptr<IAlgorithm>;
52 PropertyWithValueExporter<HeldType>::define("AlgorithmPropertyWithValue");
53
54 class_<AlgorithmProperty, bases<PropertyWithValue<HeldType>>, boost::noncopyable>("AlgorithmProperty", no_init)
55 .def(init<const std::string &>(args("name")))
56 // These variants require the validator object to be cloned
57 .def("__init__",
58 make_constructor(&createPropertyWithValidator, default_call_policies(), args("name", "validator")))
59 .def("__init__", make_constructor(&createPropertyWithValidatorAndDirection, default_call_policies(),
60 args("name", "validator", "direction")));
61}
std::string name
Definition Run.cpp: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:46
IValidator is the basic interface for all validators for properties.
Definition IValidator.h:37
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:54
A helper struct to export PropertyWithValue<> types to Python.