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