fbxclassid.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /****************************************************************************************
  2. Copyright (C) 2015 Autodesk, Inc.
  3. All rights reserved.
  4. Use of this software is subject to the terms of the Autodesk license agreement
  5. provided at the time of installation or download, or which otherwise accompanies
  6. this software in either electronic or hard copy form.
  7. ****************************************************************************************/
  8. //! \file fbxclassid.h
  9. #ifndef _FBXSDK_CORE_CLASSID_H_
  10. #define _FBXSDK_CORE_CLASSID_H_
  11. #include <fbxsdk/fbxsdk_def.h>
  12. #include <fbxsdk/fbxsdk_nsbegin.h>
  13. class FbxClassIdInfo;
  14. class FbxObject;
  15. class FbxPropertyHandle;
  16. class FbxManager;
  17. //! The function pointer type for object constructor functions.
  18. typedef FbxObject* (*FbxObjectCreateProc)(FbxManager& pManager, const char* pName, const FbxObject* pFrom);
  19. /** Internal class used to differentiate objects during run-time. Essentially, each class has an unique ClassId, that the
  20. * system can request in order to test if the class match the description. This class implement the necessary tools to be able
  21. * to perform hierarchic class testing. This means that a class B that inherits from the class A will answer yes to a "Is A"
  22. * query of type A or B, but will answer no to a class C that can still inherit from A. All class must inherit from FbxObject
  23. * before they can have their own ClassId. When using the standard macros to create new types of objects in the FBX SDK, a
  24. * static ClassId will automatically be generated for that new class.
  25. *
  26. * When objects are exported to an FBX file, their class type is maintained using 3 sort of strings. They are the Object Type
  27. * string, the Object Sub Type string and the Object Type Prefix. There is no good or bad way to choose the value of these
  28. * identifiers, but it is preferable to use meaningful values to keep the ASCII version of FBX readable and easy to understand.
  29. * \see FbxObject */
  30. class FBXSDK_DLL FbxClassId
  31. {
  32. public:
  33. //! Constructor.
  34. FbxClassId();
  35. /** Advanced constructor were we can specify the general parameters for this ClassId.
  36. * \param pClassName The name of the class represented.
  37. * \param pParentClassId The parent ClassId of this class.
  38. * \param pConstructor A function pointer to a construction method for this ClassId.
  39. * \param pFBXType The FBX file Object Type string associated to this class.
  40. * \param pFBXSubType The FBX file Object Sub Type string associated to this class. */
  41. FbxClassId(const char* pClassName, const FbxClassId& pParentClassId, FbxObjectCreateProc pConstructor=0, const char* pFBXType=NULL, const char* pFBXSubType=NULL);
  42. //! Destructor.
  43. void Destroy();
  44. /** Retrieve the class name.
  45. * \return The class identification string name. */
  46. const char* GetName() const;
  47. /** Retrieve the parent ClassId.
  48. * \return The parent ClassId. */
  49. FbxClassId GetParent() const;
  50. /** Create an instance of this class.
  51. * \param pManager The FBX SDK Manager to be used to instantiate this object. This allow the object to use the same memory manager as the provided manager.
  52. * \param pName The name to assign to this new object instance.
  53. * \param pFrom An object to clone if it matches the same ClassId. This is an optional parameter.
  54. * \return The newly created instance of this class. */
  55. FbxObject* Create(FbxManager& pManager, const char* pName, const FbxObject* pFrom);
  56. /** Override the function pointer method to construct this object.
  57. * \param pConstructor A newly defined function pointer to a construction method to replace the existing one.
  58. * \return True if the operation was successful. */
  59. bool Override(FbxObjectCreateProc pConstructor);
  60. /** Test if this class is a hierarchical children of the specified class type. This is the standard method to differentiate object classes.
  61. * \param pId The class type to test against self.
  62. * \return True if the object is a hierarchical children of the type specified.
  63. * \remark This function will perform a complete search until it reaches the top level class, but it will stop as soon as one ClassId matches the test. */
  64. bool Is(const FbxClassId& pId) const;
  65. /** Equivalence operator.
  66. * \param pClassId The class type to test against self.
  67. * \return \c true if the ClassId is exactly the same, \c false otherwise.
  68. * \remark This function only perform direct equality test, and doesn't test hierarchic children. */
  69. bool operator==(const FbxClassId& pClassId) const;
  70. /** Inequivalence operator.
  71. * \param pClassId The class type to test against self.
  72. * \return \c true if the ClassId is not the same, \c false otherwise.
  73. * \remark This function only perform direct inequality test, and doesn't test hierarchic children. */
  74. bool operator!=(const FbxClassId& pClassId) const;
  75. /** Retrieve the FBX file Object Type string associated to this class.
  76. * \param pAskParent If \c true, retrieve the parent ClassId, but only if self ClassId is not valid.
  77. * \return The FBX file Object Type string associated to this class. */
  78. const char* GetFbxFileTypeName(bool pAskParent=false) const;
  79. /** Retrieve the FBX file Object Sub Type string associated to this class.
  80. * \return The FBX file Object Sub Type string associated to this class. */
  81. const char* GetFbxFileSubTypeName() const;
  82. /** Find out if self ClassId is valid or not.
  83. * \return \c true if self ClassId is valid, \c false otherwise. */
  84. inline bool IsValid() const { return mClassInfo ? true : false; }
  85. /** Set the Object Type Prefix string associated to this class. This will change the "ObjectTypePrefix::" found in front
  86. * of object name in the FBX file. This is useful to differentiate objects by their name without using the Object Type or
  87. * Sub Type strings in the file.
  88. * \param pObjectTypePrefix The Object Type prefix string. */
  89. void SetObjectTypePrefix(const char* pObjectTypePrefix);
  90. /** Retrieve the Object Type Prefix string associated to this class.
  91. * \return The Object Type Prefix string. */
  92. const char* GetObjectTypePrefix();
  93. /** Retrieve the root property handle of this class. This is useful to access the default property hierarchy for this
  94. * class. This allow users to retrieve information such as the default value for all properties of this class.
  95. * \return The root property handle for this class. */
  96. FbxPropertyHandle* GetRootClassDefaultPropertyHandle();
  97. /** Increase the instance reference count for this class type.
  98. * \return the new count of reference to this class after increment. */
  99. int ClassInstanceIncRef();
  100. /** Decrease the instance reference count for this class type.
  101. * \return the new count of reference to this class after decrement. */
  102. int ClassInstanceDecRef();
  103. /** Retrieve the instance reference count for this class type.
  104. * \return The reference count of this class type. */
  105. int GetInstanceRef();
  106. /*****************************************************************************************************************************
  107. ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
  108. *****************************************************************************************************************************/
  109. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  110. inline FbxClassIdInfo* GetClassIdInfo() { return mClassInfo; }
  111. inline const FbxClassIdInfo* GetClassIdInfo() const { return mClassInfo; }
  112. private:
  113. FbxClassId(FbxClassIdInfo* mClassInfo);
  114. bool SetFbxFileTypeName(const char* pName);
  115. bool SetFbxFileSubTypeName(const char* pName);
  116. FbxClassIdInfo* mClassInfo;
  117. friend class FbxManager;
  118. #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
  119. };
  120. //! Functor to compare FbxClassId
  121. struct FbxClassIdCompare
  122. {
  123. inline int operator()(const FbxClassId& pKeyA, const FbxClassId& pKeyB) const
  124. {
  125. const FbxClassIdInfo* lKeyA = pKeyA.GetClassIdInfo();
  126. const FbxClassIdInfo* lKeyB = pKeyB.GetClassIdInfo();
  127. return lKeyA < lKeyB ? -1 : (lKeyA > lKeyB ? 1 : 0);
  128. }
  129. };
  130. #include <fbxsdk/fbxsdk_nsend.h>
  131. #endif /* _FBXSDK_CORE_CLASSID_H_ */