SourceXtractorPlusPlus  0.8
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
SourceXtractor::PyObjectHolder Class Reference

Hold a reference to a Python object. More...

Collaboration diagram for SourceXtractor::PyObjectHolder:
[legend]

Public Member Functions

 PyObjectHolder (py::object &&obj)
 
 PyObjectHolder (const PyObjectHolder &)=default
 
 PyObjectHolder (PyObjectHolder &&)=default
 
 operator const py::object & () const
 
const py::object & operator* () const
 
py::object attr (const char *name)
 

Private Attributes

std::shared_ptr< py::object > m_obj_ptr
 

Detailed Description

Hold a reference to a Python object.

A boost::python::object contains a pointer to the underlying Python struct, which is copied as-is (shared) when copied. When the boost::python::object is destroyed, it checks, and then decrements, the reference count. This destruction is not thread safe, as the pointer is not protected by a mutex or anything. This class holds a single reference to the Python object, and relies on the mechanism of std::shared_ptr to destroy the object once there is no one using it. std::shared_ptr is thread safe, unlike boost::python::object.

Definition at line 80 of file ModelFittingConfig.cpp.

Constructor & Destructor Documentation

SourceXtractor::PyObjectHolder::PyObjectHolder ( py::object &&  obj)
inline

Definition at line 82 of file ModelFittingConfig.cpp.

References std::make_shared().

Here is the call graph for this function:

SourceXtractor::PyObjectHolder::PyObjectHolder ( const PyObjectHolder )
default
SourceXtractor::PyObjectHolder::PyObjectHolder ( PyObjectHolder &&  )
default

Member Function Documentation

py::object SourceXtractor::PyObjectHolder::attr ( const char *  name)
inline

Definition at line 95 of file ModelFittingConfig.cpp.

SourceXtractor::PyObjectHolder::operator const py::object & ( ) const
inline

Definition at line 87 of file ModelFittingConfig.cpp.

const py::object& SourceXtractor::PyObjectHolder::operator* ( ) const
inline

Definition at line 91 of file ModelFittingConfig.cpp.

Member Data Documentation

std::shared_ptr<py::object> SourceXtractor::PyObjectHolder::m_obj_ptr
private

Definition at line 100 of file ModelFittingConfig.cpp.


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