itom
Loading...
Searching...
No Matches
ito::PythonQtSignalTarget Class Reference

Public Member Functions

 PythonQtSignalTarget ()
 empty constructor
 
 PythonQtSignalTarget (IntList &argTypeList, int slotId, int signalId, PyObject *callable, const char *signal, int minRepeatInterval)
 constructor
 
 PythonQtSignalTarget (const PythonQtSignalTarget &copy)
 copy constructor
 
 ~PythonQtSignalTarget ()
 destructor
 
PythonQtSignalTargetoperator= (const PythonQtSignalTarget &rhs)
 assignment operator
 
int signalId () const
 gets the id of the original signal
 
int slotId () const
 gets the id that was assigned to this simulated slot
 
void call (void **arguments)
 invokes the python method or function
 
IntList argTypeList () const
 returns list of type-numbers of arguments
 
bool isSame (int signalId, PyObject *callable) const
 Compares this signal target with given values.
 

Private Types

enum  CallableType { Callable_Invalid , Callable_Method , Callable_Function , Callable_CFunction }
 

Private Attributes

int m_slotId
 index of this slot
 
int m_signalId
 index of the connected signal
 
IntList m_argTypeList
 type id's from QMetaType::type("..."), describing the arguments of the function-call
 
PyObject * m_function
 
PyObject * m_boundedInstance
 weak reference to the python-class instance of the function (if the function is bounded) or NULL if the function is unbounded
 
CallableType m_callableType
 type of the python callable (see CallableType)
 
QString m_signalName
 signature of the signal (mainly used for debugging reasons)
 
QElapsedTimer m_elapsedTimer
 see m_minRepeatInterval
 
int m_minRepeatInterval
 

Member Enumeration Documentation

◆ CallableType

Enumerator
Callable_Invalid 

the callable is invalid

class method (written in python), the function is stored in m_function, the self object is stored in m_boundedInstance

Callable_Method 

unbounded python method, the function is stored in m_function, m_boundedInstance is NULL

Callable_Function 

function, written in C, stored in m_function. m_boundedInstance is NULL, since the potential self object is also contained in the CFunction object

Constructor & Destructor Documentation

◆ PythonQtSignalTarget()

ito::PythonQtSignalTarget::PythonQtSignalTarget ( IntList & argTypeList,
int slotId,
int signalId,
PyObject * callable,
const char * signal,
int minRepeatInterval )

constructor

Constructs the virtual slot as target for any signal. If this slot is invoked, the given python method is executed.

If the python method is a method (hence bounded), both a weak reference of the method and its containing instance is stored. If it is an unbounded function, only the weak reference to the function is saved.

Parameters
[in]argTypeListis a list of integer-based type number, describing the type of each argument as given by QMetaType
[in]slotIdis the assigned index for this slot (must be unique)
[in]signalIdis the index of the emitting signal
[in]callabelis a python method or function (bounded or unbounded) that should be called if the slot is invoked
[in]signalis the signature of the signal (for debugging reasons)
[in]minRepeatIntervalis a minimum amount of time (in ms) which has to be passed until the same signal-slot-connection is accepted again (additional signal emissions are blocked), default: 0 (no timeout)

Member Function Documentation

◆ call()

void ito::PythonQtSignalTarget::call ( void ** arguments)

invokes the python method or function

If the slot is invoked, the python method or function is executed by this function. Usually the method is directly executed. If the user toggled the debug-button in the main window, the method is started in debug-mode. However, this is only done if python is in idle-mode at the point of the start of the execution.

The execution is as follows:

  1. It is checked whether the method should be executed or started in debug-mode
  2. The given arguments are marshalled to PyObject-values and added to a tuple.
  3. The python method or function is called.
Parameters
[in]argumentsare the arguments of the emitted signal.

◆ isSame()

bool ito::PythonQtSignalTarget::isSame ( int signalId,
PyObject * callable ) const

Compares this signal target with given values.

checks whether the given signal index and the reference to the python method is the same than the values of this instance of PythonQtSignalTarget

Parameters
[in]signalIdis the signal index (source of the signal-slot connection)
[in]callableis the python slot method (slot, destination of the signal-slot connection)
Returns
true if they are equal, else false.

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