Nektar++
Public Member Functions | Protected Attributes | List of all members
NekFactoryRegisterHelper< T > Class Template Reference

Helper class to be used in NekFactory_Register. Stores the Python function used to call the creator function. More...

#include <NekFactory.hpp>

Public Member Functions

 NekFactoryRegisterHelper (py::object obj)
 
 ~NekFactoryRegisterHelper ()=default
 
template<class... Args>
std::shared_ptr< T > create (Args... args)
 Callback to Python instantiator function (typically a class constructor). Assumes that all arguments can be converted to boost.python through converter infrastructure. More...
 

Protected Attributes

py::object m_obj
 Python function that is used to construct objects. More...
 

Detailed Description

template<class T>
class NekFactoryRegisterHelper< T >

Helper class to be used in NekFactory_Register. Stores the Python function used to call the creator function.

Definition at line 72 of file Python/BasicUtils/NekFactory.hpp.

Constructor & Destructor Documentation

◆ NekFactoryRegisterHelper()

template<class T >
NekFactoryRegisterHelper< T >::NekFactoryRegisterHelper ( py::object  obj)
inline

Definition at line 75 of file Python/BasicUtils/NekFactory.hpp.

75 : m_obj(obj)
76 {
77 }
py::object m_obj
Python function that is used to construct objects.

◆ ~NekFactoryRegisterHelper()

template<class T >
NekFactoryRegisterHelper< T >::~NekFactoryRegisterHelper ( )
default

Member Function Documentation

◆ create()

template<class T >
template<class... Args>
std::shared_ptr< T > NekFactoryRegisterHelper< T >::create ( Args...  args)
inline

Callback to Python instantiator function (typically a class constructor). Assumes that all arguments can be converted to boost.python through converter infrastructure.

Definition at line 86 of file Python/BasicUtils/NekFactory.hpp.

87 {
88 // Create an object using the Python callable.
89 py::object inst = m_obj(args...);
90
91 // Assume that it returns an object of the appropriate type.
92 return py::cast<std::shared_ptr<T>>(inst);
93 }

References NekFactoryRegisterHelper< T >::m_obj.

Member Data Documentation

◆ m_obj

template<class T >
py::object NekFactoryRegisterHelper< T >::m_obj
protected

Python function that is used to construct objects.

Definition at line 97 of file Python/BasicUtils/NekFactory.hpp.

Referenced by NekFactoryRegisterHelper< T >::create().