pycram.world_concepts.event#
Classes#
Base implementation of events in PyCRAM. |
Module Contents#
- class pycram.world_concepts.event.Event#
Base implementation of events in PyCRAM. Events allow to attach handler methods to events that fire for specific occurences in the world.
- Variables:
handler – List of methods that are called when this event is fired.
- handlers: typing_extensions.List[typing_extensions.Callable] = []#
- add(handler: typing_extensions.Callable) None#
Adds a new handler to the list of handlers. All handler methods are called when this event is fired. Handler have to take the event sender as parameter as well as args* which can contain further parameter.
- Parameters:
handler – A method that should be added
- remove(handler: typing_extensions.Callable) None#
Removes a method from the list of handlers, the method will not be called when the event is fired.
- Parameters:
handler – The method that should be removed.
- fire(sender: typing_extensions.Any, earg: typing_extensions.Optional[typing_extensions.Any] = None) None#
Fire this event, this causes every method to be called with a sender as well as additional args.
- Parameters:
sender – The entity that fired the event.
earg – Additional arguments.
- __iadd__(other: typing_extensions.Callable) Event#
Operator overload that allows to add handlers by the ‘+=’ operator.
- Parameters:
other – The handler that should be added.
- Returns:
This instance
- __isub__(other: typing_extensions.Callable) Event#
Operator overload that allows to remove methods as handlers by using the ‘-=’ operator.
- Parameters:
other – The method that should be removed as handler.
- Returns:
This instance
- __call__#
Allows to directly call the reference.