| Total Complexity | 3 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | from enarksh.event.Event import Event |
||
| 4 | class Actor: |
||
| 5 | """ |
||
| 6 | Parent class for classes that fire events and for classes that listen for events. |
||
| 7 | """ |
||
| 8 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 9 | def __init__(self): |
||
| 10 | self.registered_events = set() |
||
| 11 | """ |
||
| 12 | All the (active) event this object can fire. |
||
| 13 | |||
| 14 | Note: this field MUST only be touched by the event controller. |
||
| 15 | |||
| 16 | :type: set[enarksh.event.Event.Event] |
||
| 17 | """ |
||
| 18 | |||
| 19 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 20 | def destroy(self): |
||
| 21 | """ |
||
| 22 | Removes this object from the event system. This as preparation for removing this object. |
||
| 23 | """ |
||
| 24 | for event in self.registered_events: |
||
| 25 | event.destroy() |
||
| 26 | |||
| 27 | Event.event_controller.unregister_listener_object(self) |
||
| 28 | |||
| 30 |
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.