decorator_pattern::Decorator

class Decorator : public decorator_pattern::Component

The Decorator class serves as the abstract base class for all decorators.

This class wraps a Component object and delegates the operations while allowing concrete decorators to extend or modify its behavior.

Subclassed by decorator_pattern::ConcreteDecoratorA, decorator_pattern::ConcreteDecoratorB

Public Functions

inline explicit Decorator(std::shared_ptr<Component> component)

Constructs the Decorator with a Component to wrap.

Parameters:

component – The Component to be decorated.

virtual std::string getDescription() const override = 0

Delegates the getDescription method to the wrapped Component. Marked as pure virtual to enforce implementation in derived classes.

Returns:

A string description.

virtual float cost() const override = 0

Delegates the cost method to the wrapped Component. Marked as pure virtual to enforce implementation in derived classes.

Returns:

A float representing the cost.