FBX SDK Reference Guide: kfbxplug.h Source File
Go to the documentation of this file.
00001 
00004 #ifndef _FBXSDK_PLUG_H_
00005 #define _FBXSDK_PLUG_H_
00006 /**************************************************************************************
00007 
00008  Copyright © 2001 - 2008 Autodesk, Inc. and/or its licensors.
00009  All Rights Reserved.
00010 
00011  The coded instructions, statements, computer programs, and/or related material 
00012  (collectively the "Data") in these files contain unpublished information 
00013  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00014  Canada and United States of America federal copyright law and by international 
00015  treaties. 
00016  
00017  The Data may not be disclosed or distributed to third parties, in whole or in
00018  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00019 
00020  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00021  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00022  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00023  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00024  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00025  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00026  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00027  
00028  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00029  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00030  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00031  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00032  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00033  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00034  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00035  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00036  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00037  OR DAMAGE. 
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> // namespace 
00051 
00052 #include <kbaselib_nsend.h> // namespace 
00053 #ifndef MB_FBXSDK
00054     #include <kbaselib_nsuse.h> // namespace 
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     //  WARNING!
00279     //
00280     //  Anything beyond these lines may not be documented accurately and is 
00281     //  subject to change without notice.
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