QPy
Python-Qt dynamic bindings
 All Classes Namespaces Files Functions
Public Member Functions | Protected Member Functions
qpy::PyArgConstructor Class Reference

Abstract base class for return constructors which create PyObjects from C++ values. More...

#include <PyArgConstructor.h>

Inheritance diagram for qpy::PyArgConstructor:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual PyObject * Create () const =0
 Create PyObject from value returned from QObject method.
virtual PyObject * Create (void *) const =0
 Create PyObject from parameter passed to Python callback from Qt when signal triggered.
virtual ~PyArgConstructor ()
 Virtual destructor.
virtual PyArgConstructorClone () const =0
 Return copy of object.
virtual QMetaType::Type Type () const =0
 Return type of constructed data.
QGenericReturnArgument Argument () const
 Return QGenericReturnArguments holding a reference to the memory location where the returned value is stored.
virtual bool IsQObjectPtr () const =0
 Return true if type is a pointer to a QObject-derived object.

Protected Member Functions

template<typename T >
void SetArg (T &arg)
 Creates return argument of the proper type.

Detailed Description

Abstract base class for return constructors which create PyObjects from C++ values.

There are two cases where data need to converted from Qt-C++ to Python:

  1. Python function/method invocation as a result of Qt signal triggered
  2. Return value of Qt-C++ method invoked from Python

In the case of (1) each parameter is directly converted to its Python format; in the case of (2) the return value must first be stored into a memory location passed to the method invocation function, and then be converted into Python format.


Member Function Documentation

virtual bool qpy::PyArgConstructor::IsQObjectPtr ( ) const [pure virtual]

Return true if type is a pointer to a QObject-derived object.

This is required to have the QPy run-time add the passed QObject into the Python context. The other option is to have PyArgConstructors::Create receive a reference to a PyContext which introduces a two-way dependency between PyArgConstructor and PyContext; this would also augment PyQArgConstructor requirements with the added responsibility of having to add instances to Python. Note that it is not enough to simply check the PyArgConstructor returned Type(), because in the case of custom registered types derived from QObject the returned type is not QObjectStar.

Implemented in qpy::ObjectStarPyArgConstructor, qpy::VoidPyArgConstructor, qpy::FloatPyArgConstructor, qpy::DoublePyArgConstructor, qpy::StringPyArgConstructor, qpy::IntPyArgConstructor, and qpy::NoPyArgConstructor.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions