BuilderData.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #if !defined(Q_MOC_RUN)
  10. #include <native/assetprocessor.h>
  11. #include <AzCore/std/containers/vector.h>
  12. #include <AzCore/std/containers/unordered_map.h>
  13. #include <AzCore/std/string/string.h>
  14. #include <AzCore/std/smart_ptr/shared_ptr.h>
  15. #include <QObject>
  16. #endif
  17. namespace AzToolsFramework
  18. {
  19. namespace AssetDatabase
  20. {
  21. class AssetDatabaseConnection;
  22. }
  23. } // namespace AzToolsFramework
  24. namespace AssetProcessor
  25. {
  26. class BuilderDataItem;
  27. //! BuilderData is a class that contains all jobs' metrics, categorized by builders. It is shared by BuilderInfoMetricsModel and
  28. //! BuilderListModel as the source of data.
  29. class BuilderData : public QObject
  30. {
  31. Q_OBJECT
  32. public:
  33. BuilderData(AZStd::shared_ptr<AzToolsFramework::AssetDatabase::AssetDatabaseConnection> dbConnection, QObject* parent = nullptr);
  34. //! This method runs when this model is initialized. It gets the list of builders, gets existing stats about CreateJobs and
  35. //! ProcessJob, and matches stats with builders and save them appropriately for future use.
  36. void Reset();
  37. AZStd::shared_ptr<AzToolsFramework::AssetDatabase::AssetDatabaseConnection> m_dbConnection;
  38. //! tree and index lookup hash tables
  39. //! Tree Structure:
  40. //! m_root (ItemType::InvisibleRoot)
  41. //! +-- "All Builders" invisible root (ItemType::InvisibleRoot)
  42. //! | +-- "All Builders" (ItemType::Builder)
  43. //! | +-- "CreateJobs" (ItemType::TaskType)
  44. //! | | +-- entry... (ItemType::Entry)
  45. //! | | +-- entry... (ItemType::Entry)
  46. //! | +-- "ProcessJob" (ItemType::TaskType)
  47. //! | +-- entry... (ItemType::Entry)
  48. //! | +-- entry... (ItemType::Entry)
  49. //! +-- "XXX Builder" invisible root (ItemType::InvisibleRoot)
  50. //! | +-- "XXX Builder" (ItemType::Builder)
  51. //! | +-- "CreateJobs" (ItemType::TaskType)
  52. //! | | +-- entry... (ItemType::Entry)
  53. //! | | +-- entry... (ItemType::Entry)
  54. //! | +-- "ProcessJob" (ItemType::TaskType)
  55. //! | +-- entry... (ItemType::Entry)
  56. //! | +-- entry... (ItemType::Entry)
  57. //! ...
  58. //! The "XXX builder" invisible root is served as the Qt TreeView root.
  59. AZStd::shared_ptr<BuilderDataItem> m_root;
  60. AZStd::unordered_map<AZStd::string, int> m_builderNameToIndex;
  61. AZStd::unordered_map<AZ::Uuid, int> m_builderGuidToIndex;
  62. Q_SIGNALS:
  63. void DurationChanged(BuilderDataItem* itemChanged);
  64. public Q_SLOTS:
  65. void OnProcessJobDurationChanged(JobEntry jobEntry, int value);
  66. void OnCreateJobsDurationChanged(QString sourceName, AZ::s64 scanFolderID);
  67. };
  68. }