Go to the
documentation of this file.
00001
00004 #ifndef FBXFILESDK_KFBXEVENTS_KFBXEVENTS_H
00005 #define FBXFILESDK_KFBXEVENTS_KFBXEVENTS_H
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
00037
00038
00039
00040
00041 #include <fbxfilesdk/fbxfilesdk_def.h>
00042
00043 #include <fbxfilesdk/kfbxplugins/kfbxtypes.h>
00044 #include <fbxfilesdk/kfbxplugins/kfbxdatatypes.h>
00045 #include <fbxfilesdk/kfbxmp/kfbxmutex.h>
00046
00047
00048 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00049 namespace kfbxevents
00050 {
00069 class KFBX_DLL KFbxEventBase
00070 {
00071 public:
00076
00077 virtual ~KFbxEventBase();
00079
00083 virtual int GetTypeId() const = 0;
00084
00088 virtual const char* GetEventName() const = 0;
00089
00090 protected:
00091 static int GetStaticTypeId(char const*);
00092
00093 private:
00094 static kfbxmp::KFbxMutex smMutex;
00095 };
00096
00097
00098
00099
00100 #define KFBXEVENT_DECLARE(Class) \
00101 public: virtual const char* GetEventName() const { return FbxEventName(); } \
00102 private: static const char* FbxEventName() { return #Class; } \
00103 friend class KFbxEvent<Class>;
00104
00105
00106
00107
00108
00109 #define KFBXEVENT_DECLARE_FBXTYPE(Class, FBXType) \
00110 public: virtual const char* GetEventName() const { return FbxEventName(); } \
00111 private: \
00112 static const char* FbxEventName() { \
00113 static KString lEventName = KString(#Class) + KString("<") + \
00114 GetFbxDataType(FbxTypeOf(*((FBXType const*)0))).GetName() + ">"; \
00115 \
00116 return lEventName.Buffer(); \
00117 } \
00118 friend class KFbxEvent< Class<FBXType> >;
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 #define KFBXEVENT_TEMPLATE_HEADER_NOT_FBXTYPE(ClassName, TemplateName)\
00130 template < class TemplateName, const char* T > \
00131 class ClassName: public kfbxevents:: KFbxEvent< ClassName <TemplateName,T> >\
00132 {\
00133 public: virtual const char* GetEventName() const {return FbxEventName();}\
00134 private: static const char* FbxEventName() {\
00135 static KString lEventName = (KString(#ClassName) +"<"+ KString(T) +">");\
00136 return lEventName.Buffer();\
00137 }\
00138 friend class KFbxEvent< ClassName<TemplateName, T> >;
00139
00140
00141
00142
00143 #define KFBXEVENT_TEMPLATE_FOOTER_NOT_FBXTYPE()\
00144 };
00145
00163
00164
00165
00166 template<typename EventT>
00167 class KFbxEvent : public KFbxEventBase
00168 {
00169 public:
00171 virtual ~KFbxEvent(){}
00172
00176 static void ForceTypeId(int pTypeId)
00177 {
00178 kfbxmp::KFbxMutexHelper lLock( smMutex );
00179
00180
00181
00182
00183 smTypeId = pTypeId;
00184 }
00185
00190 virtual int GetTypeId() const
00191 {
00192 return GetStaticTypeId();
00193 }
00194
00198 static int GetStaticTypeId()
00199 {
00200 if( !smTypeId )
00201 {
00202 kfbxmp::KFbxMutexHelper lLock( smMutex );
00203
00204 if( !smTypeId )
00205 {
00206
00207
00208 smTypeId = KFbxEventBase::GetStaticTypeId(EventT::FbxEventName());
00209 }
00210 }
00211
00212 return smTypeId;
00213 }
00214
00215 private:
00217 static int smTypeId;
00218 static kfbxmp::KFbxMutex smMutex;
00219 };
00220
00221
00222 template<typename EventT>
00223 int KFbxEvent<EventT>::smTypeId = 0;
00224 template<typename EventT>
00225 kfbxmp::KFbxMutex KFbxEvent<EventT>::smMutex;
00226 }
00227 using namespace kfbxevents;
00228
00229
00230
00231 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00232
00233 #endif // FBXFILESDK_KFBXEVENTS_KFBXEVENTS_H
00234