AssetServerHandler.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 <native/utilities/AssetUtilEBusHelper.h>
  10. #include <AssetBuilderSDK/AssetBuilderSDK.h>
  11. namespace AssetProcessor
  12. {
  13. inline constexpr const char* AssetCacheServerModeKey{ "assetCacheServerMode" };
  14. inline constexpr const char* CacheServerAddressKey{ "cacheServerAddress" };
  15. //! AssetServerHandler is implementing asset server using network share.
  16. class AssetServerHandler
  17. : public AssetServerBus::Handler
  18. {
  19. public:
  20. static const char* GetAssetServerModeText(AssetServerMode mode);
  21. public:
  22. AssetServerHandler();
  23. virtual ~AssetServerHandler();
  24. //////////////////////////////////////////////////////////////////////////
  25. // AssetServerBus::Handler overrides
  26. bool IsServerAddressValid() override;
  27. //! StoreJobResult will store all the files in the the temp folder provided by AP to a zip file on the network drive
  28. //! whose file name will be based on the server key
  29. bool StoreJobResult(const AssetProcessor::BuilderParams& builderParams, AZStd::vector<AZStd::string>& sourceFileList) override;
  30. //! RetrieveJobResult will retrieve the zip file from the network share associated with the server key and unzip it to the temporary directory provided by AP.
  31. bool RetrieveJobResult(const AssetProcessor::BuilderParams& builderParams) override;
  32. //! HandleRemoteConfiguration will attempt to set or get the remote configuration for the cache server
  33. void HandleRemoteConfiguration();
  34. //! Retrieve the current mode for shared caching
  35. AssetServerMode GetRemoteCachingMode() const override;
  36. //! Store the shared caching mode
  37. void SetRemoteCachingMode(AssetServerMode mode) override;
  38. //! Retrieve the remote folder location for the shared cache
  39. const AZStd::string& GetServerAddress() const override;
  40. //! Store the remote folder location for the shared cache
  41. bool SetServerAddress(const AZStd::string& address) override;
  42. protected:
  43. //! Source files intended to be copied into the cache don't go through out temp folder so they need
  44. //! to be added to the Archive in an additional step
  45. bool AddSourceFilesToArchive(const AssetProcessor::BuilderParams& builderParams, const QString& archivePath, AZStd::vector<AZStd::string>& sourceFileList);
  46. QString ComputeArchiveFilePath(const AssetProcessor::BuilderParams& builderParams);
  47. private:
  48. AssetServerMode m_assetCachingMode = AssetServerMode::Inactive;
  49. AZStd::string m_serverAddress;
  50. };
  51. } //namespace AssetProcessor