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 - 2010 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 
00055 typedef KFbxPlug* (*kFbxPlugConstructor)(KFbxSdkManager& pManager, const char* pName, const KFbxPlug* pFrom, const char* pFBXType, const char* pFBXSubType);
00056 
00072 class KFBX_DLL kFbxClassId
00073 {
00074 public:
00076     kFbxClassId();
00077 
00085     kFbxClassId(const char* pClassName, const kFbxClassId &pParentClassId, kFbxPlugConstructor pConstructor=0, const char* pFBXType=NULL, const char* pFBXSubType=NULL);
00086 
00088     void Destroy();
00089 
00093     const char* GetName() const;
00094 
00098     kFbxClassId GetParent() const;
00099 
00106     KFbxPlug* Create(KFbxSdkManager& pManager, const char* pName, const KFbxPlug* pFrom);
00107 
00112     bool Override(kFbxPlugConstructor pConstructor);
00113 
00119     bool Is(kFbxClassId const pId) const;
00120 
00126     bool operator==(kFbxClassId const& pClassId) const;
00127 
00133     bool operator!=(kFbxClassId const& pClassId) const;
00134 
00135 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00136 
00139     inline KFbxClassIdInfo* GetClassIdInfo() { return mClassInfo; }
00140 
00144     inline const KFbxClassIdInfo* GetClassIdInfo() const { return mClassInfo; }
00145 #endif 
00146     
00151     const char* GetFbxFileTypeName(bool pAskParent=false) const;
00152 
00157     const char* GetFbxFileSubTypeName() const;
00158 
00162     inline bool IsValid() const { return mClassInfo ? true : false; }
00163     
00169     void SetObjectTypePrefix(const char* pObjectTypePrefix);
00170 
00174     const char* GetObjectTypePrefix();
00175    
00180     KFbxPropertyHandle* GetRootClassDefaultPropertyHandle();
00181 
00185     int ClassInstanceIncRef();
00186 
00190     int ClassInstanceDecRef();
00191      
00195     int GetInstanceRef();
00196 
00198 //
00199 //  WARNING!
00200 //
00201 //  Anything beyond these lines may not be documented accurately and is 
00202 //  subject to change without notice.
00203 //
00205 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00206 private:
00207     kFbxClassId(KFbxClassIdInfo* mClassInfo);
00208 
00209     bool SetFbxFileTypeName(const char* pName);
00210     bool SetFbxFileSubTypeName(const char* pName);
00211 
00212     KFbxClassIdInfo* mClassInfo;
00213 
00214     friend class KFbxSdkManager;
00215 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00216 };
00217 
00219 #define KFBXPLUG_DECLARE(Class)                                                                 \
00220 public:                                                                                         \
00221     KFBXNEW_DECLARE_FRIEND                                                                      \
00222     static kFbxClassId ClassId;                                                                 \
00223     static Class* Create(KFbxSdkManager *pManager, const char *pName);                          \
00224     static Class* SdkManagerCreate(KFbxSdkManager *pManager, const char *pName, Class* pFrom)   \
00225     {                                                                                           \
00226         Class* lClass = FbxSdkNew< Class >(*pManager, pName);                                   \
00227         lClass->Construct(pFrom);                                                               \
00228         return lClass;                                                                          \
00229     }                                                                                           \
00230     virtual kFbxClassId GetClassId() const { return ClassId; }                                  \
00231     friend class FBXFILESDK_NAMESPACE::KFbxSdkManager;                                          \
00232 
00233 
00234 #define KFBXPLUG_DECLARE_ABSTRACT(Class)                                                        \
00235 public:                                                                                         \
00236     static kFbxClassId ClassId;                                                                 \
00237     static Class* Create(KFbxSdkManager *pManager, const char *pName);                          \
00238     static kFbxPlugConstructor SdkManagerCreate;                                                \
00239     virtual kFbxClassId GetClassId() const { return ClassId; }                                  \
00240     friend class FBXFILESDK_NAMESPACE::KFbxSdkManager;                                          \
00241 
00242 
00243 #define KFBXPLUG_IMPLEMENT(Class)                                                               \
00244     kFbxClassId Class::ClassId;                                                                 \
00245     Class* Class::Create(KFbxSdkManager* pManager, const char* pName)                           \
00246     {                                                                                           \
00247         Class* ClassPtr;                                                                        \
00248         ClassPtr = 0;                                                                           \
00249         return (Class*)pManager->CreateNewObjectFromClassId(Class::ClassId, pName);             \
00250     }                                                                                           \
00251     
00252 
00253 #define KFBXPLUG_IMPLEMENT_ABSTRACT(Class)                                                      \
00254     kFbxClassId Class::ClassId;                                                                 \
00255     kFbxPlugConstructor Class::SdkManagerCreate = 0;                                            \
00256     Class* Class::Create(KFbxSdkManager *pManager, const char *pName)                           \
00257     {                                                                                           \
00258         Class* ClassPtr;                                                                        \
00259         ClassPtr = 0;                                                                           \
00260         return (Class*)pManager->CreateNewObjectFromClassId(Class::ClassId, pName);             \
00261     }                                                                                           \
00262     
00263 
00267 class KFBX_DLL KFbxPlug : public kfbxevents::KFbxEmitter
00268 {
00269     KFBXPLUG_DECLARE(KFbxPlug);
00270 
00271 public:
00277     virtual void Destroy(bool pRecursive=false, bool pDependents=false);
00278 
00283     virtual KFbxSdkManager* GetFbxSdkManager() const { return 0; }
00284 
00290     virtual bool Is(kFbxClassId pClassId) const { return GetClassId().Is(pClassId); }
00291 
00297     template < class T >inline bool Is(T *pFBX_TYPE) const                  { return Is(T::ClassId); }
00298 
00305     virtual bool IsRuntime(kFbxClassId pClassId) const { return GetRuntimeClassId().Is(pClassId); }
00306 
00314     virtual bool SetRuntimeClassId(kFbxClassId pClassId);
00315 
00319     virtual kFbxClassId GetRuntimeClassId() const;
00320 
00324     virtual bool IsRuntimePlug() const { return !( GetRuntimeClassId() == GetClassId() ); }
00325 
00327 //
00328 //  WARNING!
00329 //
00330 //  Anything beyond these lines may not be documented accurately and is 
00331 //  subject to change without notice.
00332 //
00334 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00335     inline static void SetWipeMode(bool pState) { KFbxPlug::sgWipeMode = pState; }
00336     inline static bool GetWipeMode() { return KFbxPlug::sgWipeMode; }
00337 
00338 private:
00339     // used as global flag to modify the behavior of KFbxObject::Destruct() during a ForceKill() on the scene.
00340     // This is for internal use
00341     static bool sgWipeMode;
00342 
00343 protected:
00344     inline KFbxPlug() {}
00345     inline KFbxPlug(KFbxSdkManager& pManager, const char* pName) {}
00346     virtual ~KFbxPlug() {}
00347 
00348     virtual void Construct(const KFbxPlug* pFrom);
00349     virtual void Destruct(bool pRecursive, bool pDependents);
00350     friend class KFbxProperty;
00351     friend class KFbxObject;
00352 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00353 };
00354 
00362 #define FBX_TYPE(class) ((class const*)0)
00363 
00374 #define FBX_CLASSID(class) (class::ClassId)
00375 
00382 template < class T > inline T* KFbxCast(KFbxPlug *pPlug)
00383 {
00384     return pPlug && pPlug->Is(FBX_CLASSID(T)) ? (T *)pPlug : 0;
00385 }
00386 
00393 template < class T > inline T const* KFbxCast(KFbxPlug const*pPlug)
00394 {
00395     return pPlug && pPlug->Is(FBX_CLASSID(T)) ? (T const*)pPlug : 0;
00396 }
00397 
00398 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00399 
00400 #endif // FBXFILESDK_KFBXPLUGINS_KFBXPLUG_H
00401