QDpy
Loading...
Searching...
No Matches
qdpy.algorithms.base._CallbacksManager Class Reference
Inheritance diagram for qdpy.algorithms.base._CallbacksManager:
qdpy.base.Copyable

Public Member Functions

Sequence[Callable] get (self, str event)
None add_callback (self, str event, Callable fn)

Detailed Description

Manager of callback functions that are called when specific events of the `QDAlgorithm` class are triggered.
It is possible to register a callback function using the `self.add_callback` method. The callback functions
attached to a specific event are retrieved through the `self.get` method.

We regroup callback function handling in this private class to ease the serialisation of QDAlgorithm and its sub-classes.
Namely, the callback functions provided by the user may not be pickleable.  To prevent them to be taken into account during serialisation, we declare a __getstate__ method returning the __dict__ dictionary of object attributes, minus the registered callback function objects. This __getstate__ is not inherited by sub-classes, which make it unadapted to be specified directly in the QDAlgorithm class, as it would force all sub-classes of QDAlgorithm to redefine the __getstate__ method to be pickleable.

Definition at line 140 of file base.py.

Member Function Documentation

◆ add_callback()

None qdpy.algorithms.base._CallbacksManager.add_callback ( self,
str event,
Callable fn )
Attach a callable `fn` to this CallbacksManager. `fn` will be called each time the event specified in `event` occurs.

Parameters
----------
:param event: str
    The event triggering the callback.
:param fn: Callable
    The callback function called when the event specified in `event` occurs.

Definition at line 168 of file base.py.

◆ get()

Sequence[Callable] qdpy.algorithms.base._CallbacksManager.get ( self,
str event )
Return the Sequence of functions that can be triggered when `event` happens. 

Parameters
----------
:param event: str
    The event triggering the returned callback functions.

Definition at line 158 of file base.py.


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