/////////////////////////////////////////////////////////////////////////// // Abstraction.cpp - Implements Abstraction interface and its Concrete // // derivatives (Abstraction, Refined Abstractions) // // // // Skeleton for the BRIDGE PATTERN // // Participants : Abstraction, Refined Abstractions, // // Implementor, Concrete implementors // // // // ver 1.0 // // Language: Visual C++, ver 6.0, // // Platform: Dell XPS1000r, Windows 2000 Professional // // Author: Jim Fawcett, CST 2-187, Syracuse Univ. // // Source: // // Ivan Bernal/Wang Xiaoqiang // // imbernal@syr.edu // // CSE791 - Design Patterns, Summer 2000 // /////////////////////////////////////////////////////////////////////////// #include "Abstraction.h" #include "Implementor.h" #include using namespace std; Abstraction::Abstraction(eImpType impType) { switch(impType) { case A: _imp=new ConcreteImplementorA(); break; case B: _imp=new ConcreteImplementorB(); break; default: _imp=new ConcreteImplementorA(); break; } } Implementor*Abstraction::GetImplementor( void ) { return _imp; } Abstraction::~Abstraction() { delete _imp; } ///////////////////////////////////////////////////////////////////// // Construction/Destruction for RefinedAbstraction1 ///////////////////////////////////////////////////////////////////// RefinedAbstraction1::RefinedAbstraction1(eImpType impType) : Abstraction(impType) { } RefinedAbstraction1::~RefinedAbstraction1() { } void RefinedAbstraction1::Operation(void) { cout << "\n In RefinedAbstraction1:"; GetImplementor()->OperationImp(); } // ////////////////////////////////////////////////////////////////////// // Construction/Destruction for RefinedAbstraction2 ////////////////////////////////////////////////////////////////////// RefinedAbstraction2::RefinedAbstraction2(eImpType impType) : Abstraction(impType) { } RefinedAbstraction2:: ~RefinedAbstraction2() { } void RefinedAbstraction2::Operation(void) { cout << "\n In RefinedAbstraction2:"; GetImplementor()->OperationImp(); }