Mantid
Loading...
Searching...
No Matches
PythonObjectProperty.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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//----------------------------------------------------------------------
13
17
18#include <boost/python/object.hpp>
19
20// forward declare
21namespace Json {
22class Value;
23}
24
25namespace Mantid::Kernel {
26using PythonObject = boost::python::object;
27
28#if !defined(__APPLE__) && !(defined(__linux__) && defined(__clang__))
36// Instantiate a copy of the class with our template type so we generate the symbols for the methods in the hxx header.
38#endif
39} // namespace Mantid::Kernel
40
42
47
49public:
50 // Convenience typedefs
53
56
63 PythonObjectProperty(std::string const &name, PythonObject const &defaultValue,
64 IValidator_sptr const &validator = std::make_shared<NullValidator>(),
65 unsigned int const direction = Direction::Input)
66 : BaseClass(name, defaultValue, validator, direction) {}
67
73 PythonObjectProperty(std::string const &name, PythonObject const &defaultValue,
74 unsigned int const direction = Direction::Input)
75 : BaseClass(name, defaultValue, std::make_shared<NullValidator>(), direction) {}
76
83 PythonObjectProperty(std::string const &name, IValidator_sptr const &validator,
84 unsigned int const direction = Direction::Input)
85 : BaseClass(name, PythonObject(), validator, direction) {}
86
92 PythonObjectProperty(std::string const &name, unsigned int const direction = Direction::Input)
93 : BaseClass(name, PythonObject(), std::make_shared<NullValidator>(), direction) {}
94
102 PythonObjectProperty(std::string const &name, std::string const &strvalue,
103 IValidator_sptr const &validator = std::make_shared<NullValidator>(),
104 unsigned int const direction = Direction::Input)
105 : BaseClass(name, PythonObject(), strvalue, validator, direction) {}
106
109
111 PythonObjectProperty *clone() const override { return new PythonObjectProperty(*this); }
112
113 // Unhide the base class assignment operator
114 using BaseClass::operator=;
115
116 std::string getDefault() const override;
117 std::string setValue(PythonObject const &obj);
118 std::string setValue(std::string const &value) override;
119 std::string setValueFromJson(Json::Value const &value) override;
120 std::string setDataItem(std::shared_ptr<Kernel::DataItem> const &value) override;
121 bool isDefault() const override;
122};
123
124} // namespace Mantid::PythonInterface
std::string name
Definition Run.cpp:60
double value
The value of the point.
Definition FitMW.cpp:51
double obj
the value of the quadratic function
NullValidator is a validator that doesn't.
The concrete, templated class for properties.
PythonObjectProperty(std::string const &name, PythonObject const &defaultValue, unsigned int const direction=Direction::Input)
Constructor that's useful for output properties or inputs with non-None default and no validator.
PythonObjectProperty(std::string const &name, std::string const &strvalue, IValidator_sptr const &validator=std::make_shared< NullValidator >(), unsigned int const direction=Direction::Input)
Constructor from which you can set the property's values through a string:
PythonObjectProperty(std::string const &name, PythonObject const &defaultValue, IValidator_sptr const &validator=std::make_shared< NullValidator >(), unsigned int const direction=Direction::Input)
Constructor.
PythonObjectProperty()=delete
No default constructor.
PythonObjectProperty(PythonObjectProperty const &other)
Copy constructor.
PythonObjectProperty * clone() const override
This is required by Property interface.
PythonObjectProperty(std::string const &name, unsigned int const direction=Direction::Input)
Constructor that's useful for output properties or inputs with default value None and no validator.
PythonObjectProperty(std::string const &name, IValidator_sptr const &validator, unsigned int const direction=Direction::Input)
Constructor Will lead to the property having default value of None.
#define MANTID_PYTHONINTERFACE_CORE_DLL
Definition DllConfig.h:17
boost::python::object PythonObject
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.
Definition IValidator.h:26
STL namespace.
Describes the direction (within an algorithm) of a Property.
Definition Property.h:50