cmd_generic.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef CMD_GENERIC_HPP
00026 #define CMD_GENERIC_HPP
00027
00028 #include <string>
00029
00030 #include "../src/skin_common.hpp"
00031 #include "../utils/pointer.hpp"
00032
00033
00034
00035 #define DEFINE_COMMAND( name, type ) \
00036 class Cmd##name: public CmdGeneric \
00037 { public: \
00038 Cmd##name( intf_thread_t *pIntf ): CmdGeneric( pIntf ) { } \
00039 virtual ~Cmd##name() { } \
00040 virtual void execute(); \
00041 virtual string getType() const { return type; } \
00042 };
00043
00044
00045
00046 #define DEFINE_CALLBACK( parent, action ) \
00047 class Cmd##action: public CmdGeneric \
00048 { \
00049 public: \
00050 Cmd##action( parent *pParent ): \
00051 CmdGeneric( pParent->getIntf() ), m_pParent( pParent ) { } \
00052 virtual ~Cmd##action() { } \
00053 virtual void execute(); \
00054 virtual string getType() const { return "Cmd" #parent #action; } \
00055 private: \
00056 parent *m_pParent; \
00057 } m_cmd##action; \
00058 friend class Cmd##action;
00059
00060
00061
00062 class CmdGeneric: public SkinObject
00063 {
00064 public:
00065 virtual ~CmdGeneric() { }
00066
00067
00068 virtual void execute() = 0;
00069
00070
00071 virtual string getType() const { return ""; }
00072
00073
00074
00075 virtual bool checkRemove( CmdGeneric * ) const { return true; }
00076
00077 protected:
00078 CmdGeneric( intf_thread_t *pIntf ): SkinObject( pIntf ) { }
00079 };
00080
00081
00082 typedef CountedPtr<CmdGeneric> CmdGenericPtr;
00083
00084
00085 #endif