3
0

TestDependencyBuilderComponent.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 <AzCore/Asset/AssetCommon.h>
  12. #include <AzCore/RTTI/TypeInfoSimple.h>
  13. #include <AzCore/RTTI/RTTIMacros.h>
  14. namespace AZ
  15. {
  16. class ReflectContext;
  17. }
  18. namespace TestAssetBuilder
  19. {
  20. class TestAsset : public AZ::Data::AssetData
  21. {
  22. public:
  23. AZ_RTTI(TestAsset, "{3BDE90FA-B163-4FB9-BC67-22AC2ABD8C28}", AZ::Data::AssetData);
  24. AZ_CLASS_ALLOCATOR(TestAsset, AZ::SystemAllocator);
  25. static void Reflect(AZ::ReflectContext* context);
  26. TestAsset() = default;
  27. virtual ~TestAsset() = default;
  28. AZStd::vector<AZ::Data::Asset<TestAsset>> m_referencedAssets;
  29. };
  30. //! This builder is intended for automated tests which need an asset that can reference other assets.
  31. //! It will take .auto_test_input files containing a single path to a source file and output .auto_test_asset files with an asset
  32. //! reference to the assumed product of the referenced asset. References should be to other .auto_test_input files.
  33. class TestDependencyBuilderComponent
  34. : public AZ::Component,
  35. public AssetBuilderSDK::AssetBuilderCommandBus::MultiHandler
  36. {
  37. public:
  38. AZ_COMPONENT(TestDependencyBuilderComponent, "{E6DEE36F-8F75-41CB-9FEC-7E3231A97C1F}");
  39. void Init() override;
  40. void Activate() override;
  41. void Deactivate() override;
  42. static void Reflect(AZ::ReflectContext* context);
  43. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  44. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  45. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  46. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  47. //! Asset Builder Callback Functions
  48. void CreateJobs(const AssetBuilderSDK::CreateJobsRequest& request, AssetBuilderSDK::CreateJobsResponse& response);
  49. void ProcessJob(const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response);
  50. //////////////////////////////////////////////////////////////////////////
  51. //!AssetBuilderSDK::AssetBuilderCommandBus interface
  52. void ShutDown() override; // if you get this you must fail all existing jobs and return.
  53. //////////////////////////////////////////////////////////////////////////
  54. private:
  55. bool m_isShuttingDown = false;
  56. };
  57. } // namespace TestAssetBuilder