3
0

TestAssetBuilderComponent.h 2.8 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. #include <AzCore/Component/Component.h>
  10. #include <AssetBuilderSDK/AssetBuilderBusses.h>
  11. #include <AssetBuilderSDK/AssetBuilderSDK.h>
  12. #include <AzCore/std/smart_ptr/unique_ptr.h>
  13. #include <AzFramework/Asset/AssetCatalog.h>
  14. namespace TestAssetBuilder
  15. {
  16. struct TestDependentAsset
  17. : public AZ::Data::AssetData
  18. {
  19. AZ_CLASS_ALLOCATOR(TestDependentAsset, AZ::SystemAllocator);
  20. AZ_RTTI(TestDependentAsset, "{B91BCEFE-1725-47E8-A762-C09F09425904}", AZ::Data::AssetData);
  21. TestDependentAsset() = default;
  22. };
  23. class TestDependentAssetCatalog
  24. : public AZ::Data::AssetCatalog
  25. {
  26. public:
  27. AZ_CLASS_ALLOCATOR(TestDependentAssetCatalog, AZ::SystemAllocator);
  28. TestDependentAssetCatalog() = default;
  29. AZ::Data::AssetStreamInfo GetStreamInfoForLoad(const AZ::Data::AssetId& assetId, const AZ::Data::AssetType& type) override;
  30. };
  31. //! TestAssetBuilderComponent handles the lifecycle of the builder.
  32. class TestAssetBuilderComponent
  33. : public AZ::Component,
  34. public AssetBuilderSDK::AssetBuilderCommandBus::Handler
  35. {
  36. public:
  37. AZ_COMPONENT(TestAssetBuilderComponent, "{55C3848D-A489-4428-9BA9-4A40AC7B9952}");
  38. TestAssetBuilderComponent();
  39. ~TestAssetBuilderComponent() override;
  40. void Init() override;
  41. void Activate() override;
  42. void Deactivate() override;
  43. static void Reflect(AZ::ReflectContext* context);
  44. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  45. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  46. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  47. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  48. //! Asset Builder Callback Functions
  49. void CreateJobs(const AssetBuilderSDK::CreateJobsRequest& request, AssetBuilderSDK::CreateJobsResponse& response);
  50. void ProcessJob(const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response);
  51. //////////////////////////////////////////////////////////////////////////
  52. //!AssetBuilderSDK::AssetBuilderCommandBus interface
  53. void ShutDown() override; // if you get this you must fail all existing jobs and return.
  54. //////////////////////////////////////////////////////////////////////////
  55. private:
  56. bool m_isShuttingDown = false;
  57. AZStd::unique_ptr<TestDependentAssetCatalog> m_dependentCatalog;
  58. };
  59. } // namespace TestAssetBuilder