3
0

AWSApiClientJob.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 <Framework/AWSApiClientJobConfig.h>
  10. #include <Framework/AWSApiJob.h>
  11. namespace AWSCore
  12. {
  13. //! A job that uses an AWS API client. To use, extend this class and
  14. //! implement the AZ::Job defined Process function. That function can
  15. //! use the protected m_client object to make AWS requests.
  16. template<class ClientType>
  17. class AwsApiClientJob
  18. : public AwsApiJob
  19. {
  20. public:
  21. using AwsApiClientJobType = AwsApiClientJob<ClientType>;
  22. // To use a different allocator, extend this class and use this macro.
  23. AZ_CLASS_ALLOCATOR(AwsApiClientJob, AZ::SystemAllocator);
  24. using IConfig = IAwsApiClientJobConfig<ClientType>;
  25. using Config = AwsApiClientJobConfig<ClientType>;
  26. static Config* GetDefaultConfig()
  27. {
  28. static AwsApiJobConfigHolder<Config> s_configHolder{};
  29. return s_configHolder.GetConfig(AwsApiJob::GetDefaultConfig());
  30. }
  31. protected:
  32. AwsApiClientJob(bool isAutoDelete, IConfig* config = GetDefaultConfig())
  33. : AwsApiJob(isAutoDelete, config)
  34. , m_client{config->GetClient()}
  35. {
  36. }
  37. std::shared_ptr<ClientType> m_client;
  38. private:
  39. AwsApiClientJob(const AwsApiClientJob&) = delete;
  40. AwsApiClientJob& operator=(const AwsApiClientJob&) = delete;
  41. };
  42. } // namespace AWSCore