AssetBuilderInfo.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. class QString;
  10. class QStringList;
  11. #include <QLibrary>
  12. #include <QVector>
  13. #include <AzCore/std/containers/set.h>
  14. #include <AzCore/Math/Uuid.h>
  15. namespace AZ
  16. {
  17. class ComponentDescriptor;
  18. class Entity;
  19. namespace Internal
  20. {
  21. class EnvironmentInterface;
  22. }
  23. typedef Internal::EnvironmentInterface* EnvironmentInstance;
  24. }
  25. namespace AssetBuilder
  26. {
  27. enum class AssetBuilderType
  28. {
  29. Invalid, Valid, None
  30. };
  31. /**
  32. * Class to manage external module builders for AssetBuilder. Note that this is similar
  33. * to a class in Asset Processor, because both AssetProcessor.exe and AssetBuilder.exe both load builders in a similar manner.
  34. * The implementation details differ.
  35. */
  36. class ExternalModuleAssetBuilderInfo
  37. {
  38. public:
  39. ExternalModuleAssetBuilderInfo(const QString& modulePath);
  40. virtual ~ExternalModuleAssetBuilderInfo();
  41. const QString& GetName() const;
  42. //! Sanity check for the module's status
  43. bool IsLoaded() const;
  44. //! Perform the module initialization for the external builder
  45. void Initialize();
  46. //! Perform the necessary process of uninitializing an external builder
  47. void UnInitialize();
  48. //! Register a builder descriptor ID to track as part of this builders lifecycle management
  49. void RegisterBuilderDesc(const AZ::Uuid& builderDesc);
  50. //! Register a component descriptor to track as part of this builders lifecycle management
  51. void RegisterComponentDesc(AZ::ComponentDescriptor* descriptor);
  52. //! Check to see if the builder has the required functions defined.
  53. AssetBuilder::AssetBuilderType GetAssetBuilderType();
  54. protected:
  55. AssetBuilderType Load();
  56. void Unload();
  57. AZStd::set<AZ::Uuid> m_registeredBuilderDescriptorIDs;
  58. typedef void(* InitializeModuleFunction)(AZ::EnvironmentInstance sharedEnvironment);
  59. typedef void(* ModuleRegisterDescriptorsFunction)(void);
  60. typedef void(* ModuleAddComponentsFunction)(AZ::Entity* entity);
  61. typedef void(* UninitializeModuleFunction)(void);
  62. template<typename T>
  63. T ResolveModuleFunction(const char* functionName, QStringList& missingFunctionsList);
  64. InitializeModuleFunction m_initializeModuleFunction;
  65. ModuleRegisterDescriptorsFunction m_moduleRegisterDescriptorsFunction;
  66. ModuleAddComponentsFunction m_moduleAddComponentsFunction;
  67. UninitializeModuleFunction m_uninitializeModuleFunction;
  68. AZStd::vector<AZ::ComponentDescriptor*> m_componentDescriptorList;
  69. AZ::Entity* m_entity = nullptr;
  70. QString m_builderName;
  71. QString m_modulePath;
  72. QLibrary m_library;
  73. };
  74. } // AssetBuilder