#ifndef COMMAND_H #define COMMAND_H /////////////////////////////////////////////////////////////////// // command.h - declare command and invoker classes // // 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 class command; /////////////////////////////////////////////////////////////// // invoker is usually some, perhaps large, library facility // // that generates events clients need to react to // /////////////////////////////////////////////////////////////// class invoker { public: enum event { event1, event2, event3 }; void Register(event,command*); void doCommands(event ev); void doEvents(); private: std::vector registrants[3]; }; /////////////////////////////////////////////////////////////// // command defines some interface for executing client code // // when one of perhaps several special events occurs // /////////////////////////////////////////////////////////////// class command { public: virtual void execute() = 0; }; #endif