Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00013 #ifndef _FBXSDK_CORE_EVENT_HANDLER_H_
00014 #define _FBXSDK_CORE_EVENT_HANDLER_H_
00015
00016 #include <fbxsdk/fbxsdk_def.h>
00017
00018
00019 #include <fbxsdk/core/fbxevent.h>
00020
00021
00022 #include <fbxsdk/core/base/fbxintrusivelist.h>
00023
00024 #include <fbxsdk/fbxsdk_nsbegin.h>
00025
00026 class FbxListener;
00027
00028
00045 class FbxEventHandler
00046 {
00047 public:
00048 enum EType
00049 {
00050 eListener,
00051 eEmitter,
00052 eCount
00053 };
00054
00057 FbxEventHandler(){}
00058
00061 virtual ~FbxEventHandler(){}
00062
00063
00067 virtual int GetHandlerEventType() = 0;
00068
00073 virtual void FunctionCall(const FbxEventBase& pEvent) = 0;
00074
00078 virtual FbxListener* GetListener() = 0;
00079
00080 FBXSDK_INTRUSIVE_LIST_NODE(FbxEventHandler, eCount);
00081 };
00082
00084
00085
00086
00087
00088
00089
00091 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00092
00093 template <typename EventType, typename ListenerType> class FbxMemberFuncEventHandler : public FbxEventHandler
00094 {
00095
00096
00097 typedef void (ListenerType::*CBFunction)(const EventType*);
00098
00099 public:
00100 FbxMemberFuncEventHandler(ListenerType* pListenerInstance, CBFunction pFunc) :
00101 mListener(pListenerInstance),
00102 mFunc(pFunc)
00103 {
00104 }
00105
00106
00107 virtual int GetHandlerEventType(){ return EventType::GetStaticTypeId(); }
00108 virtual void FunctionCall(const FbxEventBase& pEvent){ (*mListener.*mFunc)(reinterpret_cast<const EventType*>(&pEvent)); }
00109 virtual FbxListener* GetListener(){ return mListener;}
00110 private:
00111 ListenerType* mListener;
00112
00113
00114 CBFunction mFunc;
00115 };
00116
00117
00118 template <typename EventType, typename ListenerType> class FbxConstMemberFuncEventHandler : public FbxEventHandler
00119 {
00120
00121
00122
00123 typedef void (ListenerType::*CBFunction)(const EventType*)const;
00124
00125 public:
00126 FbxConstMemberFuncEventHandler(ListenerType* pListenerInstance, CBFunction pFunc) :
00127 mListener(pListenerInstance),
00128 mFunc(pFunc)
00129 {
00130 }
00131
00132
00133 virtual int GetHandlerEventType(){ return EventType::GetStaticTypeId(); }
00134 virtual void FunctionCall(const FbxEventBase& pEvent){ (*mListener.*mFunc)(reinterpret_cast<const EventType*>(&pEvent)); }
00135 virtual FbxListener* GetListener(){ return mListener;}
00136 private:
00137 ListenerType* mListener;
00138
00139
00140 CBFunction mFunc;
00141 };
00142
00143
00144 template <typename EventType> class FbxFuncEventHandler : public FbxEventHandler
00145 {
00146
00147
00148 typedef void (*CBFunction)(const EventType*,FbxListener*);
00149
00150 public:
00151 FbxFuncEventHandler(FbxListener* pListener, CBFunction pFunc) :
00152 mListener(pListener),
00153 mFunc(pFunc)
00154 {
00155 }
00156
00157
00158 virtual int GetHandlerEventType(){ return EventType::GetStaticTypeId(); }
00159 virtual void FunctionCall(const FbxEventBase& pEvent){ (*mFunc)(reinterpret_cast<const EventType*>(&pEvent),mListener); }
00160 virtual FbxListener* GetListener(){ return mListener; }
00161 private:
00162 FbxListener* mListener;
00163
00164
00165 CBFunction mFunc;
00166 };
00167 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00168
00169 #include <fbxsdk/fbxsdk_nsend.h>
00170
00171 #endif