00001 00010 #ifndef DEFINE_H_YACTION 00011 #define DEFINE_H_YACTION 00012 00017 class YAction { 00018 protected: 00019 YAction(); 00020 00021 public: 00022 virtual ~YAction(); 00023 00028 virtual void execute() = 0; 00029 }; 00030 00040 template <class Receiver> 00041 class YSimpleAction : public YAction { 00042 public: 00043 typedef void (Receiver::* Function)(); 00044 00045 YSimpleAction(Receiver* r, Function a) 00046 : _receiver(r), _action(a) { } 00047 00048 virtual void execute() { 00049 (_receiver->*_action)(); 00050 } 00051 00052 private: 00053 Function _action; 00054 Receiver* _receiver; 00055 }; 00056 00057 #endif DEFINE_H_YACTION