5.8.2 Slot classes

There are the following standard slots:

class Slot( [value, flags])
Create a slot that initially carries the specified value.

Todo: Describe the flags argument.

isSlotCompatible( slot)
Return True if slot is compatible with this slot. Two slots are compatible if they hold the same type of value. Only compatible slots can be connected to each other. But note that even when this method returns true, it can happen that the slots can not be connected. This is the case whenever the target just doesn't accept input connections (for example, because it's computing its output value procedurally).

typeName( )
Return a string containing the name of the stored type. This name can be used to display the type of the slot to the user. The name should be chosen so that if two slots cannot be connected to each other then they should also return different names (however, if two slots have different names it is still possible that they can be connected to each other).

getController( )
Return the associated controlling slot or None.

setController( slot)
Set or remove a controller for this slot. The current controller is replaced with slot which may also be None to remove the current controller only. If the controller is not compatible with this slot an EIncompatibleSlotTypes exception is thrown.

getValue( )
Return the current slot value.

setValue( val)
Set a new value. If the slot has a controller the new value is propagated up to the controller. It is then up to the controller how this new value influences the actual output value. So it is not guaranteed that the output of the slot is really the new value. When the value really changes this method triggers the onValueChanged() method on all dependent objects.

connect( slot)
Connect the output of this slot with the input of slot. Calling this method is equivalent to calling slot.setController(self). The method has no effect if slot is None.

disconnect( slot)
Breaks an existing connection between this slot and slot. Calling this method is equivalent to calling slot.setController(None). The method checks if the connection actually exists before breaking it. If it does not exist, a ValueError exception is raised. The method has no effect if slot is None.

addDependent( d)
Establish a dependency between this slot and another object d. The argument d is added to the list of dependent objects. This means that d somehow depends on the value of this slot and that d has to be notified whenever the value of this slot changes. The actual notification is done by calling notifyDependents() which in turn calls onValueChanged() on all dependent objects.

Todo: C++ warning!

removeDependent( d)
Remove the dependency between this slot and another object d.

notifyDependents( )
Notify all dependent slots about a value change. This method calls the onValueChanged() method of all slots whose value depends on the value of this slot.

computeValue( )
This method is used to compute a new value whenever getValue() is called and the cache is invalid. It should only be implemented on procedural slots.