lewis.core.processor
This module defines two classes related to one of lewis’ essential concepts, namely
the cycle-based approach. CanProcess
and CanProcessComposite
implement the
composite design pattern so that it’s possible to form a tree of objects which can perform
calculations based on an elapsed time Δt.
Members
The CanProcess class is meant as a base for all things that are able to process on the basis of a time delta (dt). |
|
This subclass of CanProcess is a convenient way of collecting multiple items that implement the CanProcess interface. |
- class lewis.core.processor.CanProcess[source]
Bases:
object
The CanProcess class is meant as a base for all things that are able to process on the basis of a time delta (dt).
The base implementation does nothing.
There are three methods that can be implemented by sub-classes and are called in the process-method in this order:
doBeforeProcess
doProcess
doAfterProcess
The doBefore- and doAfterProcess methods are only called if a doProcess-method exists.
- class lewis.core.processor.CanProcessComposite(iterable=())[source]
Bases:
CanProcess
This subclass of CanProcess is a convenient way of collecting multiple items that implement the CanProcess interface.
Items can be added to the composite like this:
composite = CanProcessComposite() composite.add_processor(item_that_implements_CanProcess)
The process-method calls the process-method of each contained item. Specific things that have to be done before or after the containing items are processed can be implemented in the doBefore- and doAfterProcess methods.