/** * bridge.h * Implemented by Blueprint Technologies, Inc. */ #ifndef _bridge_h #define _bridge_h /** * Defines the interface for implementation classes. This * interface doesn't have to correspond exactly to Abstraction's * interface; in fact the two interfaces can be quite different. * Typically the Implementor interface provides only primitive * operations, and Abstraction defines higher-level operations * based on these primitives. */ class Implementor { public: virtual void operationImp() = 0; }; /** * Implements the Implementor interface and defines its * concrete implementation. */ class ConcreteImplementorA: public Implementor { public: virtual void operationImp() { // Do something. }; }; /** * Implements the Implementor interface and defines its * concrete implementation. */ class ConcreteImplementorB: public Implementor { public: virtual void operationImp() { // Do something. }; }; /** * Defines the abstraction's interface. Maintains a reference * to an object of type Implementor. */ class Abstraction { private: Implementor* implementor; public: Abstraction(): implementor(0) { }; virtual void operation() { implementor -> operationImp(); }; void setImplementor( Implementor* implementor ) { this -> implementor = implementor; }; Implementor* getImplementor() { return implementor; }; }; /** * Extends the interface defined by Abstraction. */ class RefinedAbstraction: public Abstraction { public: virtual void operation() { Abstraction::operation(); /** * new behavior here. */ }; }; #endif