SourceForge.net Logo
PythonQt
Public Member Functions | Public Attributes | List of all members
PythonQtInstanceWrapperStruct Struct Reference

a Python wrapper object for Qt objects and C++ objects (that are themselves wrapped by wrapper QObjects) More...

#include <PythonQtInstanceWrapper.h>

Public Member Functions

PyObject_HEAD PythonQtClassInfoclassInfo ()
 the class information, this is set even if the _obj or _wrappedPtr is NULL to support typed NULL pointers More...
 
PythonQtDynamicClassInfodynamicClassInfo ()
 
void setQObject (QObject *object)
 set the QObject pointer More...
 
void passOwnershipToCPP ()
 Passes the ownership of the wrapped object to C++. More...
 
void passOwnershipToPython ()
 Passes the ownership to Python. More...
 

Public Attributes

QPointer< QObject > _obj
 pointer to the wrapped Qt object or if _wrappedPtr is set, the Qt object that wraps the C++ Ptr More...
 
void * _objPointerCopy
 
void * _wrappedPtr
 optional C++ object Ptr that is wrapped by the above _obj More...
 
bool _ownedByPythonQt
 flag that stores if the object is owned by pythonQt More...
 
bool _useQMetaTypeDestroy
 stores that the owned object should be destroyed using QMetaType::destroy() More...
 
bool _isShellInstance
 stores if the object is a shell instance More...
 
bool _shellInstanceRefCountsWrapper
 stores if the shell instance (C++) owns the wrapper with its ref count More...
 

Detailed Description

a Python wrapper object for Qt objects and C++ objects (that are themselves wrapped by wrapper QObjects)

Definition at line 63 of file PythonQtInstanceWrapper.h.

Member Function Documentation

PyObject_HEAD PythonQtClassInfo* PythonQtInstanceWrapperStruct::classInfo ( )
inline

the class information, this is set even if the _obj or _wrappedPtr is NULL to support typed NULL pointers

Definition at line 67 of file PythonQtInstanceWrapper.h.

68  { return ((PythonQtClassWrapper*)Py_TYPE(this))->_classInfo; }
PythonQtDynamicClassInfo* PythonQtInstanceWrapperStruct::dynamicClassInfo ( )
inline

Definition at line 70 of file PythonQtInstanceWrapper.h.

71  { return ((PythonQtClassWrapper*)Py_TYPE(this))->_dynamicClassInfo; }
void PythonQtInstanceWrapperStruct::passOwnershipToCPP ( )
inline

Passes the ownership of the wrapped object to C++.

Definition at line 80 of file PythonQtInstanceWrapper.h.

References _isShellInstance, _ownedByPythonQt, and _shellInstanceRefCountsWrapper.

80  {
81  // we pass the ownership to C++
82  _ownedByPythonQt = false;
83  // handle shell instance
84  if (_isShellInstance) {
86  // ref count the wrapper, so that the Python part of the shell instance can not go
87  // away until the C++ object gets deleted...
88  Py_INCREF((PyObject*)this);
90  }
91  }
92  }
bool _isShellInstance
stores if the object is a shell instance
bool _ownedByPythonQt
flag that stores if the object is owned by pythonQt
struct _object PyObject
bool _shellInstanceRefCountsWrapper
stores if the shell instance (C++) owns the wrapper with its ref count
void PythonQtInstanceWrapperStruct::passOwnershipToPython ( )
inline

Passes the ownership to Python.

Definition at line 95 of file PythonQtInstanceWrapper.h.

References _ownedByPythonQt, and _shellInstanceRefCountsWrapper.

95  {
96  _ownedByPythonQt = true;
97  // if the shell instance was owned by C++ and the ownership goes to Python,
98  // we need to remove the extra ref count that kept the Python part alive from the C++ side.
100  Py_DECREF((PyObject*)this);
102  }
103  }
bool _ownedByPythonQt
flag that stores if the object is owned by pythonQt
struct _object PyObject
bool _shellInstanceRefCountsWrapper
stores if the shell instance (C++) owns the wrapper with its ref count
void PythonQtInstanceWrapperStruct::setQObject ( QObject *  object)
inline

set the QObject pointer

Definition at line 74 of file PythonQtInstanceWrapper.h.

References _obj, and _objPointerCopy.

74  {
75  _obj = object;
76  _objPointerCopy = object;
77  }
QPointer< QObject > _obj
pointer to the wrapped Qt object or if _wrappedPtr is set, the Qt object that wraps the C++ Ptr ...

Member Data Documentation

bool PythonQtInstanceWrapperStruct::_isShellInstance

stores if the object is a shell instance

Definition at line 124 of file PythonQtInstanceWrapper.h.

Referenced by passOwnershipToCPP().

QPointer<QObject> PythonQtInstanceWrapperStruct::_obj

pointer to the wrapped Qt object or if _wrappedPtr is set, the Qt object that wraps the C++ Ptr

Definition at line 107 of file PythonQtInstanceWrapper.h.

Referenced by setQObject().

void* PythonQtInstanceWrapperStruct::_objPointerCopy

a copy of the _obj pointer, which is required because the wrapper needs to deregister itself via the _obj pointer, even when the QPointer<QObject> object was destroyed

Definition at line 110 of file PythonQtInstanceWrapper.h.

Referenced by setQObject().

bool PythonQtInstanceWrapperStruct::_ownedByPythonQt

flag that stores if the object is owned by pythonQt

Definition at line 118 of file PythonQtInstanceWrapper.h.

Referenced by passOwnershipToCPP(), passOwnershipToPython(), and PythonQtConvertListOfKnownClassToPythonList().

bool PythonQtInstanceWrapperStruct::_shellInstanceRefCountsWrapper

stores if the shell instance (C++) owns the wrapper with its ref count

Definition at line 127 of file PythonQtInstanceWrapper.h.

Referenced by passOwnershipToCPP(), and passOwnershipToPython().

bool PythonQtInstanceWrapperStruct::_useQMetaTypeDestroy

stores that the owned object should be destroyed using QMetaType::destroy()

Definition at line 121 of file PythonQtInstanceWrapper.h.

void* PythonQtInstanceWrapperStruct::_wrappedPtr

optional C++ object Ptr that is wrapped by the above _obj

Definition at line 113 of file PythonQtInstanceWrapper.h.


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