MUQ  0.4.3
muq::Modeling::SwigExtract Class Reference

Class to extract a c++ class that was exposed to python with Swig. @detials This class is used to unwrap a c++ class that was exposed to python with Swig and then passed to MUQ through pybind11 bindings. The class is defined in a way to enable straightforward conversions with code like. More...

#include <SwigExtract.h>

Detailed Description

Class to extract a c++ class that was exposed to python with Swig. @detials This class is used to unwrap a c++ class that was exposed to python with Swig and then passed to MUQ through pybind11 bindings. The class is defined in a way to enable straightforward conversions with code like.

pybind11::object pyObject = ... ;
std::shared_ptr<CppClass> cppPtr = SwigExtract(pyObject);
SwigExtract(pybind11::object const &objIn)
Definition: SwigExtract.h:39

Instead of using the implicit conversion, it is also possible to explicitly cast the python object:

pybind11::object pyObject = ... ;
SwigExtract extractor(pyObject);
std::shared_ptr<CppClass> cppPtr = extractor.Cast<std::shared_pointer<CppClass>>();

Definition at line 35 of file SwigExtract.h.

Public Member Functions

 SwigExtract (pybind11::object const &objIn)
 
template<typename T >
 operator T ()
 
template<typename T >
Cast ()
 

Constructor & Destructor Documentation

◆ SwigExtract()

muq::Modeling::SwigExtract::SwigExtract ( pybind11::object const &  objIn)
inline

Definition at line 39 of file SwigExtract.h.

Member Function Documentation

◆ Cast()

template<typename T >
T muq::Modeling::SwigExtract::Cast ( )
inline

Definition at line 48 of file SwigExtract.h.

References obj.

Referenced by muq::Modeling::FenicsPiece::EvaluateFunc().

◆ ConversionError()

template<typename T >
void muq::Modeling::SwigExtract::ConversionError ( )
inlineprivate

Definition at line 76 of file SwigExtract.h.

References obj.

◆ operator T()

template<typename T >
muq::Modeling::SwigExtract::operator T ( )
inline

Definition at line 42 of file SwigExtract.h.

Member Data Documentation

◆ obj

pybind11::object const& muq::Modeling::SwigExtract::obj
private

Definition at line 73 of file SwigExtract.h.

Referenced by Cast(), and ConversionError().


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