Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

SimpleCommand.h

Go to the documentation of this file.
00001 // $Id: SimpleCommand.h,v 1.1.1.1 2001/01/04 01:01:11 burnett Exp $
00002 // template for simple commands
00003 
00004 #ifndef CONTROL_SIMPLECOMMAND_H
00005 #define CONTROL_SIMPLECOMMAND_H
00006 
00007 #include "gui/Command.h"
00008 
00009 namespace gui {
00010 
00011 template <class Receiver>
00012 class SimpleCommand : public Command {
00013         // A template class for simple commands. The template parameter is the
00014         // class which is the receiver, i.e the class which actually performs
00015         // the operations.
00016 public:
00017    typedef void (Receiver::* Action)();
00018 
00019    SimpleCommand(Receiver* r, Action a):m_receiver(r),m_action(a){};
00020    // Constructor needs the receiver class and the method to invoke in that class
00021 
00022    virtual void execute();
00023    // All a command can do - tells the receiver to perform the action.
00024 
00025 private:
00026    Receiver* m_receiver;
00027    Action m_action;
00028 
00029 };
00030 
00031 template <class Receiver> inline
00032 void SimpleCommand<Receiver>::execute(){
00033         (m_receiver->*m_action)();
00034 }
00035 
00036 } // namespace gui
00037 
00038 #endif // CONTROL_SIMPLECOMMAND_H

Generated at Wed Nov 21 12:20:55 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000