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 197 of file PythonQtObjectPtr.h.

Constructor & Destructor Documentation

◆ PythonQtSafeObjectPtr() [1/6]

PythonQtSafeObjectPtr::PythonQtSafeObjectPtr ( )
inline

Definition at line 200 of file PythonQtObjectPtr.h.

200:_object(nullptr) {}

◆ PythonQtSafeObjectPtr() [2/6]

PythonQtSafeObjectPtr::PythonQtSafeObjectPtr ( const PythonQtSafeObjectPtr p)
inline

Definition at line 202 of file PythonQtObjectPtr.h.

203 :_object(nullptr) {
204 setObject(p.object());
205 }
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 207 of file PythonQtObjectPtr.h.

208 :_object(nullptr) {
209 setObject(p.object());
210 }

References PythonQtConvertPairToPython().

◆ PythonQtSafeObjectPtr() [4/6]

PythonQtSafeObjectPtr::PythonQtSafeObjectPtr ( PythonQtSafeObjectPtr &&  p)
inlinenoexcept

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

Definition at line 213 of file PythonQtObjectPtr.h.

214 :_object(p._object) {
215 p._object = nullptr;
216 }

References PythonQtConvertPairToPython().

◆ PythonQtSafeObjectPtr() [5/6]

PythonQtSafeObjectPtr::PythonQtSafeObjectPtr ( PythonQtObjectPtr &&  p)
inline

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

Definition at line 219 of file PythonQtObjectPtr.h.

220 :_object(p.takeObject()) {
221 }

◆ PythonQtSafeObjectPtr() [6/6]

PythonQtSafeObjectPtr::PythonQtSafeObjectPtr ( PyObject o)

◆ ~PythonQtSafeObjectPtr()

PythonQtSafeObjectPtr::~PythonQtSafeObjectPtr ( )

Member Function Documentation

◆ isNull()

bool PythonQtSafeObjectPtr::isNull ( ) const
inline

Definition at line 277 of file PythonQtObjectPtr.h.

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

◆ object()

PyObject * PythonQtSafeObjectPtr::object ( ) const
inline

Definition at line 285 of file PythonQtObjectPtr.h.

285 {
286 return _object;
287 }

◆ operator PyObject *()

PythonQtSafeObjectPtr::operator PyObject * ( ) const
inline

Definition at line 283 of file PythonQtObjectPtr.h.

283{ return object(); }

◆ operator!=() [1/2]

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

Definition at line 265 of file PythonQtObjectPtr.h.

265 {
266 return !(*this == p);
267 }

References PythonQtConvertPairToPython().

◆ operator!=() [2/2]

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

Definition at line 273 of file PythonQtObjectPtr.h.

273 {
274 return object() != p;
275 }

References PythonQtConvertPairToPython().

◆ operator*()

PyObject & PythonQtSafeObjectPtr::operator* ( ) const
inline

Definition at line 281 of file PythonQtObjectPtr.h.

281{ return *(object()); }

◆ operator->()

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

Definition at line 279 of file PythonQtObjectPtr.h.

279{ return object(); }

◆ operator=() [1/5]

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

Definition at line 232 of file PythonQtObjectPtr.h.

232 {
233 setObjectUnsafe(p.object());
234 return *this;
235 }
void setObjectUnsafe(PyObject *o)

References PythonQtConvertPairToPython().

◆ operator=() [2/5]

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

Definition at line 227 of file PythonQtObjectPtr.h.

227 {
228 setObject(p.object());
229 return *this;
230 }

References PythonQtConvertPairToPython().

◆ operator=() [3/5]

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

Definition at line 256 of file PythonQtObjectPtr.h.

256 {
257 setObject(o);
258 return *this;
259 }

References PythonQtConvertPairToPython().

◆ operator=() [4/5]

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

rvalue assignment operator that steals the reference from p

Definition at line 248 of file PythonQtObjectPtr.h.

248 {
249 if (_object) {
250 setObjectUnsafe(nullptr);
251 }
252 _object = p.takeObject();
253 return *this;
254 }

References PythonQtConvertPairToPython().

◆ operator=() [5/5]

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

rvalue assignment operator that steals the reference from p

Definition at line 238 of file PythonQtObjectPtr.h.

238 {
239 if (_object) {
240 setObject(nullptr);
241 }
242 _object = p._object;
243 p._object = nullptr;
244 return *this;
245 }

References PythonQtConvertPairToPython().

◆ operator==() [1/2]

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

Definition at line 261 of file PythonQtObjectPtr.h.

261 {
262 return object() == p.object();
263 }

References PythonQtConvertPairToPython().

◆ operator==() [2/2]

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

Definition at line 269 of file PythonQtObjectPtr.h.

269 {
270 return object() == p;
271 }

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 291 of file PythonQtObjectPtr.h.

291 {
292 PyObject* o = _object;
293 _object = nullptr;
294 return o;
295 }
struct _object PyObject

References PythonQtConvertPairToPython().


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