Composite API Documentation
- class Component[source]
Bases:
ABCThe Component interface declares common operations for both leaf and composite objects.
- add(component)[source]
Optionally, add a child component to the composite. Raises NotImplementedError for leaf components.
- class Leaf(name)[source]
Bases:
ComponentRepresents the Leaf object in the Composite pattern. A Leaf has no children and defines behavior for primitive objects.
- Parameters:
name (str)
- class Composite(name)[source]
Bases:
ComponentRepresents the Composite object in the Composite pattern. A Composite can contain both Leaf and other Composite objects.
- Parameters:
name (str)
- __init__(name)[source]
Initialize the Composite with a name.
- Parameters:
name (
str) – The name of the composite.