PotentialDependencies.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/std/containers/map.h>
  10. #include <AzCore/std/containers/set.h>
  11. #include <AzCore/std/smart_ptr/shared_ptr.h>
  12. namespace AZ
  13. {
  14. namespace Data
  15. {
  16. struct AssetId;
  17. }
  18. }
  19. namespace AssetProcessor
  20. {
  21. class SpecializedDependencyScanner;
  22. /// Tracks additional information about a potential dependency, such as
  23. /// what string in the file is associated with the dependency, and what scanner.
  24. class PotentialDependencyMetaData
  25. {
  26. public:
  27. PotentialDependencyMetaData() { }
  28. PotentialDependencyMetaData(
  29. AZStd::string sourceString,
  30. AZStd::shared_ptr<SpecializedDependencyScanner> scanner) :
  31. m_sourceString(sourceString),
  32. m_scanner(scanner)
  33. {
  34. }
  35. // Needed to store these in a sorted container, which is used to guarantee
  36. // logs show up in the same order for every sacn.
  37. bool operator<(const PotentialDependencyMetaData& rhs) const
  38. {
  39. return m_sourceString < rhs.m_sourceString;
  40. }
  41. /// The portion of the scanned file that matches the missing dependency.
  42. AZStd::string m_sourceString;
  43. /// Which scanner found this dependency.
  44. AZStd::shared_ptr<SpecializedDependencyScanner> m_scanner;
  45. };
  46. /// Stores the collections of potential product dependencies found in a file.
  47. class PotentialDependencies
  48. {
  49. public:
  50. AZStd::set<PotentialDependencyMetaData> m_paths;
  51. // Using a map instead of a multimap to avoid polluting the results with the
  52. // same missing dependency. If a file references the same potential dependency
  53. // more than once, then only one result will be available.
  54. AZStd::map<AZ::Uuid, PotentialDependencyMetaData> m_uuids;
  55. AZStd::map<AZ::Data::AssetId, PotentialDependencyMetaData> m_assetIds;
  56. };
  57. }