Base::PyObjectBase Class Reference

The PyObjectBase class, exports the class as a python type PyObjectBase is the base class for all C++ classes which need to get exported into the python namespace. More...

#include <PyObjectBase.h>

Public Types

typedef void * PointerType
 
enum  Status { Valid = 0 , Immutable = 1 , Notify = 2 , NoTrack = 3 }
 

Public Member Functions

PyObjectBaseDecRef ()
 decref method wrapper (see python extending manual) More...
 
void * getTwinPointer () const
 Get the pointer of the twin object. More...
 
virtual PyTypeObject * GetType (void)
 
PyObjectBaseIncRef ()
 incref method wrapper (see python extending manual) More...
 
bool isConst ()
 
bool isNotTracking () const
 
bool isValid ()
 
virtual int PyInit (PyObject *, PyObject *)
 PyInit method Override this method to initialize a newly created instance of the class (Constructor) More...
 
 PyObjectBase (void *, PyTypeObject *T)
 Constructor Sets the Type of the object (for inheritance) and decrease the the reference count of the PyObject. More...
 
void setConst ()
 
void setInvalid ()
 
void setNotTracking (bool on=true)
 
void setShouldNotify (bool on)
 
bool shouldNotify () const
 
void startNotify ()
 

Static Public Member Functions

static void PyDestructor (PyObject *P)
 Wrapper for the Python destructor. More...
 

Public Attributes

PyObjectbaseProxy
 

Static Public Attributes

static PyMethodDef Methods []
 
static PyTypeObject Type
 Py_Header struct from python.h. More...
 

Protected Member Functions

void setTwinPointer (void *ptr)
 Overrides the pointer to the twin object. More...
 
virtual ~PyObjectBase ()
 destructor More...
 

Protected Attributes

std::bitset< 32 > StatusBits
 

Detailed Description

The PyObjectBase class, exports the class as a python type PyObjectBase is the base class for all C++ classes which need to get exported into the python namespace.

This class is very important because nearly all important classes in FreeCAD are visible in python for macro recording and automation purpose. The class App::Document is a good expample for an exported class. There are some convenience macros to make it easier to inherit from this class and defining new methods exported to python. PYFUNCDEF_D defines a new exported method. PYFUNCIMP_D defines the implementation of the new exported method. In the implementation you can use Py_Return, Py_Error, Py_Try and Py_Assert. PYMETHODEDEF makes the entry in the python method table.

See also
Document
PYFUNCDEF_D
PYFUNCIMP_D
PYMETHODEDEF
Py_Return
Py_Error
Py_Try
Py_Assert

Member Typedef Documentation

◆ PointerType

Member Enumeration Documentation

◆ Status

Enumerator
Valid 
Immutable 
Notify 
NoTrack 

Constructor & Destructor Documentation

◆ ~PyObjectBase()

PyObjectBase::~PyObjectBase ( )
protectedvirtual

◆ PyObjectBase()

PyObjectBase::PyObjectBase ( void *  p,
PyTypeObject *  T 
)

Constructor Sets the Type of the object (for inheritance) and decrease the the reference count of the PyObject.

References Base::Console(), Base::ConsoleSingleton::Log(), Notify, StatusBits, and Valid.

Member Function Documentation

◆ DecRef()

PyObjectBase * Base::PyObjectBase::DecRef ( )

decref method wrapper (see python extending manual)

◆ getTwinPointer()

void * Base::PyObjectBase::getTwinPointer ( ) const

Get the pointer of the twin object.

◆ GetType()

virtual PyTypeObject * Base::PyObjectBase::GetType ( void  )
virtual

◆ IncRef()

PyObjectBase * Base::PyObjectBase::IncRef ( )

incref method wrapper (see python extending manual)

◆ isConst()

bool Base::PyObjectBase::isConst ( )

◆ isNotTracking()

bool Base::PyObjectBase::isNotTracking ( ) const

◆ isValid()

bool Base::PyObjectBase::isValid ( )

◆ PyDestructor()

static void Base::PyObjectBase::PyDestructor ( PyObject P)
static

Wrapper for the Python destructor.

◆ PyInit()

virtual int Base::PyObjectBase::PyInit ( PyObject ,
PyObject  
)
virtual

PyInit method Override this method to initialize a newly created instance of the class (Constructor)

◆ setConst()

void Base::PyObjectBase::setConst ( )

◆ setInvalid()

void Base::PyObjectBase::setInvalid ( )

◆ setNotTracking()

void Base::PyObjectBase::setNotTracking ( bool  on = true)

◆ setShouldNotify()

void Base::PyObjectBase::setShouldNotify ( bool  on)

◆ setTwinPointer()

void Base::PyObjectBase::setTwinPointer ( void *  ptr)
protected

Overrides the pointer to the twin object.

◆ shouldNotify()

bool Base::PyObjectBase::shouldNotify ( ) const

Referenced by startNotify().

◆ startNotify()

void PyObjectBase::startNotify ( )

References shouldNotify().

Member Data Documentation

◆ baseProxy

PyObject* Base::PyObjectBase::baseProxy

Referenced by ~PyObjectBase().

◆ Methods

PyMethodDef PyObjectBase::Methods
static
Initial value:
= {
{nullptr, nullptr, 0, nullptr}
}

◆ StatusBits

std::bitset<32> Base::PyObjectBase::StatusBits
protected

Referenced by PyObjectBase().

◆ Type


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