Mantid
Loading...
Searching...
No Matches
PythonObjectTypeHandler.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 +
7//-----------------------------------------------------------------------------
8// Includes
9//-----------------------------------------------------------------------------
13#include <boost/python/extract.hpp>
14
16
28std::unique_ptr<Kernel::Property> PythonObjectTypeHandler::create(std::string const &name,
29 boost::python::object const &defaultValue,
30 boost::python::object const &validator,
31 const unsigned int direction) const {
32 using boost::python::extract;
34
35 std::unique_ptr<Kernel::Property> valueProp;
36 if (isNone(validator)) {
37 valueProp = std::make_unique<PythonObjectProperty>(name, defaultValue, direction);
38 } else {
39 const IValidator *propValidator = extract<IValidator *>(validator);
40 valueProp = std::make_unique<PythonObjectProperty>(name, defaultValue, propValidator->clone(), direction);
41 }
42 return valueProp;
43}
44
45} // namespace Mantid::PythonInterface::Registry
std::string name
Definition Run.cpp:60
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.
bool isNone(const PyObject *ptr)
Definition IsNone.h:26
std::unique_ptr< Kernel::Property > create(std::string const &name, boost::python::object const &defaultValue, boost::python::object const &validator, unsigned int const direction) const override
Call to create a named property where the value is some container type.