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 #include <fbxfilesdk/fbxfilesdk_def.h>
00042 
00043 #include <fbxfilesdk/kfbxevents/kfbxemitter.h>
00044 #include <fbxfilesdk/fbxfilesdk_new.h>
00045 
00046 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00047 
00048 class KFbxPlug;
00049 class KFbxSdkManager;
00050 class KFbxClassIdInfo;
00051 class KFbxObject;
00052 class KFbxPropertyHandle;
00053 
00054 typedef KFbxPlug* (*kFbxPlugConstructor)(KFbxSdkManager& pManager, const char* pName, const KFbxPlug* pFrom, const char* pFBXType, const char* pFBXSubType);
00055 
00060 class KFBX_DLL kFbxClassId
00061 {
00062 public:
00067  
00069     kFbxClassId();
00070 
00078     kFbxClassId(const char* pClassName, const kFbxClassId &pParentClassId, kFbxPlugConstructor pConstructor=0, const char* pFBXType=NULL, const char* pFBXSubType=NULL);
00079 
00081     void Destroy();
00083 
00087     const char* GetName() const;
00088 
00092     kFbxClassId GetParent() const;
00093 
00100     KFbxPlug* Create(KFbxSdkManager& pManager, const char* pName, const KFbxPlug* pFrom);
00101 
00105     bool Override(kFbxPlugConstructor pConstructor);
00106 
00111     bool Is(kFbxClassId const pId) const;
00112 
00117     bool operator==(kFbxClassId const& pClassId) const;
00118 
00123     bool operator!=(kFbxClassId const& pClassId) const;
00124 
00128     inline KFbxClassIdInfo* GetClassIdInfo() { return mClassInfo; }
00129 
00133     inline const KFbxClassIdInfo* GetClassIdInfo() const  { return mClassInfo; }
00134 
00135 private:
00136     friend class KFbxSdkManager;
00137 
00139     bool SetFbxFileTypeName(const char* pName);
00140 
00142     bool SetFbxFileSubTypeName(const char* pName);
00143     
00144 public:
00149     const char* GetFbxFileTypeName(bool pAskParent=false) const;
00150 
00152     const char* GetFbxFileSubTypeName() const;
00153 
00154 
00158     inline bool IsValid() const { return mClassInfo ? true : false; }
00159     
00163     void SetObjectTypePrefix(const char* pObjectTypePrefix);
00164 
00166     const char* GetObjectTypePrefix();
00167    
00169     KFbxPropertyHandle* GetRootClassDefaultPropertyHandle();
00170 
00174     int ClassInstanceIncRef();
00175 
00179     int ClassInstanceDecRef();
00180      
00184     int GetInstanceRef();
00185 
00186 private:
00188     kFbxClassId(KFbxClassIdInfo* mClassInfo);
00189     KFbxClassIdInfo* mClassInfo;
00190 };
00191 
00192 #define KFBXPLUG_DECLARE(Class)                                                                 \
00193 public:                                                                                         \
00194     KFBXNEW_DECLARE_FRIEND                                                                      \
00195     static kFbxClassId ClassId;                                                                 \
00196     static Class* Create(KFbxSdkManager *pManager, const char *pName);                          \
00197     static Class* SdkManagerCreate(KFbxSdkManager *pManager, const char *pName, Class* pFrom)   \
00198     {                                                                                           \
00199         Class* lClass = FbxSdkNew< Class >(*pManager,pName);                                    \
00200         lClass->Construct(pFrom);                                                               \
00201         return lClass;                                                                          \
00202     }                                                                                           \
00203     virtual kFbxClassId GetClassId() const { return ClassId; }                                  \
00204     friend class FBXFILESDK_NAMESPACE::KFbxSdkManager;                                          \
00205 
00206 #define KFBXPLUG_DECLARE_ABSTRACT(Class)                                \
00207 public:                                                                 \
00208     static kFbxClassId  ClassId;                                        \
00209     static Class* Create(KFbxSdkManager *pManager, const char *pName);  \
00210     static kFbxPlugConstructor SdkManagerCreate;                        \
00211     virtual kFbxClassId GetClassId() const { return ClassId; }          \
00212     friend class FBXFILESDK_NAMESPACE::KFbxSdkManager;                  \
00213 
00214 #define KFBXPLUG_IMPLEMENT(Class)                                           \
00215     kFbxClassId Class::ClassId;                                             \
00216     Class* Class::Create(KFbxSdkManager *pManager, const char *pName)       \
00217     {                                                                       \
00218         Class* ClassPtr = 0;                                                \
00219         return (Class*)pManager->CreateClass(Class::ClassId, pName, NULL);  \
00220     }                                                                       \
00221     
00222 #define KFBXPLUG_IMPLEMENT_ABSTRACT(Class)                                  \
00223     kFbxClassId Class::ClassId;                                             \
00224     kFbxPlugConstructor Class::SdkManagerCreate = 0;                        \
00225     Class* Class::Create(KFbxSdkManager *pManager, const char *pName)       \
00226     {                                                                       \
00227         Class* ClassPtr = 0;                                                \
00228         return (Class*)pManager->CreateClass(Class::ClassId, pName, NULL);  \
00229     }                                                                       \
00230     
00231 
00235 class KFBX_DLL KFbxPlug : public kfbxevents::KFbxEmitter
00236 {
00237     KFBXPLUG_DECLARE(KFbxPlug);
00238 
00243 public:
00248     virtual void Destroy(bool pRecursive=false, bool pDependents=false);
00250 
00255 public:
00259     virtual KFbxSdkManager* GetFbxSdkManager() const { return 0; }
00264     virtual bool                    Is(kFbxClassId pClassId) const          { return GetClassId().Is(pClassId); }
00265 
00270     template < class T >inline bool Is(T *pFBX_TYPE) const                  { return Is(T::ClassId); }
00271 
00276     virtual bool                    IsRuntime(kFbxClassId pClassId) const   { return GetRuntimeClassId().Is(pClassId);  }
00277 
00282     virtual bool                    SetRuntimeClassId(kFbxClassId pClassId);
00283 
00285     virtual kFbxClassId             GetRuntimeClassId() const;
00286 
00288     virtual bool                    IsRuntimePlug() const                   { return !( GetRuntimeClassId() == GetClassId() ); }
00290 
00292     //
00293     //  WARNING!
00294     //
00295     //  Anything beyond these lines may not be documented accurately and is 
00296     //  subject to change without notice.
00297     //
00299 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00300 protected:
00301     inline KFbxPlug() {}
00302     inline KFbxPlug(KFbxSdkManager& pManager, const char* pName) {}
00303     virtual ~KFbxPlug() {}
00304 
00305     virtual void Construct(const KFbxPlug* pFrom);
00306     virtual void Destruct(bool pRecursive, bool pDependents);
00307     friend class KFbxProperty;
00308     friend class KFbxObject;
00309 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00310 };
00311 
00312 #define FBX_TYPE(class) ((class const*)0)
00313 #define FBX_CLASSID(class) (class::ClassId)
00314 
00315 template < class T > inline T* KFbxCast(KFbxPlug *pPlug)
00316 {
00317     return pPlug && pPlug->Is(FBX_CLASSID(T)) ? (T *)pPlug : 0;
00318 }
00319 
00320 template < class T > inline T const* KFbxCast(KFbxPlug const*pPlug)
00321 {
00322     return pPlug && pPlug->Is(FBX_CLASSID(T)) ? (T const*)pPlug : 0;
00323 }
00324 
00325 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00326 
00327 #endif // FBXFILESDK_KFBXPLUGINS_KFBXPLUG_H
00328