kfbxplug.h

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 (C) 2001 - 2009 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 
00061 class KFBX_DLL kFbxClassId
00062 {
00063 public:
00068  
00070     kFbxClassId();
00071 
00079     kFbxClassId(const char* pClassName, const kFbxClassId &pParentClassId, kFbxPlugConstructor pConstructor=0, const char* pFBXType=NULL, const char* pFBXSubType=NULL);
00080 
00082     void Destroy();
00084 
00088     const char* GetName() const;
00089 
00093     kFbxClassId GetParent() const;
00094 
00101     KFbxPlug* Create(KFbxSdkManager& pManager, const char* pName, const KFbxPlug* pFrom);
00102 
00106     bool Override(kFbxPlugConstructor pConstructor);
00107 
00112     bool Is(kFbxClassId const pId) const;
00113 
00118     bool operator == (kFbxClassId const& pClassId) const;
00119 
00123     inline KFbxClassIdInfo* GetClassIdInfo() { return mClassInfo; }
00124 
00128     inline const KFbxClassIdInfo* GetClassIdInfo() const  { return mClassInfo; }
00129 
00130 private:
00131     friend class KFbxSdkManager;
00132 
00134     bool SetFbxFileTypeName(const char* pName);
00135 
00137     bool SetFbxFileSubTypeName(const char* pName);
00138     
00139 public:
00144     const char* GetFbxFileTypeName(bool pAskParent=false) const;
00145 
00147     const char* GetFbxFileSubTypeName() const;
00148 
00149 
00153     inline bool IsValid() const { return mClassInfo ? true : false; }
00154     
00158     void SetObjectTypePrefix(const char* pObjectTypePrefix);
00159 
00161     const char* GetObjectTypePrefix();
00162    
00164     KFbxPropertyHandle* GetRootClassDefaultPropertyHandle();
00165 
00169     int ClassInstanceIncRef();
00170 
00174     int ClassInstanceDecRef();
00175      
00179     int GetInstanceRef();
00180 
00181 private:
00183     kFbxClassId(KFbxClassIdInfo* mClassInfo);
00184     KFbxClassIdInfo* mClassInfo;
00185 };
00186 
00187 #define KFBXPLUG_DECLARE(Class)                                                                 \
00188 public:                                                                                         \
00189     static kFbxClassId ClassId;                                                                 \
00190     static Class* Create(KFbxSdkManager *pManager, const char *pName);                          \
00191     static Class* SdkManagerCreate(KFbxSdkManager *pManager, const char *pName, Class* pFrom)   \
00192     {                                                                                           \
00193         Class* lClass = new Class(*pManager,pName);                                             \
00194         lClass->Construct(pFrom);                                                               \
00195         return lClass;                                                                          \
00196     }                                                                                           \
00197     virtual kFbxClassId GetClassId() const { return ClassId; }                                  \
00198     friend class FBXFILESDK_NAMESPACE::KFbxSdkManager;                                          \
00199 
00200 #define KFBXPLUG_DECLARE_ABSTRACT(Class)                                \
00201 public:                                                                 \
00202     static kFbxClassId  ClassId;                                        \
00203     static Class* Create(KFbxSdkManager *pManager, const char *pName);  \
00204     static kFbxPlugConstructor SdkManagerCreate;                        \
00205     virtual kFbxClassId GetClassId() const { return ClassId; }          \
00206     friend class FBXFILESDK_NAMESPACE::KFbxSdkManager;                  \
00207 
00208 #define KFBXPLUG_IMPLEMENT(Class)                                           \
00209     kFbxClassId Class::ClassId;                                             \
00210     Class* Class::Create(KFbxSdkManager *pManager, const char *pName)       \
00211     {                                                                       \
00212         Class* ClassPtr = 0;                                                \
00213         return (Class*)pManager->CreateClass(Class::ClassId, pName, NULL);  \
00214     }                                                                       \
00215     
00216 #define KFBXPLUG_IMPLEMENT_ABSTRACT(Class)                                  \
00217     kFbxClassId Class::ClassId;                                             \
00218     kFbxPlugConstructor Class::SdkManagerCreate = 0;                        \
00219     Class* Class::Create(KFbxSdkManager *pManager, const char *pName)       \
00220     {                                                                       \
00221         Class* ClassPtr = 0;                                                \
00222         return (Class*)pManager->CreateClass(Class::ClassId, pName, NULL);  \
00223     }                                                                       \
00224     
00225 
00229 class KFBX_DLL KFbxPlug : public kfbxevents::KFbxEmitter
00230 {
00231     KFBXPLUG_DECLARE(KFbxPlug);
00232 
00237 public:
00242     virtual void Destroy(bool pRecursive=false, bool pDependents=false);
00244 
00249 public:
00253     virtual KFbxSdkManager* GetFbxSdkManager() const { return 0; }
00258     virtual bool                    Is(kFbxClassId pClassId) const          { return GetClassId().Is(pClassId); }
00259 
00264     template < class T >inline bool Is(T *pFBX_TYPE) const                  { return Is(T::ClassId); }
00265 
00270     virtual bool                    IsRuntime(kFbxClassId pClassId) const   { return GetRuntimeClassId().Is(pClassId);  }
00271 
00276     virtual bool                    SetRuntimeClassId(kFbxClassId pClassId);
00277 
00279     virtual kFbxClassId             GetRuntimeClassId() const;
00280 
00282     virtual bool                    IsRuntimePlug() const                   { return !( GetRuntimeClassId() == GetClassId() ); }
00284 
00286     //
00287     //  WARNING!
00288     //
00289     //  Anything beyond these lines may not be documented accurately and is 
00290     //  subject to change without notice.
00291     //
00293 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00294 protected:
00295     inline KFbxPlug() {}
00296     inline KFbxPlug(KFbxSdkManager& pManager, const char* pName) {}
00297     virtual ~KFbxPlug() {}
00298 
00299     virtual void Construct(const KFbxPlug* pFrom);
00300     virtual void Destruct(bool pRecursive, bool pDependents);
00301     friend class KFbxProperty;
00302     friend class KFbxObject;
00303 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00304 };
00305 
00306 #define FBX_TYPE(class) ((class const*)0)
00307 #define FBX_CLASSID(class) (class::ClassId)
00308 
00309 template < class T > inline T* KFbxCast(KFbxPlug *pPlug)
00310 {
00311     return pPlug && pPlug->Is(FBX_CLASSID(T)) ? (T *)pPlug : 0;
00312 }
00313 
00314 template < class T > inline T const* KFbxCast(KFbxPlug const*pPlug)
00315 {
00316     return pPlug && pPlug->Is(FBX_CLASSID(T)) ? (T const*)pPlug : 0;
00317 }
00318 
00319 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00320 
00321 #endif // FBXFILESDK_KFBXPLUGINS_KFBXPLUG_H
00322