/////////////////////////////////////////////////////////////////// // client.cpp -- Oversimplified Neural Network simulation // // uses layers (AbstractFactories) // // to create nodes (products) // // - does no iteration or adjustment of weights // // in fact there is no interconnect at all // // // // Jim Fawcett, CSE776 - Design Patterns, Summer 2004 // /////////////////////////////////////////////////////////////////// // ver 1.1 - added static creational function in AbstractLayer // // so client can use the abstract interface // /////////////////////////////////////////////////////////////////// #include #include "absfact.h" using namespace std; void main( ) { cout << "\n Demonstrating Abstract Factory Pattern " << "\n using a prototype neural network " << "\n ========================================\n"; absNNfact *pfact = absNNfact::CreateFactory(absNNfact::input); abstractLayer *pALi = pfact->createLayer(); pfact->PopulateLayer(3); pfact = absNNfact::CreateFactory(absNNfact::hidden); abstractLayer *pALh = pfact->createLayer(); pfact->PopulateLayer(5); pfact = absNNfact::CreateFactory(absNNfact::output); abstractLayer *pALo = pfact->createLayer(); pfact->PopulateLayer(1); pALi->useLayer(); pALh->useLayer(); pALo->useLayer(); delete pALi; delete pALh; delete pALo; cout << "\n\n"; }