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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef SIM_FOUNDATION_EVENT_DELEGATE_H
00037 #define SIM_FOUNDATION_EVENT_DELEGATE_H
00038
00039 #include "Sim/Foundation/Event/EventBase.h"
00040 #include "Utility/SharedPtrObjectPool.h"
00041
00042 namespace Onikiri
00043 {
00044
00045 template <class ClassType, class ParamType>
00046 class EventDelegate :
00047 public EventBase< EventDelegate<ClassType, ParamType> >
00048 {
00049 using EventBase< EventDelegate<ClassType, ParamType> >::SetPriority;
00050 using EventBase< EventDelegate<ClassType, ParamType> >::GetPriority;
00051 typedef void (ClassType::*MethodType)(ParamType);
00052 ClassType* m_obj;
00053 MethodType m_func;
00054 ParamType m_param;
00055
00056 public:
00057 EventDelegate(ClassType* obj, MethodType func, ParamType param, int priority = RP_DEFAULT_EVENT) :
00058 m_obj ( obj ),
00059 m_func ( func ),
00060 m_param ( param )
00061 {
00062 SetPriority(priority);
00063 };
00064
00065 EventDelegate(const EventDelegate& ref) :
00066 m_obj ( ref.obj ),
00067 m_func ( ref.func ),
00068 m_param ( ref.param )
00069 {
00070 SetPriority( ref.GetPriority() );
00071 };
00072
00073 void Update()
00074 {
00075 (m_obj->*m_func)( m_param );
00076 };
00077 };
00078
00079 }
00080
00081
00082
00083 #endif
00084