PythonQt
Public Member Functions | Protected Member Functions | List of all members
PythonQtSafeObjectPtr Class Reference

a smart pointer that stores a PyObject pointer and that handles reference counting automatically More...

#include <PythonQtObjectPtr.h>

Public Member Functions

 PythonQtSafeObjectPtr ()
 
 PythonQtSafeObjectPtr (const PythonQtSafeObjectPtr &p)
 
 PythonQtSafeObjectPtr (const PythonQtObjectPtr &p)
 
 PythonQtSafeObjectPtr (PythonQtSafeObjectPtr &&p) noexcept
 rvalue copy constructor, does not need any incref/decref.
 
 PythonQtSafeObjectPtr (PythonQtObjectPtr &&p)
 rvalue copy constructor, does not need any incref/decref.
 
 PythonQtSafeObjectPtr (PyObject *o)
 
 ~PythonQtSafeObjectPtr ()
 
PythonQtSafeObjectPtroperator= (const PythonQtSafeObjectPtr &p)
 
PythonQtSafeObjectPtroperator= (const PythonQtObjectPtr &p)
 
PythonQtSafeObjectPtroperator= (PythonQtSafeObjectPtr &&p) noexcept
 rvalue assignment operator that steals the reference from p
 
PythonQtSafeObjectPtroperator= (PythonQtObjectPtr &&p)
 rvalue assignment operator that steals the reference from p
 
PythonQtSafeObjectPtroperator= (PyObject *o)
 
bool operator== (const PythonQtSafeObjectPtr &p) const
 
bool operator!= (const PythonQtSafeObjectPtr &p) const
 
bool operator== (PyObject *p) const
 
bool operator!= (PyObject *p) const
 
bool isNull () const
 
PyObjectoperator-> () const
 
PyObjectoperator* () const
 
 operator PyObject * () const
 
PyObjectobject () const
 
PyObjecttakeObject ()
 

Protected Member Functions

void setObject (PyObject *o)
 
void setObjectUnsafe (PyObject *o)
 

Detailed Description

a smart pointer that stores a PyObject pointer and that handles reference counting automatically

Definition at line 198 of file PythonQtObjectPtr.h.

Constructor & Destructor Documentation

◆ PythonQtSafeObjectPtr() [1/6]

PythonQtSafeObjectPtr::PythonQtSafeObjectPtr ( )
inline

Definition at line 201 of file PythonQtObjectPtr.h.

202 : _object(nullptr)
203 {
204 }

◆ PythonQtSafeObjectPtr() [2/6]

PythonQtSafeObjectPtr::PythonQtSafeObjectPtr ( const PythonQtSafeObjectPtr p)
inline

Definition at line 206 of file PythonQtObjectPtr.h.

207 : _object(nullptr)
208 {
209 setObject(p.object());
210 }
PyObject * PythonQtConvertPairToPython(const void *inPair, int metaTypeId)
void setObject(PyObject *o)

References PythonQtConvertPairToPython().

◆ PythonQtSafeObjectPtr() [3/6]

PythonQtSafeObjectPtr::PythonQtSafeObjectPtr ( const PythonQtObjectPtr p)
inline

Definition at line 212 of file PythonQtObjectPtr.h.

213 : _object(nullptr)
214 {
215 setObject(p.object());
216 }

References PythonQtConvertPairToPython().

◆ PythonQtSafeObjectPtr() [4/6]

PythonQtSafeObjectPtr::PythonQtSafeObjectPtr ( PythonQtSafeObjectPtr &&  p)
inlinenoexcept

rvalue copy constructor, does not need any incref/decref.

Definition at line 219 of file PythonQtObjectPtr.h.

220 : _object(p._object)
221 {
222 p._object = nullptr;
223 }

References PythonQtConvertPairToPython().

◆ PythonQtSafeObjectPtr() [5/6]

PythonQtSafeObjectPtr::PythonQtSafeObjectPtr ( PythonQtObjectPtr &&  p)
inline

rvalue copy constructor, does not need any incref/decref.

Definition at line 226 of file PythonQtObjectPtr.h.

227 : _object(p.takeObject())
228 {
229 }

◆ PythonQtSafeObjectPtr() [6/6]

PythonQtSafeObjectPtr::PythonQtSafeObjectPtr ( PyObject o)

◆ ~PythonQtSafeObjectPtr()

PythonQtSafeObjectPtr::~PythonQtSafeObjectPtr ( )

Member Function Documentation

◆ isNull()

bool PythonQtSafeObjectPtr::isNull ( ) const
inline

Definition at line 282 of file PythonQtObjectPtr.h.

282{ return !object(); }
PyObject * object() const

◆ object()

PyObject * PythonQtSafeObjectPtr::object ( ) const
inline

Definition at line 290 of file PythonQtObjectPtr.h.

290{ return _object; }

◆ operator PyObject *()

PythonQtSafeObjectPtr::operator PyObject * ( ) const
inline

Definition at line 288 of file PythonQtObjectPtr.h.

288{ return object(); }

◆ operator!=() [1/2]

bool PythonQtSafeObjectPtr::operator!= ( const PythonQtSafeObjectPtr p) const
inline

Definition at line 276 of file PythonQtObjectPtr.h.

276{ return !(*this == p); }

References PythonQtConvertPairToPython().

◆ operator!=() [2/2]

bool PythonQtSafeObjectPtr::operator!= ( PyObject p) const
inline

Definition at line 280 of file PythonQtObjectPtr.h.

280{ return object() != p; }

References PythonQtConvertPairToPython().

◆ operator*()

PyObject & PythonQtSafeObjectPtr::operator* ( ) const
inline

Definition at line 286 of file PythonQtObjectPtr.h.

286{ return *(object()); }

◆ operator->()

PyObject * PythonQtSafeObjectPtr::operator-> ( ) const
inline

Definition at line 284 of file PythonQtObjectPtr.h.

284{ return object(); }

◆ operator=() [1/5]

PythonQtSafeObjectPtr & PythonQtSafeObjectPtr::operator= ( const PythonQtObjectPtr p)
inline

Definition at line 241 of file PythonQtObjectPtr.h.

242 {
243 setObjectUnsafe(p.object());
244 return *this;
245 }
void setObjectUnsafe(PyObject *o)

References PythonQtConvertPairToPython().

◆ operator=() [2/5]

PythonQtSafeObjectPtr & PythonQtSafeObjectPtr::operator= ( const PythonQtSafeObjectPtr p)
inline

Definition at line 235 of file PythonQtObjectPtr.h.

236 {
237 setObject(p.object());
238 return *this;
239 }

References PythonQtConvertPairToPython().

◆ operator=() [3/5]

PythonQtSafeObjectPtr & PythonQtSafeObjectPtr::operator= ( PyObject o)
inline

Definition at line 268 of file PythonQtObjectPtr.h.

269 {
270 setObject(o);
271 return *this;
272 }

References PythonQtConvertPairToPython().

◆ operator=() [4/5]

PythonQtSafeObjectPtr & PythonQtSafeObjectPtr::operator= ( PythonQtObjectPtr &&  p)
inline

rvalue assignment operator that steals the reference from p

Definition at line 259 of file PythonQtObjectPtr.h.

260 {
261 if (_object) {
262 setObjectUnsafe(nullptr);
263 }
264 _object = p.takeObject();
265 return *this;
266 }

References PythonQtConvertPairToPython().

◆ operator=() [5/5]

PythonQtSafeObjectPtr & PythonQtSafeObjectPtr::operator= ( PythonQtSafeObjectPtr &&  p)
inlinenoexcept

rvalue assignment operator that steals the reference from p

Definition at line 248 of file PythonQtObjectPtr.h.

249 {
250 if (_object) {
251 setObject(nullptr);
252 }
253 _object = p._object;
254 p._object = nullptr;
255 return *this;
256 }

References PythonQtConvertPairToPython().

◆ operator==() [1/2]

bool PythonQtSafeObjectPtr::operator== ( const PythonQtSafeObjectPtr p) const
inline

Definition at line 274 of file PythonQtObjectPtr.h.

274{ return object() == p.object(); }

References PythonQtConvertPairToPython().

◆ operator==() [2/2]

bool PythonQtSafeObjectPtr::operator== ( PyObject p) const
inline

Definition at line 278 of file PythonQtObjectPtr.h.

278{ return object() == p; }

References PythonQtConvertPairToPython().

◆ setObject()

void PythonQtSafeObjectPtr::setObject ( PyObject o)
protected

◆ setObjectUnsafe()

void PythonQtSafeObjectPtr::setObjectUnsafe ( PyObject o)
protected

◆ takeObject()

PyObject * PythonQtSafeObjectPtr::takeObject ( )
inline

takes the object from the pointer, leaving the pointer empty. the caller has to take care about the decref of the taken object!

Definition at line 294 of file PythonQtObjectPtr.h.

295 {
296 PyObject* o = _object;
297 _object = nullptr;
298 return o;
299 }
struct _object PyObject

References PythonQtConvertPairToPython().


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