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
00042 #include <fbxfilesdk/components/kbaselib/kaydaradef_h.h>
00043 #include <fbxfilesdk/components/kbaselib/kaydara.h>
00044
00045 #include <fbxfilesdk/kfbxevents/kfbxemitter.h>
00046
00047 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00048
00049 class KFbxPlug;
00050 class KFbxSdkManager;
00051 class KFbxClassIdInfo;
00052 class KFbxObject;
00053 class KFbxPropertyHandle;
00054
00055 typedef KFbxPlug* (*kFbxPlugConstructor)(KFbxSdkManager& pManager, const char* pName, const KFbxPlug* pFrom, const char* pFBXType, const char* pFBXSubType);
00056
00062 class KFBX_DLL kFbxClassId
00063 {
00064 public:
00069
00071 kFbxClassId();
00072
00080 kFbxClassId(const char* pClassName, const kFbxClassId &pParentClassId, kFbxPlugConstructor pConstructor=0, const char* pFBXType=NULL, const char* pFBXSubType=NULL);
00081
00083 void Destroy();
00085
00089 const char* GetName() const;
00090
00094 kFbxClassId GetParent() const;
00095
00102 KFbxPlug* Create(KFbxSdkManager& pManager, const char* pName, const KFbxPlug* pFrom);
00103
00107 bool Override(kFbxPlugConstructor pConstructor);
00108
00113 bool Is(kFbxClassId const pId) const;
00114
00119 bool operator == (kFbxClassId const& pClassId) const;
00120
00124 inline KFbxClassIdInfo* GetClassIdInfo() { return mClassInfo; }
00125
00129 inline const KFbxClassIdInfo* GetClassIdInfo() const { return mClassInfo; }
00130
00131 private:
00132 friend class KFbxSdkManager;
00133
00135 bool SetFbxFileTypeName(const char* pName);
00136
00138 bool SetFbxFileSubTypeName(const char* pName);
00139
00140 public:
00145 const char* GetFbxFileTypeName(bool pAskParent=false) const;
00146
00148 const char* GetFbxFileSubTypeName() const;
00149
00150
00154 inline bool IsValid() const { return mClassInfo ? true : false; }
00155
00159 void SetObjectTypePrefix(const char* pObjectTypePrefix);
00160
00162 const char* GetObjectTypePrefix();
00163
00165 KFbxPropertyHandle* GetRootClassDefaultPropertyHandle();
00166
00170 int ClassInstanceIncRef();
00171
00175 int ClassInstanceDecRef();
00176
00180 int GetInstanceRef();
00181
00182 private:
00184 kFbxClassId(KFbxClassIdInfo* mClassInfo);
00185 KFbxClassIdInfo* mClassInfo;
00186 };
00187
00188 #define KFBXPLUG_DECLARE(Class) \
00189 public: \
00190 static kFbxClassId ClassId; \
00191 static Class* Create(KFbxSdkManager *pManager, const char *pName); \
00192 static Class* SdkManagerCreate(KFbxSdkManager *pManager, const char *pName, Class* pFrom) \
00193 { \
00194 Class* lClass = new Class(*pManager,pName); \
00195 lClass->Construct(pFrom); \
00196 return lClass; \
00197 } \
00198 virtual kFbxClassId GetClassId() const { return ClassId; } \
00199 \
00200 friend class FBXFILESDK_NAMESPACE::KFbxSdkManager;
00201
00202 #define KFBXPLUG_DECLARE_ABSTRACT(Class) \
00203 public: \
00204 static kFbxClassId ClassId; \
00205 static Class* Create(KFbxSdkManager *pManager, const char *pName); \
00206 static kFbxPlugConstructor SdkManagerCreate; \
00207 virtual kFbxClassId GetClassId() const { return ClassId; } \
00208 \
00209 friend class FBXFILESDK_NAMESPACE::KFbxSdkManager;
00210
00211 #define KFBXPLUG_IMPLEMENT(Class) \
00212 kFbxClassId Class::ClassId; \
00213 Class* Class::Create(KFbxSdkManager *pManager, const char *pName) \
00214 { \
00215 Class* ClassPtr=0; \
00216 return (Class *)pManager->CreateClass( Class::ClassId,pName,NULL ); \
00217 }
00218
00219 #define KFBXPLUG_IMPLEMENT_ABSTRACT(Class) \
00220 kFbxClassId Class::ClassId; \
00221 kFbxPlugConstructor Class::SdkManagerCreate = 0; \
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
00232 class KFBX_DLL KFbxPlug : public kfbxevents::KFbxEmitter
00233 {
00234 KFBXPLUG_DECLARE(KFbxPlug);
00235
00240 public:
00245 virtual void Destroy(bool pRecursive=false, bool pDependents=false);
00247
00252 public:
00256 virtual KFbxSdkManager* GetFbxSdkManager() const { return 0; }
00261 virtual bool Is(kFbxClassId pClassId) const { return GetClassId().Is(pClassId); }
00262
00267 template < class T >inline bool Is(T *pFBX_TYPE) const { return Is(T::ClassId); }
00268
00273 virtual bool IsRuntime(kFbxClassId pClassId) const { return GetRuntimeClassId().Is(pClassId); }
00274
00279 virtual bool SetRuntimeClassId(kFbxClassId pClassId);
00280
00282 virtual kFbxClassId GetRuntimeClassId() const;
00283 virtual bool IsRuntimePlug() const { return !( GetRuntimeClassId() == GetClassId() ); }
00285
00287
00288
00289
00290
00291
00292
00294 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00295 protected:
00296 inline KFbxPlug() {}
00297 inline KFbxPlug(KFbxSdkManager& pManager, const char* pName) {}
00298 virtual ~KFbxPlug() {}
00299
00300 virtual void Construct(const KFbxPlug* pFrom);
00301 virtual void Destruct(bool pRecursive, bool pDependents);
00302 friend class KFbxProperty;
00303 friend class KFbxObject;
00304 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00305 };
00306
00307 #define FBX_TYPE(class) ((class const*)0)
00308 #define FBX_CLASSID(class) (class::ClassId)
00309
00310 template < class T > inline T* KFbxCast(KFbxPlug *pPlug)
00311 {
00312 return pPlug && pPlug->Is(FBX_CLASSID(T)) ? (T *)pPlug : 0;
00313 }
00314
00315 template < class T > inline T const* KFbxCast(KFbxPlug const*pPlug)
00316 {
00317 return pPlug && pPlug->Is(FBX_CLASSID(T)) ? (T const*)pPlug : 0;
00318 }
00319
00320 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00321
00322 #endif // FBXFILESDK_KFBXPLUGINS_KFBXPLUG_H
00323