15#include <boost/python/extract.hpp>
16#include <boost/python/object.hpp>
22namespace PythonInterface {
29 :
m_deleter(
boost::python::converter::shared_ptr_deleter(deleter.owner)) {}
39 boost::python::converter::shared_ptr_deleter
m_deleter;
70 object instance = m_classObject();
84 auto instancePtr = extract<std::shared_ptr<Base>>(instance)();
85 auto *deleter = std::get_deleter<converter::shared_ptr_deleter, Base>(instancePtr);
95 throw std::runtime_error(
"Unable to create unwrapped instance of Python object");
The base class for instantiators.
Defines a structure for acquiring/releasing the Python GIL using the RAII pattern.
Base * createUnwrappedInstance() const override
Creates an instance of the object as raw pointer to the Base type.
std::shared_ptr< Base > createInstance() const override
Creates an instance of the object as shared_ptr to the Base type.
PythonObjectInstantiator(const boost::python::object &classObject)
Constructor taking a Python class object wrapped as a boost::python:object.
boost::python::object m_classObject
The class name.
Helper class which provides the Collimation Length for SANS instruments.
Special shared_ptr::deleter object that locks the GIL while deleting the underlying Python object.
GILSharedPtrDeleter(const boost::python::converter::shared_ptr_deleter &deleter)
boost::python::converter::shared_ptr_deleter m_deleter
Main deleter object.
void operator()(void const *data)
Called when the shared_ptr reference count is zero.