/////////////////////////////////////////////////////////////// // Client.cpp - Example of Bridge Design Pattern // // using a manufacturing analogy // // ver 1.0 // // Language: Visual C++, ver 6.0 // // Platform: Dell XPS1000r, Windows 2000 Professional // // Application: Design Patterns Presentation, Summer 2001 // // Author: Jim Fawcett, CST 2-187, Syracuse Univ. // // jfawcett@twcny.rr.com // // Source: John DeMar, Link 210, Syracuse Univ. // // jsdemar@syr.edu // /////////////////////////////////////////////////////////////// #include #include "Abstr.h" #include "ImplAbstr.h" #include "Impl.h" using namespace std; int main( void ) { // Note: // The client is NOT compile-independent of the implementations // because the implemenation objects are created here. // To achieve compile-independence we would have to move these // creation operations into static factory functions in the // base ProductionLine class. cout << "\n Simulating an Automated Manufacturing Process"; cout << "\n ===============================================\n"; ProductionLine* productionLineAX = new ProductionLineA(); MakeAssembly* runProductX = new MakeType1Assembly(productionLineAX); ProductionLine* productionLineBY = new ProductionLineB(); MakeAssembly* runProductY = new MakeType2Assembly(productionLineBY); ProductionLine* productionLineAZ = new ProductionLineA(); MakeAssembly* runProductZ = new MakeType2Assembly(productionLineAZ); cout << "\nRunning Product X, Type 1 using production line A...\n"; runProductX->Load(); runProductX->Fabricate(); runProductX->Test(); runProductX->Unload(); cout << "\nRunning Product Y, Type 2 using production line B...\n"; runProductY->Load(); runProductY->Fabricate(); runProductY->Test(); runProductY->Unload(); cout << "\nRunning Product Z, Type 2 using production line A...\n"; runProductZ->Load(); runProductZ->Fabricate(); runProductZ->Test(); runProductZ->Unload(); return 0; }