/////////////////////////////////////////////////////////////////// // sKcommand.cpp - define invoker class // // ver 1.1 // // // // Language: Visual C++, ver 7.1 // // Platform: Dell Dimension 8300, Windows XP, Pro, sp2 // // Application: CSE776 - Design Patterns, Summer 2005 // // Author: Jim Fawcett, Instructor // // CST 2-187, (315) 443-3948 // // jfawcett@twcny.rr.com // /////////////////////////////////////////////////////////////////// #include #include "sKcommand.h" using namespace std; /////////////////////////////////////////////////////////////// // this function will stay about the same for any library // /////////////////////////////////////////////////////////////// void invoker::Register(event ev, command* pComm) { registrants[ev].push_back(pComm); } /////////////////////////////////////////////////////////////// // this function will stay about the same for any library // /////////////////////////////////////////////////////////////// void invoker::doCommands(event ev) { for(int i=0; i<(int)registrants[ev].size(); i++) registrants[ev][i]->execute(); } /////////////////////////////////////////////////////////////// // this function represents processing that will change for // // each library // /////////////////////////////////////////////////////////////// void invoker::doEvents() { cout << "\n\n invoker processing event1"; doCommands(event1); cout << "\n\n invoker processing event2"; doCommands(event2); cout << "\n\n invoker processing event3"; doCommands(event3); } #ifdef TEST_COMMAND void main() { invoker inv; } #endif