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#else
40#endif
41} // namespace Mantid::Kernel
42
44
49
51public:
52 // Convenience typedefs
55
58
65 PythonObjectProperty(std::string const &name, PythonObject const &defaultValue,
66 IValidator_sptr const &validator = std::make_shared<NullValidator>(),
67 unsigned int const direction = Direction::Input)
68 : BaseClass(name, defaultValue, validator, direction) {}
69
75 PythonObjectProperty(std::string const &name, PythonObject const &defaultValue,
76 unsigned int const direction = Direction::Input)
77 : BaseClass(name, defaultValue, std::make_shared<NullValidator>(), direction) {}
78
85 PythonObjectProperty(std::string const &name, IValidator_sptr const &validator,
86 unsigned int const direction = Direction::Input)
87 : BaseClass(name, PythonObject(), validator, direction) {}
88
94 PythonObjectProperty(std::string const &name, unsigned int const direction = Direction::Input)
95 : BaseClass(name, PythonObject(), std::make_shared<NullValidator>(), direction) {}
96
104 PythonObjectProperty(std::string const &name, std::string const &strvalue,
105 IValidator_sptr const &validator = std::make_shared<NullValidator>(),
106 unsigned int const direction = Direction::Input)
107 : BaseClass(name, PythonObject(), strvalue, validator, direction) {}
108
111
113 PythonObjectProperty *clone() const override { return new PythonObjectProperty(*this); }
114
115 // Unhide the base class assignment operator
116 using BaseClass::operator=;
117
118 std::string getDefault() const override;
119 std::string setValue(PythonObject const &obj);
120 std::string setValue(std::string const &value) override;
121 std::string setValueFromJson(Json::Value const &value) override;
122 std::string setDataItem(std::shared_ptr<Kernel::DataItem> const &value) override;
123 bool isDefault() const override;
124};
125
126} // 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