00001
00004 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXPLUG_H
00005 #define FBXFILESDK_KFBXPLUGINS_KFBXPLUG_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/kfbxevents/kfbxemitter.h>
00044 #include <fbxfilesdk/fbxfilesdk_new.h>
00045
00046 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00047
00048 class KFbxPlug;
00049 class KFbxSdkManager;
00050 class KFbxClassIdInfo;
00051 class KFbxObject;
00052 class KFbxPropertyHandle;
00053
00054 typedef KFbxPlug* (*kFbxPlugConstructor)(KFbxSdkManager& pManager, const char* pName, const KFbxPlug* pFrom, const char* pFBXType, const char* pFBXSubType);
00055
00060 class KFBX_DLL kFbxClassId
00061 {
00062 public:
00067
00069 kFbxClassId();
00070
00078 kFbxClassId(const char* pClassName, const kFbxClassId &pParentClassId, kFbxPlugConstructor pConstructor=0, const char* pFBXType=NULL, const char* pFBXSubType=NULL);
00079
00081 void Destroy();
00083
00087 const char* GetName() const;
00088
00092 kFbxClassId GetParent() const;
00093
00100 KFbxPlug* Create(KFbxSdkManager& pManager, const char* pName, const KFbxPlug* pFrom);
00101
00105 bool Override(kFbxPlugConstructor pConstructor);
00106
00111 bool Is(kFbxClassId const pId) const;
00112
00117 bool operator==(kFbxClassId const& pClassId) const;
00118
00123 bool operator!=(kFbxClassId const& pClassId) const;
00124
00128 inline KFbxClassIdInfo* GetClassIdInfo() { return mClassInfo; }
00129
00133 inline const KFbxClassIdInfo* GetClassIdInfo() const { return mClassInfo; }
00134
00135 private:
00136 friend class KFbxSdkManager;
00137
00139 bool SetFbxFileTypeName(const char* pName);
00140
00142 bool SetFbxFileSubTypeName(const char* pName);
00143
00144 public:
00149 const char* GetFbxFileTypeName(bool pAskParent=false) const;
00150
00152 const char* GetFbxFileSubTypeName() const;
00153
00154
00158 inline bool IsValid() const { return mClassInfo ? true : false; }
00159
00163 void SetObjectTypePrefix(const char* pObjectTypePrefix);
00164
00166 const char* GetObjectTypePrefix();
00167
00169 KFbxPropertyHandle* GetRootClassDefaultPropertyHandle();
00170
00174 int ClassInstanceIncRef();
00175
00179 int ClassInstanceDecRef();
00180
00184 int GetInstanceRef();
00185
00186 private:
00188 kFbxClassId(KFbxClassIdInfo* mClassInfo);
00189 KFbxClassIdInfo* mClassInfo;
00190 };
00191
00192 #define KFBXPLUG_DECLARE(Class) \
00193 public: \
00194 KFBXNEW_DECLARE_FRIEND \
00195 static kFbxClassId ClassId; \
00196 static Class* Create(KFbxSdkManager *pManager, const char *pName); \
00197 static Class* SdkManagerCreate(KFbxSdkManager *pManager, const char *pName, Class* pFrom) \
00198 { \
00199 Class* lClass = FbxSdkNew< Class >(*pManager,pName); \
00200 lClass->Construct(pFrom); \
00201 return lClass; \
00202 } \
00203 virtual kFbxClassId GetClassId() const { return ClassId; } \
00204 friend class FBXFILESDK_NAMESPACE::KFbxSdkManager; \
00205
00206 #define KFBXPLUG_DECLARE_ABSTRACT(Class) \
00207 public: \
00208 static kFbxClassId ClassId; \
00209 static Class* Create(KFbxSdkManager *pManager, const char *pName); \
00210 static kFbxPlugConstructor SdkManagerCreate; \
00211 virtual kFbxClassId GetClassId() const { return ClassId; } \
00212 friend class FBXFILESDK_NAMESPACE::KFbxSdkManager; \
00213
00214 #define KFBXPLUG_IMPLEMENT(Class) \
00215 kFbxClassId Class::ClassId; \
00216 Class* Class::Create(KFbxSdkManager *pManager, const char *pName) \
00217 { \
00218 Class* ClassPtr = 0; \
00219 return (Class*)pManager->CreateClass(Class::ClassId, pName, NULL); \
00220 } \
00221
00222 #define KFBXPLUG_IMPLEMENT_ABSTRACT(Class) \
00223 kFbxClassId Class::ClassId; \
00224 kFbxPlugConstructor Class::SdkManagerCreate = 0; \
00225 Class* Class::Create(KFbxSdkManager *pManager, const char *pName) \
00226 { \
00227 Class* ClassPtr = 0; \
00228 return (Class*)pManager->CreateClass(Class::ClassId, pName, NULL); \
00229 } \
00230
00231
00235 class KFBX_DLL KFbxPlug : public kfbxevents::KFbxEmitter
00236 {
00237 KFBXPLUG_DECLARE(KFbxPlug);
00238
00243 public:
00248 virtual void Destroy(bool pRecursive=false, bool pDependents=false);
00250
00255 public:
00259 virtual KFbxSdkManager* GetFbxSdkManager() const { return 0; }
00264 virtual bool Is(kFbxClassId pClassId) const { return GetClassId().Is(pClassId); }
00265
00270 template < class T >inline bool Is(T *pFBX_TYPE) const { return Is(T::ClassId); }
00271
00276 virtual bool IsRuntime(kFbxClassId pClassId) const { return GetRuntimeClassId().Is(pClassId); }
00277
00282 virtual bool SetRuntimeClassId(kFbxClassId pClassId);
00283
00285 virtual kFbxClassId GetRuntimeClassId() const;
00286
00288 virtual bool IsRuntimePlug() const { return !( GetRuntimeClassId() == GetClassId() ); }
00290
00292
00293
00294
00295
00296
00297
00299 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00300 protected:
00301 inline KFbxPlug() {}
00302 inline KFbxPlug(KFbxSdkManager& pManager, const char* pName) {}
00303 virtual ~KFbxPlug() {}
00304
00305 virtual void Construct(const KFbxPlug* pFrom);
00306 virtual void Destruct(bool pRecursive, bool pDependents);
00307 friend class KFbxProperty;
00308 friend class KFbxObject;
00309 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00310 };
00311
00312 #define FBX_TYPE(class) ((class const*)0)
00313 #define FBX_CLASSID(class) (class::ClassId)
00314
00315 template < class T > inline T* KFbxCast(KFbxPlug *pPlug)
00316 {
00317 return pPlug && pPlug->Is(FBX_CLASSID(T)) ? (T *)pPlug : 0;
00318 }
00319
00320 template < class T > inline T const* KFbxCast(KFbxPlug const*pPlug)
00321 {
00322 return pPlug && pPlug->Is(FBX_CLASSID(T)) ? (T const*)pPlug : 0;
00323 }
00324
00325 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00326
00327 #endif // FBXFILESDK_KFBXPLUGINS_KFBXPLUG_H
00328