fbxembeddedfilesaccumulator.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 fbxembeddedfilesaccumulator.h
  9. #ifndef _FBXSDK_UTILS_EMBEDDED_FILES_ACCUMULATOR_H_
  10. #define _FBXSDK_UTILS_EMBEDDED_FILES_ACCUMULATOR_H_
  11. #include <fbxsdk/fbxsdk_def.h>
  12. #include <fbxsdk/utils/fbxprocessor.h>
  13. #include <fbxsdk/fbxsdk_nsbegin.h>
  14. /** This processor is used to accumulate the list of file dependencies (embedded files) in a hierarchy of objects.
  15. * It retrieves information of embedded files from objects and accumulates them to its class member mEmbeddedFiles.
  16. * \see FbxProcessor::ProcessCollection(FbxCollection *)
  17. * \nosubgrouping
  18. */
  19. class FBXSDK_DLL FbxEmbeddedFilesAccumulator : public FbxProcessor
  20. {
  21. public:
  22. /**
  23. * Map the object to the property's hierarchical name.
  24. * An object may use the same file on multiple properties, hence the
  25. * set.
  26. * Each property may have multiple URLs, separate by |.
  27. * We thus need to store the index along with the property.
  28. */
  29. //@{
  30. struct PropertyUrlIndex
  31. {
  32. FbxString mPropName;
  33. int mIndex;
  34. PropertyUrlIndex() : mIndex(0)
  35. {
  36. }
  37. PropertyUrlIndex(const FbxString& pUrl, int pIndex)
  38. : mPropName(pUrl)
  39. , mIndex(pIndex)
  40. {
  41. }
  42. };
  43. //! Comparer for PropertyUrlIndexSet, which outputs consistent partial orders for PropertyUrlIndex pairs
  44. struct FbxPropertyUrlIndexCompare
  45. {
  46. inline int operator()(const PropertyUrlIndex& pKeyA, const PropertyUrlIndex& pKeyB) const
  47. {
  48. if( pKeyA.mPropName < pKeyB.mPropName ) return -1;
  49. if( pKeyB.mPropName < pKeyA.mPropName ) return 1;
  50. if( pKeyA.mIndex < pKeyB.mIndex ) return -1;
  51. if( pKeyB.mIndex < pKeyA.mIndex ) return 1;
  52. return 0;
  53. }
  54. };
  55. typedef FbxSet<PropertyUrlIndex, FbxPropertyUrlIndexCompare> PropertyUrlIndexSet;
  56. typedef FbxMap<FbxObject*, PropertyUrlIndexSet> ObjectPropertyMap;
  57. struct EmbeddedFileInfo
  58. {
  59. FbxString mOriginalPropertyUrl;
  60. ObjectPropertyMap mConsumers;
  61. };
  62. //@}
  63. /**
  64. * Map the (absolute filename) to which object/properties use this file.
  65. * To simply get the list of file dependencies, iterate through this map and query
  66. * all the keys.
  67. */
  68. //@{
  69. typedef FbxMap<FbxString, EmbeddedFileInfo> EmbeddedFilesMap;
  70. EmbeddedFilesMap mEmbeddedFiles;
  71. //@}
  72. public:
  73. /** Constructor.
  74. * The name is not important.
  75. * The property filter is a list of strings, property names, which are automatically ignored when
  76. * encountered. Property names must be the full hierarchical property name (ie: parent|child|child).
  77. *
  78. * \param pManager Reference to the SDK manager.
  79. * \param pName Name of this object.
  80. * \param pPropertyFilter Reference to the property filter.
  81. */
  82. FbxEmbeddedFilesAccumulator(FbxManager& pManager, const char* pName, FbxSet<FbxString>& pPropertyFilter);
  83. virtual ~FbxEmbeddedFilesAccumulator();
  84. /*****************************************************************************************************************************
  85. ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
  86. *****************************************************************************************************************************/
  87. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  88. private:
  89. virtual bool internal_ProcessObject(FbxObject* pObject);
  90. FbxSet<FbxString> mPropertyFilter;
  91. #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
  92. };
  93. #include <fbxsdk/fbxsdk_nsend.h>
  94. #endif /* _FBXSDK_UTILS_EMBEDDED_FILES_ACCUMULATOR_H_ */