The PyHandler class This class is the base class of all FreeCAD classes which exports into the python space. More...
#include <PyExport.h>
Public Member Functions | |
PyObject * | getPyObject () const |
returns the type as PyObject More... | |
bool | IsNull () const |
Test if it not handles something. More... | |
bool | IsValid () const |
Test if it handles something. More... | |
HandledType & | operator* () |
dereference operators More... | |
const HandledType & | operator* () const |
dereference operators More... | |
HandledType * | operator-> () |
dereference operators More... | |
const HandledType * | operator-> () const |
dereference operators More... | |
bool | operator< (const PyHandle< HandledType > &other) const |
lower operator needed for sorting in maps and sets More... | |
PyHandle< HandledType > & | operator= (const PyHandle< HandledType > &other) |
PyHandle< HandledType > & | operator= (HandledType *other) |
bool | operator== (const PyHandle< HandledType > &other) const |
equal operator More... | |
PyHandle (const PyHandle< HandledType > &ToHandle) | |
Copy constructor. More... | |
PyHandle (HandledType *ToHandle=0L) | |
pointer and default constructor the good way would be not using pointer instead using a overwritten new operator in the HandledType class! But is not easy to enforce! More... | |
~PyHandle () | |
destructor Release the reference count which cause, if was the last one, the referenced object to destruct! More... | |
The PyHandler class This class is the base class of all FreeCAD classes which exports into the python space.
This class handles the creation referencing of the python export object.
E.g. if GetPyObject() always returns a new Python object then no increment is necessary, because at construction time the reference counter is already set to 1. If the Python interpreter stores this object pointer into a local variable and destroys this variable then the reference counter gets decremented (to 0) and the object gets destroyed automatically. In case we didn't make this specification and increment the Python object from outside once again then the reference counter would be set to 2 and there would be no chance to destroy the object again.
The other case is that we have a member variable in our C++ class that holds the Python object then we either can create this Python in the constructor or create it the first time when GetPyObject() gets called. In the destructor then we must decrement the Python object to avoid a memory leak while GetPyObject() then increments the Python object every time it gets called.
Base::PyHandle< HandledType >::PyHandle | ( | HandledType * | ToHandle = 0L | ) |
pointer and default constructor the good way would be not using pointer instead using a overwritten new operator in the HandledType class! But is not easy to enforce!
Base::PyHandle< HandledType >::PyHandle | ( | const PyHandle< HandledType > & | ToHandle | ) |
Copy constructor.
Base::PyHandle< HandledType >::~PyHandle | ( | ) |
destructor Release the reference count which cause, if was the last one, the referenced object to destruct!
PyObject * Base::PyHandle< HandledType >::getPyObject | ( | void | ) | const |
returns the type as PyObject
References Base::PyHandle< HandledType >::getPyObject().
Referenced by Base::PyHandle< HandledType >::getPyObject().
bool Base::PyHandle< HandledType >::IsNull | ( | ) | const |
Test if it not handles something.
bool Base::PyHandle< HandledType >::IsValid | ( | ) | const |
Test if it handles something.
HandledType & Base::PyHandle< HandledType >::operator* | ( | ) |
dereference operators
const HandledType & Base::PyHandle< HandledType >::operator* | ( | ) | const |
dereference operators
HandledType * Base::PyHandle< HandledType >::operator-> | ( | ) |
dereference operators
const HandledType * Base::PyHandle< HandledType >::operator-> | ( | ) | const |
dereference operators
bool Base::PyHandle< HandledType >::operator< | ( | const PyHandle< HandledType > & | other | ) | const |
lower operator needed for sorting in maps and sets
PyHandle< HandledType > & Base::PyHandle< HandledType >::operator= | ( | const PyHandle< HandledType > & | other | ) |
PyHandle< HandledType > & Base::PyHandle< HandledType >::operator= | ( | HandledType * | other | ) |
bool Base::PyHandle< HandledType >::operator== | ( | const PyHandle< HandledType > & | other | ) | const |
equal operator