Total Complexity | 3 |
Total Lines | 25 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | 1 | from enarksh.event.Event import Event |
|
4 | 1 | class EventActor: |
|
5 | """ |
||
6 | Parent class for classes that fire events and for classes that listen for events. |
||
7 | """ |
||
8 | # ------------------------------------------------------------------------------------------------------------------ |
||
9 | 1 | def __init__(self): |
|
10 | 1 | self.friend_registered_events = set() |
|
11 | 1 | """ |
|
12 | All the (active) events this object can fire. |
||
13 | |||
14 | Note: This field MUST be touched by the event controller only. |
||
15 | |||
16 | :type: set[enarksh.event.Event.Event] |
||
17 | """ |
||
18 | |||
19 | # ------------------------------------------------------------------------------------------------------------------ |
||
20 | 1 | def destroy(self): |
|
21 | """ |
||
22 | Removes this object from the event system. This as preparation for removing this object such that there aren't |
||
23 | references (from the event system) to this object and the garbage collector can remove this object. |
||
24 | """ |
||
25 | 1 | for event in self.friend_registered_events: |
|
26 | 1 | event.destroy() |
|
27 | |||
28 | 1 | Event.event_controller.friend_unregister_listener_object(self) |
|
29 | |||
31 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.