Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Mantid::PythonInterface::PythonObjectInstantiator< Base > Class Template Reference

#include <PythonObjectInstantiator.h>

Inheritance diagram for Mantid::PythonInterface::PythonObjectInstantiator< Base >:
Mantid::Kernel::AbstractInstantiator< Base >

Public Member Functions

std::shared_ptr< IFunctioncreateInstance () const
 Specialization for IFunction. More...
 
std::shared_ptr< Base > createInstance () const override
 Creates an instance of the object as shared_ptr to the Base type. More...
 
Base * createUnwrappedInstance () const override
 Creates an instance of the object as raw pointer to the Base type. More...
 
 PythonObjectInstantiator (const boost::python::object &classObject)
 Constructor taking a Python class object wrapped as a boost::python:object. More...
 
- Public Member Functions inherited from Mantid::Kernel::AbstractInstantiator< Base >
 AbstractInstantiator ()=default
 Creates the AbstractInstantiator. More...
 
virtual std::shared_ptr< Base > createInstance (Args... args) const=0
 Creates an instance of a concrete subclass of Base. More...
 
virtual Base * createUnwrappedInstance (Args... args) const=0
 Creates an instance of a concrete subclass of Base, which is not wrapped in a shared_ptr. More...
 
virtual ~AbstractInstantiator ()=default
 Destroys the AbstractInstantiator. More...
 

Private Attributes

boost::python::object m_classObject
 The class name. More...
 

Detailed Description

template<typename Base>
class Mantid::PythonInterface::PythonObjectInstantiator< Base >
Template Parameters
BaseA pointer to the C++ type that is stored in within the created python object

Definition at line 46 of file PythonObjectInstantiator.h.

Constructor & Destructor Documentation

◆ PythonObjectInstantiator()

template<typename Base >
Mantid::PythonInterface::PythonObjectInstantiator< Base >::PythonObjectInstantiator ( const boost::python::object &  classObject)
inline

Constructor taking a Python class object wrapped as a boost::python:object.

Definition at line 49 of file PythonObjectInstantiator.h.

Member Function Documentation

◆ createInstance() [1/2]

std::shared_ptr< IFunction > Mantid::PythonInterface::PythonObjectInstantiator< IFunction >::createInstance ( ) const

Specialization for IFunction.

Fit functions defined in python need to be wrapped in FunctionWrapper without asking the user to do additional actions. The instantiator lets the fit function class object know that an instance will be created by the FunctionFactory and it needs to be a subclass of IFunction and not a FunctionWrapper.

Definition at line 50 of file FunctionFactory.cpp.

◆ createInstance() [2/2]

template<typename Base >
std::shared_ptr< Base > Mantid::PythonInterface::PythonObjectInstantiator< Base >::createInstance
override

Creates an instance of the object as shared_ptr to the Base type.

Returns
A shared_ptr to Base.

Definition at line 66 of file PythonObjectInstantiator.h.

◆ createUnwrappedInstance()

template<typename Base >
Base * Mantid::PythonInterface::PythonObjectInstantiator< Base >::createUnwrappedInstance
override

Creates an instance of the object as raw pointer to the Base type.

Exceptions
std::runtime_erroras we're unable to extract a non-shared ptr from the wrapped object

Definition at line 94 of file PythonObjectInstantiator.h.

Member Data Documentation

◆ m_classObject

template<typename Base >
boost::python::object Mantid::PythonInterface::PythonObjectInstantiator< Base >::m_classObject
private

The class name.

Definition at line 59 of file PythonObjectInstantiator.h.


The documentation for this class was generated from the following file: