/** * decorator.h * Implemented by Blueprint Technologies, Inc. */ #ifndef _decorator_h #define _decorator_h /** * Defines the interface for objects that can have responsibilities * added to them dynamically. */ class Component { public: virtual void operation() = 0; }; /** * Defines an object to which additional responsibilities * can be attached. */ class ConcreteComponent: public Component { public: virtual void operation() { }; }; /** * Maintains a reference to a Component object and defines * an interface that conforms to Component's interface. */ class Decorator: public Component { private: Component* component; public: virtual void operation() { component -> operation(); }; /** * Accessors. */ Component* getComponent() { return component; }; void setComponent( Component* component ) { this -> component = component; }; }; /** * Adds responsibilities to the component. */ class ConcreteDecoratorA: public Decorator { private: int addedState; public: virtual void operation() { }; }; /** * Adds responsibilities to the component. */ class ConcreteDecoratorB: public Decorator { public: virtual void operation() { Decorator::operation(); addedBehavior(); }; void addedBehavior() { }; }; #endif