안녕하세요..
시간이 남아서 작업을 추가했습니다.
일단 __fastcall로 되어 있는 이벤트 핸들러도 동시에 처리합니다.
그리고 shared_ptr의 초기화도 지원합니다.
이벤트는 옵저버를 shared_ptr이 아니라 weak_ptr로 가지고 있게 됩니다.
즉 옵저버 연결이 유지되어도 객체의 생명주기가 다 되어서 객체가 삭제될 수 있습니다.
그러나 weak_ptr이므로 최소한 객체의 유효여부는 알 수 있으므로 사라진 객체에 대해서
멤버함수 콜을 하지 않습니다.
이러한 기능 추가를 위해서 사용법이 바뀐 것은 없습니다.
그냥 아래 글에서 설명한 방법으로 사용하시면 됩니다.
#ifndef mod_EventObserverH
#define mod_EventObserverH
#include
#include
#include
#include
#define INSERT_FIRST -1
#define INSERT_LAST 1
#define TEMPLATE_DECLARATION_STATEMENT_1 class ParamType
#define TEMPLATE_DECLARATION_STATEMENT_2 class ParamType, class ParamType2
#define TEMPLATE_DECLARATION_STATEMENT_3 class ParamType, class ParamType2, class ParamType3
#define TEMPLATE_DECLARATION_STATEMENT_4 class ParamType, class ParamType2, class ParamType3, class ParamType4
#define TEMPLATE_DECLARATION_STATEMENT_5 class ParamType, class ParamType2, class ParamType3, class ParamType4, class ParamType5
#define TEMPLATE_DECLARATION_STATEMENT_6 class ParamType, class ParamType2, class ParamType3, class ParamType4, class ParamType5, class ParamType6
#define TEMPLATE_DECLARATION_STATEMENT_7 class ParamType, class ParamType2, class ParamType3, class ParamType4, class ParamType5, class ParamType6, class ParamType7
#define CLASS_DECLARATION_STATEMENT_1 ParamType
#define CLASS_DECLARATION_STATEMENT_2 ParamType, ParamType2
#define CLASS_DECLARATION_STATEMENT_3 ParamType, ParamType2, ParamType3
#define CLASS_DECLARATION_STATEMENT_4 ParamType, ParamType2, ParamType3, ParamType4
#define CLASS_DECLARATION_STATEMENT_5 ParamType, ParamType2, ParamType3, ParamType4, ParamType5
#define CLASS_DECLARATION_STATEMENT_6 ParamType, ParamType2, ParamType3, ParamType4, ParamType5, ParamType6
#define CLASS_DECLARATION_STATEMENT_7 ParamType, ParamType2, ParamType3, ParamType4, ParamType5, ParamType6, ParamType7
#define FUNC_DECLARATION_STATEMENT_1 ParamType param
#define FUNC_DECLARATION_STATEMENT_2 ParamType param, ParamType2 param2
#define FUNC_DECLARATION_STATEMENT_3 ParamType param, ParamType2 param2, ParamType3 param3
#define FUNC_DECLARATION_STATEMENT_4 ParamType param, ParamType2 param2, ParamType3 param3, ParamType4 param4
#define FUNC_DECLARATION_STATEMENT_5 ParamType param, ParamType2 param2, ParamType3 param3, ParamType4 param4, ParamType5 param5
#define FUNC_DECLARATION_STATEMENT_6 ParamType param, ParamType2 param2, ParamType3 param3, ParamType4 param4, ParamType5 param5, ParamType6 param6
#define FUNC_DECLARATION_STATEMENT_7 ParamType param, ParamType2 param2, ParamType3 param3, ParamType4 param4, ParamType5 param5, ParamType6 param6, ParamType7 param7
#define FUNC_CALL_STATEMENT_1 param
#define FUNC_CALL_STATEMENT_2 param, param2
#define FUNC_CALL_STATEMENT_3 param, param2, param3
#define FUNC_CALL_STATEMENT_4 param, param2, param3, param4
#define FUNC_CALL_STATEMENT_5 param, param2, param3, param4, param5
#define FUNC_CALL_STATEMENT_6 param, param2, param3, param4, param5, param6
#define FUNC_CALL_STATEMENT_7 param, param2, param3, param4, param5, param6, param7
// --------------------------------------------
#define DEFINE_EVENT_OBSERVER_BASE(param_count) \
template \
class TEventObserverBase##param_count { \
public: \
virtual void Notify(FUNC_DECLARATION_STATEMENT_##param_count) = 0; \
virtual void* GetObserverObjectPtr(void) = 0; \
};
DEFINE_EVENT_OBSERVER_BASE(1);
DEFINE_EVENT_OBSERVER_BASE(2);
DEFINE_EVENT_OBSERVER_BASE(3);
DEFINE_EVENT_OBSERVER_BASE(4);
DEFINE_EVENT_OBSERVER_BASE(5);
DEFINE_EVENT_OBSERVER_BASE(6);
DEFINE_EVENT_OBSERVER_BASE(7);
// --------------------------------------------
#define DEFINE_EVENT_OBSERVER(param_count) \
template \
class TEventObserver##param_count: public TEventObserverBase##param_count { \
public: \
typedef void (ClassType::*TObserverMemberFunc)(FUNC_DECLARATION_STATEMENT_##param_count); \
TEventObserver##param_count(ClassType* observer_obj, TObserverMemberFunc observer_member_func) { ObserverObject = observer_obj; ObserverMemberFunc = observer_member_func; } \
virtual void* GetObserverObjectPtr(void) { return ObserverObject; } \
virtual void Notify(FUNC_DECLARATION_STATEMENT_##param_count) { if ( ObserverObject ) (*ObserverObject.*ObserverMemberFunc)(FUNC_CALL_STATEMENT_##param_count); } \
private: \
ClassType* ObserverObject; \
TObserverMemberFunc ObserverMemberFunc; \
};
DEFINE_EVENT_OBSERVER(1);
DEFINE_EVENT_OBSERVER(2);
DEFINE_EVENT_OBSERVER(3);
DEFINE_EVENT_OBSERVER(4);
DEFINE_EVENT_OBSERVER(5);
DEFINE_EVENT_OBSERVER(6);
DEFINE_EVENT_OBSERVER(7);
// --------------------------------------------
#define DEFINE_EVENT_OBSERVER_FASTCALL(param_count) \
template \
class TEventObserverFastcall##param_count: public TEventObserverBase##param_count { \
public: \
typedef void __fastcall (ClassType::*TObserverMemberFunc)(FUNC_DECLARATION_STATEMENT_##param_count); \
TEventObserverFastcall##param_count(ClassType* observer_obj, TObserverMemberFunc observer_member_func) { ObserverObject = observer_obj; ObserverMemberFunc = observer_member_func; } \
virtual void* GetObserverObjectPtr(void) { return ObserverObject; } \
virtual void Notify(FUNC_DECLARATION_STATEMENT_##param_count) { if ( ObserverObject ) (*ObserverObject.*ObserverMemberFunc)(FUNC_CALL_STATEMENT_##param_count); } \
private: \
ClassType* ObserverObject; \
TObserverMemberFunc ObserverMemberFunc; \
};
DEFINE_EVENT_OBSERVER_FASTCALL(1);
DEFINE_EVENT_OBSERVER_FASTCALL(2);
DEFINE_EVENT_OBSERVER_FASTCALL(3);
DEFINE_EVENT_OBSERVER_FASTCALL(4);
DEFINE_EVENT_OBSERVER_FASTCALL(5);
DEFINE_EVENT_OBSERVER_FASTCALL(6);
DEFINE_EVENT_OBSERVER_FASTCALL(7);
// --------------------------------------------
#define DEFINE_SAFE_EVENT_OBSERVER(param_count) \
template \
class TSafeEventObserver##param_count: public TEventObserverBase##param_count { \
public: \
typedef void (ClassType::*TObserverMemberFunc)(FUNC_DECLARATION_STATEMENT_##param_count); \
TSafeEventObserver##param_count(boost::shared_ptr observer_obj, TObserverMemberFunc observer_member_func) { ObserverObject = observer_obj; ObserverMemberFunc = observer_member_func; } \
virtual void* GetObserverObjectPtr(void) { if ( ObserverObject.expired() ) return NULL; else return ObserverObject.px; } \
virtual void Notify(FUNC_DECLARATION_STATEMENT_##param_count) { \
if ( !ObserverObject.expired() ) { \
shared_ptr obj = ObserverObject.lock(); \
(*obj.*ObserverMemberFunc)(FUNC_CALL_STATEMENT_##param_count); \
} \
} \
private: \
boost::weak_ptr ObserverObject; \
TObserverMemberFunc ObserverMemberFunc; \
};
DEFINE_SAFE_EVENT_OBSERVER(1);
DEFINE_SAFE_EVENT_OBSERVER(2);
DEFINE_SAFE_EVENT_OBSERVER(3);
DEFINE_SAFE_EVENT_OBSERVER(4);
DEFINE_SAFE_EVENT_OBSERVER(5);
DEFINE_SAFE_EVENT_OBSERVER(6);
DEFINE_SAFE_EVENT_OBSERVER(7);
// --------------------------------------------
#define DEFINE_SAFE_EVENT_OBSERVER_FASTCALL(param_count) \
template \
class TSafeEventObserverFastcall##param_count: public TEventObserverBase##param_count { \
public: \
typedef void __fastcall (ClassType::*TObserverMemberFunc)(FUNC_DECLARATION_STATEMENT_##param_count); \
TSafeEventObserverFastcall##param_count(boost::shared_ptr observer_obj, TObserverMemberFunc observer_member_func) { ObserverObject = observer_obj; ObserverMemberFunc = observer_member_func; } \
virtual void* GetObserverObjectPtr(void) { if ( ObserverObject.expired() ) return NULL; else return ObserverObject.px; } \
virtual void Notify(FUNC_DECLARATION_STATEMENT_##param_count) { \
if ( !ObserverObject.expired() ) { \
shared_ptr obj = ObserverObject.lock(); \
(*obj.*ObserverMemberFunc)(FUNC_CALL_STATEMENT_##param_count); \
} \
} \
private: \
boost::weak_ptr ObserverObject; \
TObserverMemberFunc ObserverMemberFunc; \
};
DEFINE_SAFE_EVENT_OBSERVER_FASTCALL(1);
DEFINE_SAFE_EVENT_OBSERVER_FASTCALL(2);
DEFINE_SAFE_EVENT_OBSERVER_FASTCALL(3);
DEFINE_SAFE_EVENT_OBSERVER_FASTCALL(4);
DEFINE_SAFE_EVENT_OBSERVER_FASTCALL(5);
DEFINE_SAFE_EVENT_OBSERVER_FASTCALL(6);
DEFINE_SAFE_EVENT_OBSERVER_FASTCALL(7);
// --------------------------------------------
#define DEFINE_EVENT_OBSERVER_SINGLE(param_count) \
template \
class TEventObserverSingle##param_count { \
private: \
TEventObserverBase##param_count* Observer; \
public: \
TEventObserverSingle##param_count() { Observer = NULL; } \
~TEventObserverSingle##param_count() { if ( Observer ) delete Observer; } \
void Set(TEventObserverBase##param_count* observer, int pos = 0) { if ( Observer ) delete Observer; Observer = observer; } \
void Reset(void* observer_object_ptr = NULL) { if ( Observer ) delete Observer; Observer = NULL; } \
void Notify(FUNC_DECLARATION_STATEMENT_##param_count) { if ( Observer ) Observer->Notify(FUNC_CALL_STATEMENT_##param_count); } \
};
DEFINE_EVENT_OBSERVER_SINGLE(1);
DEFINE_EVENT_OBSERVER_SINGLE(2);
DEFINE_EVENT_OBSERVER_SINGLE(3);
DEFINE_EVENT_OBSERVER_SINGLE(4);
DEFINE_EVENT_OBSERVER_SINGLE(5);
DEFINE_EVENT_OBSERVER_SINGLE(6);
DEFINE_EVENT_OBSERVER_SINGLE(7);
// --------------------------------------------
#define DEFINE_EVENT_OBSERVER_LIST(param_count) \
template \
class TEventObserverList##param_count { \
private: \
std::vector*> list; \
void AddInternal(TEventObserverBase##param_count* observer, int pos) { \
if ( pos == 0 ) list.push_back(observer); \
else if ( pos < 0 ) list.insert(list.begin(), observer); \
else list.insert(list.begin()+1, observer); \
} \
public: \
~TEventObserverList##param_count() { \
std::vector*>::iterator iter; \
for ( iter=list.begin() ; iter!=list.end() ; iter++ ) \
delete *iter; \
} \
void Set(TEventObserverBase##param_count* observer, int pos = 0) { \
if ( observer ) { \
Reset(observer->GetObserverObjectPtr()); \
AddInternal(observer, pos); \
}\
} \
void Reset(void) { \
std::vector*>::iterator iter; \
for ( iter=list.begin() ; iter!=list.end() ; iter++ ) \
delete *iter; \
list.clear(); \
} \
void Reset(void* observer_object_ptr) { \
if ( observer_object_ptr ) { \
std::vector*>::iterator iter; \
for ( iter=list.begin() ; iter!=list.end() ; ) { \
if ( (*iter)->GetObserverObjectPtr() == observer_object_ptr ) { \
delete *iter; list.erase(iter); continue; \
} \
iter++; \
} \
} \
} \
void Notify(FUNC_DECLARATION_STATEMENT_##param_count) { \
std::vector*>::iterator iter, end; \
for ( iter=list.begin(), end=list.end() ; iter!=end ; iter++ ) \
(*iter)->Notify(FUNC_CALL_STATEMENT_##param_count); \
} \
};
DEFINE_EVENT_OBSERVER_LIST(1);
DEFINE_EVENT_OBSERVER_LIST(2);
DEFINE_EVENT_OBSERVER_LIST(3);
DEFINE_EVENT_OBSERVER_LIST(4);
DEFINE_EVENT_OBSERVER_LIST(5);
DEFINE_EVENT_OBSERVER_LIST(6);
DEFINE_EVENT_OBSERVER_LIST(7);
// --------------------------------------------
#define DEFINE_EVENT_1(event_name, param1_type) \
typedef TEventObserverSingle1 T##event_name; \
typedef TEventObserverList1 T##event_name##s; \
class T##event_name##Observer { public: virtual void On##event_name##Receive(param1_type p1) = 0; }; \
template class T##event_name##Factory { public: \
static TEventObserver1* CreateObserver(ClassType* obj, void(ClassType::*func)(param1_type)) { \
return new TEventObserver1(obj, func); \
} \
static TEventObserverFastcall1* CreateObserver(ClassType* obj, void __fastcall (ClassType::*func)(param1_type)) { \
return new TEventObserverFastcall1(obj, func); \
} \
static TEventObserver1* CreateObserver(ClassType* obj) { \
return new TEventObserver1(obj, ClassType::On##event_name##Receive); \
} \
static TSafeEventObserver1* CreateObserver(boost::shared_ptr obj, void(ClassType::*func)(param1_type)) { \
return new TSafeEventObserver1(obj, func); \
} \
static TSafeEventObserverFastcall1* CreateSafeObserver(boost::shared_ptr obj, void __fastcall (ClassType::*func)(param1_type)) { \
return new TSafeEventObserverFastcall1(obj, func); \
} \
static TSafeEventObserver1* CreateSafeObserver(boost::shared_ptr obj) { \
return new TSafeEventObserver1(obj, ClassType::On##event_name##Receive); \
} \
};
#define DEFINE_EVENT_2(event_name, param1_type, param2_type) \
typedef TEventObserverSingle2 T##event_name; \
typedef TEventObserverList2 T##event_name##s; \
class T##event_name##Observer { public: virtual void On##event_name##Receive(param1_type p1, param2_type p2) = 0; }; \
template class T##event_name##Factory { public: \
static TEventObserver2* CreateObserver(ClassType* obj, void(ClassType::*func)(param1_type, param2_type)) { \
return new TEventObserver2(obj, func); \
} \
static TEventObserverFastcall2* CreateObserver(ClassType* obj, void __fastcall (ClassType::*func)(param1_type, param2_type)) { \
return new TEventObserverFastcall2(obj, func); \
} \
static TEventObserver2* CreateObserver(ClassType* obj) { \
return new TEventObserver2(obj, ClassType::On##event_name##Receive); \
} \
static TSafeEventObserver2* CreateSafeObserver(boost::shared_ptr obj, void(ClassType::*func)(param1_type, param2_type)) { \
return new TSafeEventObserver2(obj, func); \
} \
static TSafeEventObserverFastcall2* CreateSafeObserver(boost::shared_ptr obj, void __fastcall (ClassType::*func)(param1_type, param2_type)) { \
return new TSafeEventObserverFastcall2(obj, func); \
} \
static TSafeEventObserver2* CreateSafeObserver(boost::shared_ptr obj) { \
return new TSafeEventObserver2(obj, ClassType::On##event_name##Receive); \
} \
};
#define DEFINE_EVENT_3(event_name, param1_type, param2_type, param3_type) \
typedef TEventObserverSingle3 T##event_name; \
typedef TEventObserverList3 T##event_name##s; \
class T##event_name##Observer { public: virtual void On##event_name##Receive(param1_type p1, param2_type p2, param3_type p3) = 0; }; \
template class T##event_name##Factory { public: \
static TEventObserver3* CreateObserver(ClassType* obj, void(ClassType::*func)(param1_type, param2_type, param3_type)) { \
return new TEventObserver3(obj, func); \
} \
static TEventObserverFastcall3* CreateObserver(ClassType* obj, void __fastcall (ClassType::*func)(param1_type, param2_type, param3_type)) { \
return new TEventObserverFastcall3(obj, func); \
} \
static TEventObserver3* CreateObserver(ClassType* obj) { \
return new TEventObserver3(obj, ClassType::On##event_name##Receive); \
} \
static TSafeEventObserver3* CreateSafeObserver(boost::shared_ptr obj, void(ClassType::*func)(param1_type, param2_type, param3_type)) { \
return new TSafeEventObserver3(obj, func); \
} \
static TSafeEventObserverFastcall3* CreateSafeObserver(boost::shared_ptr obj, void __fastcall (ClassType::*func)(param1_type, param2_type, param3_type)) { \
return new TSafeEventObserverFastcall3(obj, func); \
} \
static TSafeEventObserver3* CreateSafeObserver(boost::shared_ptr obj) { \
return new TSafeEventObserver3(obj, ClassType::On##event_name##Receive); \
} \
};
#define DEFINE_EVENT_4(event_name, param1_type, param2_type, param3_type, param4_type) \
typedef TEventObserverSingle4 T##event_name; \
typedef TEventObserverList4 T##event_name##s; \
class T##event_name##Observer { public: virtual void On##event_name##Receive(param1_type p1, param2_type p2, param3_type p3, param4_type p4) = 0; }; \
template class T##event_name##Factory { public: \
static TEventObserver4* CreateObserver(ClassType* obj, void(ClassType::*func)(param1_type, param2_type, param3_type, param4_type)) { \
return new TEventObserver4(obj, func); \
} \
static TEventObserverFastcall4* CreateObserver(ClassType* obj, void __fastcall (ClassType::*func)(param1_type, param2_type, param3_type, param4_type)) { \
return new TEventObserverFastcall4(obj, func); \
} \
static TEventObserver4* CreateObserver(ClassType* obj) { \
return new TEventObserver4(obj, ClassType::On##event_name##Receive); \
} \
static TSafeEventObserver4* CreateSafeObserver(boost::shared_ptr obj, void(ClassType::*func)(param1_type, param2_type, param3_type, param4_type)) { \
return new TSafeEventObserver4(obj, func); \
} \
static TSafeEventObserverFastcall4* CreateSafeObserver(boost::shared_ptr obj, void __fastcall (ClassType::*func)(param1_type, param2_type, param3_type, param4_type)) { \
return new TSafeEventObserverFastcall4(obj, func); \
} \
static TSafeEventObserver4* CreateSafeObserver(boost::shared_ptr obj) { \
return new TSafeEventObserver4(obj, ClassType::On##event_name##Receive); \
} \
};
#define DEFINE_EVENT_5(event_name, param1_type, param2_type, param3_type, param4_type, param5_type) \
typedef TEventObserverSingle5 T##event_name; \
typedef TEventObserverList5 T##event_name##s; \
class T##event_name##Observer { public: virtual void On##event_name##Receive(param1_type p1, param2_type p2, param3_type p3, param4_type p4, param5_type p5) = 0; }; \
template class T##event_name##Factory { public: \
static TEventObserver5* CreateObserver(ClassType* obj, void(ClassType::*func)(param1_type, param2_type, param3_type, param4_type, param5_type)) { \
return new TEventObserver5(obj, func); \
} \
static TEventObserverFastcall5* CreateObserver(ClassType* obj, void __fastcall (ClassType::*func)(param1_type, param2_type, param3_type, param4_type, param5_type)) { \
return new TEventObserverFastcall5(obj, func); \
} \
static TEventObserver5* CreateObserver(ClassType* obj) { \
return new TEventObserver5(obj, ClassType::On##event_name##Receive); \
} \
static TSafeEventObserver5* CreateSafeObserver(boost::shared_ptr obj, void(ClassType::*func)(param1_type, param2_type, param3_type, param4_type, param5_type)) { \
return new TSafeEventObserver5(obj, func); \
} \
static TSafeEventObserverFastcall5* CreateSafeObserver(boost::shared_ptr obj, void __fastcall (ClassType::*func)(param1_type, param2_type, param3_type, param4_type, param5_type)) { \
return new TSafeEventObserverFastcall5(obj, func); \
} \
static TSafeEventObserver5* CreateSafeObserver(boost::shared_ptr obj) { \
return new TSafeEventObserver5(obj, ClassType::On##event_name##Receive); \
} \
};
#define DEFINE_EVENT_6(event_name, param1_type, param2_type, param3_type, param4_type, param5_type, param6_type) \
typedef TEventObserverSingle6 T##event_name; \
typedef TEventObserverList6 T##event_name##s; \
class T##event_name##Observer { public: virtual void On##event_name##Receive(param1_type p1, param2_type p2, param3_type p3, param4_type p4, param5_type p5, param6_type p6) = 0; }; \
template class T##event_name##Factory { public: \
static TEventObserver6* CreateObserver(ClassType* obj, void(ClassType::*func)(param1_type, param2_type, param3_type, param4_type, param5_type, param6_type)) { \
return new TEventObserver6(obj, func); \
} \
static TEventObserverFastcall6* CreateObserver(ClassType* obj, void __fastcall(ClassType::*func)(param1_type, param2_type, param3_type, param4_type, param5_type, param6_type)) { \
return new TEventObserverFastcall6(obj, func); \
} \
static TEventObserver6* CreateObserver(ClassType* obj) { \
return new TEventObserver6(obj, ClassType::On##event_name##Receive); \
} \
static TSafeEventObserver6* CreateSafeObserver(boost::shared_ptr obj, void(ClassType::*func)(param1_type, param2_type, param3_type, param4_type, param5_type, param6_type)) { \
return new TSafeEventObserver6(obj, func); \
} \
static TSafeEventObserverFastcall6* CreateSafeObserver(boost::shared_ptr obj, void __fastcall(ClassType::*func)(param1_type, param2_type, param3_type, param4_type, param5_type, param6_type)) { \
return new TSafeEventObserverFastcall6(obj, func); \
} \
static TSafeEventObserver6* CreateSafeObserver(boost::shared_ptr obj) { \
return new TSafeEventObserver6(obj, ClassType::On##event_name##Receive); \
} \
};
#define DEFINE_EVENT_7(event_name, param1_type, param2_type, param3_type, param4_type, param5_type, param6_type, param7_type) \
typedef TEventObserverSingle7 T##event_name; \
typedef TEventObserverList7 T##event_name##s; \
class T##event_name##Observer { public: virtual void On##event_name##Receive(param1_type p1, param2_type p2, param3_type p3, param4_type p4, param5_type p5, param6_type p6, param7_type p7) = 0; }; \
template class T##event_name##Factory { public: \
static TEventObserver7* CreateObserver(ClassType* obj, void(ClassType::*func)(param1_type, param2_type, param3_type, param4_type, param5_type, param6_type, param7_type)) { \
return new TEventObserver7(obj, func); \
} \
static TEventObserverFastcall7* CreateObserver(ClassType* obj, void __fastcall(ClassType::*func)(param1_type, param2_type, param3_type, param4_type, param5_type, param6_type, param7_type)) { \
return new TEventObserverFastcall7(obj, func); \
} \
static TEventObserver7* CreateObserver(ClassType* obj) { \
return new TEventObserver7(obj, ClassType::On##event_name##Receive); \
} \
static TSafeEventObserver7* CreateSafeObserver(boost::shared_ptr obj, void(ClassType::*func)(param1_type, param2_type, param3_type, param4_type, param5_type, param6_type, param7_type)) { \
return new TSafeEventObserver7(obj, func); \
} \
static TSafeEventObserverFastcall7* CreateSafeObserver(boost::shared_ptr obj, void __fastcall(ClassType::*func)(param1_type, param2_type, param3_type, param4_type, param5_type, param6_type, param7_type)) { \
return new TSafeEventObserverFastcall7(obj, func); \
} \
static TSafeEventObserver7* CreateSafeObserver(boost::shared_ptr obj) { \
return new TSafeEventObserver7(obj, ClassType::On##event_name##Receive); \
} \
};
#define CREATE_OBSERVER(event_type_name, observer_type, observer_obj, observer_func) event_type_name##Factory::CreateObserver(observer_obj, observer_type::observer_func)
#define CREATE_INHERITED_OBSERVER(event_type_name, observer_type, observer_obj) event_type_name##Factory::CreateObserver(observer_obj)
#endif