fbxmanager.h

Go to the documentation of this file.
00001 /****************************************************************************************
00002  
00003    Copyright (C) 2013 Autodesk, Inc.
00004    All rights reserved.
00005  
00006    Use of this software is subject to the terms of the Autodesk license agreement
00007    provided at the time of installation or download, or which otherwise accompanies
00008    this software in either electronic or hard copy form.
00009  
00010 ****************************************************************************************/
00011 
00013 #ifndef _FBXSDK_CORE_MANAGER_H_
00014 #define _FBXSDK_CORE_MANAGER_H_
00015 
00016 #include <fbxsdk/fbxsdk_def.h>
00017 
00018 #include <fbxsdk/core/fbxobject.h>
00019 
00020 #include <fbxsdk/fbxsdk_nsbegin.h>
00021 
00022 class FbxIOSettings;
00023 class FbxIOPluginRegistry;
00024 class FbxSceneReference;
00025 class FbxUserNotification;
00026 class FbxMessageEmitter;
00027 class FbxLocalizationManager;
00028 class FbxXRefManager;
00029 class FbxManager_internal;
00030 
00031 #ifndef FBXSDK_ENV_WINRT
00032     class FbxPlugin;
00033 #endif
00034 
00055 class FBXSDK_DLL FbxManager
00056 {
00057 public:
00066         static FbxManager* Create();
00067 
00071         virtual void Destroy();
00073 
00082         static const char* GetVersion(bool pFull=true);
00083 
00089         static void GetFileFormatVersion(int& pMajor, int& pMinor, int& pRevision);
00091 
00092 
00107         template <typename T1, typename T2> inline FbxClassId RegisterFbxClass(char const* pName, const T1*, const T2*, const char* pFbxFileTypeName=0, const char* pFbxFileSubTypeName=0)
00108         {
00109             T1::ClassId = Internal_RegisterFbxClass(pName, T2::ClassId, (FbxObjectCreateProc)T1::Allocate, pFbxFileTypeName, pFbxFileSubTypeName);
00110             return T1::ClassId;
00111         }
00112      
00122         template <typename T> inline FbxClassId RegisterRuntimeFbxClass(char const* pName, const T*, const char* pFbxFileTypeName=0,const char* pFbxFileSubTypeName=0)
00123         {
00124             return Internal_RegisterFbxClass(pName, T::ClassId, (FbxObjectCreateProc)T::Allocate, pFbxFileTypeName, pFbxFileSubTypeName);
00125         }
00126         
00130         inline void UnregisterRuntimeFbxClass(char const* pName)
00131         {
00132             FbxClassId lClassId = FindClass(pName);
00133             if( !(lClassId == FbxClassId()) )
00134             {
00135                 Internal_UnregisterFbxClass(lClassId);
00136             }
00137         }
00138         
00144         template <typename T1,typename T2> inline FbxClassId OverrideFbxClass(const T1* pFBX_TYPE_Class, const T2* pFBX_TYPE_OverridenClass)
00145         {
00146             T1::ClassId  = Internal_OverrideFbxClass(T2::ClassId,(FbxObjectCreateProc)T1::Allocate );
00147             return T1::ClassId;
00148         }
00149 
00160         FbxObject* CreateNewObjectFromClassId(FbxClassId pClassId, char const* pName, FbxObject* pContainer=NULL, const FbxObject* pCloneFrom=NULL);
00161 
00165         FbxClassId FindClass(const char* pClassName) const;
00166 
00171         FbxClassId FindFbxFileClass(const char* pFbxFileTypeName, const char* pFbxFileSubTypeName) const;
00172 
00176         template <typename T> inline void UnregisterFbxClass(const T* pFBX_TYPE_Class)
00177         {
00178             Internal_UnregisterFbxClass(T::ClassId);
00179             T::ClassId = FbxClassId();
00180         }
00182 
00192         FbxDataType CreateDataType(const char* pName, const EFbxType pType);
00193 
00197         int GetDataTypeCount() const;
00198 
00203         FbxDataType& GetDataType(const int pIndex) const;
00204 
00209         FbxDataType& GetDataTypeFromName(const char* pDataType) const;
00211 
00220         FbxUserNotification* GetUserNotification() const;
00221 
00225         void SetUserNotification(FbxUserNotification* pUN);
00227 
00236         virtual FbxIOSettings* GetIOSettings() const;
00237 
00241         virtual void SetIOSettings(FbxIOSettings* pIOSettings);
00243 
00244 
00252         FbxMessageEmitter& GetMessageEmitter();
00257         bool SetMessageEmitter(FbxMessageEmitter* pMessageEmitter);
00259 
00260         
00268         void AddLocalization(FbxLocalizationManager* pLocManager);
00269 
00273         void RemoveLocalization(FbxLocalizationManager* pLocManager);
00274 
00278         bool SetLocale(const char* pLocale);
00279 
00286         const char* Localize(const char* pID, const char* pDefault=NULL) const;
00288 
00296         FbxXRefManager& GetXRefManager();
00298 
00306         FbxLibrary* GetRootLibrary() const;
00307         FbxLibrary* GetSystemLibraries() const;
00308         FbxLibrary* GetUserLibraries() const;
00310 
00318         FbxIOPluginRegistry* GetIOPluginRegistry() const;
00320 
00325     #ifndef FBXSDK_ENV_WINRT
00326 
00331         bool LoadPluginsDirectory(const char* pFilename, const char* pExtensions=NULL);
00332 
00337         bool LoadPlugin(const char* pFilename);
00338 
00341         bool UnloadPlugins();
00342 
00346         bool EmitPluginsEvent(const FbxEventBase& pEvent);
00347        
00349         FbxArray<const FbxPlugin*> GetPlugins() const;
00350 
00354         int GetPluginCount() const;
00355 
00361         FbxPlugin* FindPlugin(const char* pName, const char* pVersion) const;
00362     #endif /* !FBXSDK_ENV_WINRT */
00363 
00364 
00365 
00370     // Add IOSettings in hierarchy from different modules
00371 
00375         void FillIOSettingsForReadersRegistered(FbxIOSettings& pIOS);
00376 
00380         void FillIOSettingsForWritersRegistered(FbxIOSettings& pIOS);
00381 
00386         void FillCommonIOSettings(FbxIOSettings& pIOS, bool pImport);
00388 
00398         void RegisterObject(FbxObject* pObject);
00399 
00404         void UnregisterObject(FbxObject* pObject);
00405 
00410         void RegisterObjects(const FbxArray<FbxObject*>& pArray);
00411 
00416         void UnregisterObjects(const FbxArray<FbxObject*>& pArray);
00417 
00421         void IncreaseDestroyingSceneFlag();
00426         void DecreaseDestroyingSceneFlag();
00434         int GetReferenceCount() const;
00435 
00440         FbxSceneReference* GetReference(int pIndex) const;
00441 
00447         int AddReference(FbxSceneReference* pReference);
00448 
00454         bool RemoveReference(FbxSceneReference* pReference);
00455 
00461         bool ClearReference(FbxSceneReference* pReference);
00463 
00473     static FbxString PrefixName(char const* pPrefix, char const* pName);
00474 
00478     int GetDocumentCount();
00479 
00484     FbxDocument* GetDocument(int pIndex);
00485 
00486 /*****************************************************************************************************************************
00487 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
00488 *****************************************************************************************************************************/
00489 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00490     static FbxManager*  GetDefaultManager();
00491     void                CreateMissingBindPoses(FbxScene* pScene);
00492     int                 GetBindPoseCount(FbxScene *pScene) const;
00493     int                 GetFbxClassCount() const;
00494     FbxClassId          GetNextFbxClass(FbxClassId pClassId /* invalid id: first one */) const;
00495 
00496 protected:
00497     FbxManager();
00498     virtual ~FbxManager();
00499 
00500     void Clear();
00501     void ClassInit();
00502     void ClassRelease();
00503     void DataTypeInit();
00504     void DataTypeRelease();
00505 
00506 private:
00507     bool        CanAutoDestroySrcObject(FbxObject* pObject, FbxObject* pSrcObject, bool pRecursive) const;
00508 
00509     void        Create_Common_Import_IOSettings_Groups(FbxIOSettings& pIOS);
00510     void        Create_Common_Export_IOSettings_Groups(FbxIOSettings& pIOS);
00511     void        Add_Common_Import_IOSettings(FbxIOSettings& pIOS);
00512     void        Add_Common_Export_IOSettings(FbxIOSettings& pIOS);
00513     void        Add_Common_RW_Import_IOSettings(FbxIOSettings& pIOS);
00514     void        Add_Common_RW_Export_IOSettings(FbxIOSettings& pIOS);
00515 
00516     FbxClassId  Internal_RegisterFbxClass(const char* pClassName, FbxClassId pParentClassId, FbxObjectCreateProc=0, char const* pFbxFileTypeName=0, char const* pFbxFileSubTypeName=0);
00517     bool        Internal_RegisterFbxClass(FbxClassId pClassId);
00518     FbxClassId  Internal_OverrideFbxClass(FbxClassId pClassId, FbxObjectCreateProc=0);
00519     void        Internal_UnregisterFbxClass(FbxClassId pClassId);
00520 
00521     void        RemoveObjectsOfType(const FbxClassId& pClassId);
00522 
00523     FbxArray<FbxObject*>                mObjects;
00524     FbxArray<FbxDocument*>              mDocuments;
00525 
00526     FbxIOSettings*                      mIOSettings;
00527     FbxIOPluginRegistry*                mRegistry;
00528     FbxUserNotification*                mUserNotification;
00529     FbxMessageEmitter*                  mMessageEmitter;
00530     FbxArray<FbxLocalizationManager*>   mLocalizationManagerArray;
00531     FbxArray<FbxSceneReference*>        mSceneReferenceArray;
00532 
00533     FbxArray<FbxObject*>                mDestroyingObjects;
00534     FbxArray<FbxDocument*>              mDestroyingDocuments;
00535     int                                 mIsDestroyingScene;
00536 
00537     FbxManager_internal*                mInternal;
00538     static FbxManager*                  smDefaultManager;
00539 
00540     FBXSDK_FRIEND_NEW();
00541     friend class FbxObject;
00542 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
00543 };
00544 
00545 #include <fbxsdk/fbxsdk_nsend.h>
00546 
00547 #endif /* _FBXSDK_CORE_MANAGER_H_ */