///////////////////////////////////////////////////////////////////////// // factory.cpp - implements factory method // // // // Demonstrates use of a factory class to create a product family // // on behalf of the client. This factory is bound to the product // // family so that the client does not have to be. // // // // Jim Fawcett, CSE687 - Object Oriented Design, Spring 2001 // ///////////////////////////////////////////////////////////////////////// #include #include "factory.h" #include "facade.h" using namespace std; //----< void constructor >----------------------------------------------- factory::factory() : pPA(NULL) { cout << "\n constructing factory"; } //----< destructor >----------------------------------------------------- factory::~factory() { cout << "\n destroying factory"; } //----< factory method >------------------------------------------------- // // This is a Singleton. Only one facade can be created. // productAbstraction* factory::createProduct() { if(pPA == NULL) { pPA = static_cast(new facade); return pPA; } return pPA; }