00001
00004 #ifndef _FBXSDK_PLUG_H_
00005 #define _FBXSDK_PLUG_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 <kaydaradef.h>
00042 #ifndef KFBX_DLL
00043 #define KFBX_DLL K_DLLIMPORT
00044 #endif
00045
00046 #include <kaydara.h>
00047
00048 #include <kfbxevents/kfbxemitter.h>
00049
00050 #include <kbaselib_nsbegin.h>
00051
00052 #include <kbaselib_nsend.h>
00053 #ifndef MB_FBXSDK
00054 #include <kbaselib_nsuse.h>
00055 #endif
00056
00057 #include <fbxfilesdk_nsbegin.h>
00058
00059 class KFbxPlug;
00060 class KFbxSdkManager;
00061 class KFbxClassIdInfo;
00062 class KFbxObject;
00063 class KFbxContainer;
00064 class KFbxPropertyHandle;
00065
00066 typedef KFbxPlug* (*kFbxPlugConstructor)(KFbxSdkManager& pManager, const char* pName, const KFbxPlug* pFrom, const char* pFBXType, const char* pFBXSubType);
00067
00073 class KFBX_DLL kFbxClassId
00074 {
00075 public:
00080
00082 kFbxClassId();
00083
00091 kFbxClassId(const char* pClassName, const kFbxClassId &pParentClassId, kFbxPlugConstructor pConstructor=0, const char* pFBXType=NULL, const char* pFBXSubType=NULL);
00092
00094 void Destroy();
00096
00100 const char* GetName() const;
00101
00105 kFbxClassId GetParent() const;
00106
00113 KFbxPlug* Create(KFbxSdkManager& pManager, const char* pName, const KFbxPlug* pFrom);
00114
00118 bool Override(kFbxPlugConstructor pConstructor);
00119
00124 bool Is(kFbxClassId const pId) const;
00125
00130 bool operator == (kFbxClassId const& pClassId) const;
00131
00135 inline KFbxClassIdInfo* GetClassIdInfo() { return mClassInfo; }
00136
00140 inline const KFbxClassIdInfo* GetClassIdInfo() const { return mClassInfo; }
00141
00142 private:
00143 friend class KFbxSdkManager;
00144
00146 bool SetFbxFileTypeName(const char* pName);
00147
00149 bool SetFbxFileSubTypeName(const char* pName);
00150
00151 public:
00156 const char* GetFbxFileTypeName(bool pAskParent=false) const;
00157
00159 const char* GetFbxFileSubTypeName() const;
00160
00161
00165 inline bool IsValid() const { return mClassInfo ? true : false; }
00166
00168 void SetObjectTypePrefix(const char* pObjectTypePrefix);
00169
00171 const char* GetObjectTypePrefix();
00172
00174 KFbxPropertyHandle* GetRootClassDefaultPropertyHandle();
00175
00179 int ClassInstanceIncRef();
00180
00184 int ClassInstanceDecRef();
00185
00189 int GetInstanceRef();
00190
00191 private:
00193 kFbxClassId(KFbxClassIdInfo* mClassInfo);
00194 KFbxClassIdInfo* mClassInfo;
00195 };
00196
00197 #define KFBXPLUG_DECLARE(Class) \
00198 public: \
00199 static kFbxClassId ClassId; \
00200 static Class* Create(KFbxSdkManager *pManager, const char *pName); \
00201 static Class* SdkManagerCreate(KFbxSdkManager *pManager, const char *pName, Class* pFrom) \
00202 { \
00203 Class* lClass = new Class(*pManager,pName); \
00204 lClass->Construct(pFrom); \
00205 return lClass; \
00206 } \
00207 virtual kFbxClassId GetClassId() const { return ClassId; } \
00208 \
00209 friend class FBXFILESDK_NAMESPACE::KFbxSdkManager;
00210
00211 #define KFBXPLUG_DECLARE_ABSTRACT(Class) \
00212 public: \
00213 static kFbxClassId ClassId; \
00214 static Class* Create(KFbxSdkManager *pManager, const char *pName); \
00215 static kFbxPlugConstructor SdkManagerCreate; \
00216 virtual kFbxClassId GetClassId() const { return ClassId; } \
00217 \
00218 friend class FBXFILESDK_NAMESPACE::KFbxSdkManager;
00219
00220 #define KFBXPLUG_IMPLEMENT(Class) \
00221 kFbxClassId Class::ClassId; \
00222 Class* Class::Create(KFbxSdkManager *pManager, const char *pName) \
00223 { \
00224 Class* ClassPtr=0; \
00225 return (Class *)pManager->CreateClass( Class::ClassId,pName,NULL ); \
00226 }
00227
00228 #define KFBXPLUG_IMPLEMENT_ABSTRACT(Class) \
00229 kFbxClassId Class::ClassId; \
00230 kFbxPlugConstructor Class::SdkManagerCreate = 0; \
00231 Class* Class::Create(KFbxSdkManager *pManager, const char *pName) \
00232 { \
00233 Class* ClassPtr=0; \
00234 return (Class *)pManager->CreateClass( Class::ClassId,pName, NULL ); \
00235 } \
00236
00237
00241 class KFBX_DLL KFbxPlug : public kfbxevents::KFbxEmitter
00242 {
00243 KFBXPLUG_DECLARE(KFbxPlug);
00244
00249 public:
00252 virtual void Destroy(bool pRecursive=false, bool pDependents=false);
00254
00259 public:
00263 virtual KFbxSdkManager* GetFbxSdkManager() const { return 0; }
00268 virtual bool Is(kFbxClassId pClassId) const { return GetClassId().Is(pClassId); }
00269 template < class T >inline bool Is(T *pFBX_TYPE) const { return Is(T::ClassId); }
00270 virtual bool IsRuntime(kFbxClassId pClassId) const { return GetRuntimeClassId().Is(pClassId); }
00271 virtual bool SetRuntimeClassId(kFbxClassId pClassId);
00272 virtual kFbxClassId GetRuntimeClassId() const;
00273 virtual bool IsRuntimePlug() const { return !( GetRuntimeClassId() == GetClassId() ); }
00275
00277
00278
00279
00280
00281
00282
00284 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00285 protected:
00286 inline KFbxPlug() {}
00287 inline KFbxPlug(KFbxSdkManager& pManager, const char* pName) {}
00288 virtual ~KFbxPlug() {}
00289
00290 virtual void Construct(const KFbxPlug* pFrom);
00291 virtual void Destruct(bool pRecursive, bool pDependents);
00292 friend class KFbxProperty;
00293 friend class KFbxObject;
00294 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00295 };
00296
00297 #define FBX_TYPE(class) ((class const*)0)
00298 #define FBX_CLASSID(class) (class::ClassId)
00299
00300 template < class T > inline T* KFbxCast(KFbxPlug *pPlug)
00301 {
00302 return pPlug && pPlug->Is(FBX_CLASSID(T)) ? (T *)pPlug : 0;
00303 }
00304
00305 template < class T > inline T const* KFbxCast(KFbxPlug const*pPlug)
00306 {
00307 return pPlug && pPlug->Is(FBX_CLASSID(T)) ? (T const*)pPlug : 0;
00308 }
00309
00310 #include <fbxfilesdk_nsend.h>
00311
00312 #endif // #ifndef _FBXSDK_PLUG_H_
00313