PythonBuilderWorker.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 <AzCore/std/smart_ptr/shared_ptr.h>
  11. #include <AssetBuilderSDK/AssetBuilderSDK.h>
  12. #include <AssetBuilderSDK/AssetBuilderBusses.h>
  13. #include <EditorPythonBindings/EditorPythonBindingsBus.h>
  14. #include <PythonAssetBuilder/PythonAssetBuilderBus.h>
  15. namespace PythonAssetBuilder
  16. {
  17. //! A delegate asset build worker for Python scripts
  18. class PythonBuilderWorker
  19. : public AssetBuilderSDK::AssetBuilderCommandBus::Handler
  20. , public AssetBuilderSDK::JobCommandBus::Handler
  21. {
  22. public:
  23. AZ_TYPE_INFO(PythonBuilderWorker, "{F27E64FB-A7FF-47F2-80DB-7E1371B014DD}");
  24. AZ_CLASS_ALLOCATOR(PythonBuilderWorker, AZ::SystemAllocator);
  25. PythonBuilderWorker() = default;
  26. virtual ~PythonBuilderWorker() = default;
  27. static void Reflect(AZ::ReflectContext* context);
  28. //! Configure the Python builder using an asset builder description; should only be done once
  29. bool ConfigureBuilderInformation(const AssetBuilderSDK::AssetBuilderDesc& assetBuilderDesc);
  30. protected:
  31. //! AssetBuilder callback functions
  32. void CreateJobs(const AssetBuilderSDK::CreateJobsRequest& request, AssetBuilderSDK::CreateJobsResponse& response);
  33. void ProcessJob(const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response);
  34. //! AssetBuilderSDK::AssetBuilderCommandBus interface
  35. void ShutDown() override;
  36. //! AssetBuilderSDK::JobCommandBus interface
  37. void Cancel() override;
  38. private:
  39. AZ::Uuid m_busId = AZ::Uuid::CreateNull();
  40. bool m_isShuttingDown = false;
  41. AZStd::shared_ptr<AssetBuilderSDK::AssetBuilderDesc> m_assetBuilderDesc;
  42. };
  43. }