ServiceClientJob.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/ServiceJob.h>
  10. #include <Framework/ServiceClientJobConfig.h>
  11. namespace AWSCore
  12. {
  13. /// Base class for AWSCore service request jobs. This class
  14. /// exists so that we have somewhere to put service type specific
  15. /// configuration.
  16. template<class ServiceTraitsType>
  17. class ServiceClientJob
  18. : public ServiceJob
  19. {
  20. public:
  21. // To use a different allocator, extend this class and use this macro.
  22. AZ_CLASS_ALLOCATOR(ServiceClientJob, AZ::SystemAllocator);
  23. using IConfig = IServiceClientJobConfig;
  24. using Config = ServiceClientJobConfig<ServiceTraitsType>;
  25. static Config* GetDefaultConfig()
  26. {
  27. static AwsApiJobConfigHolder<Config> s_configHolder{};
  28. return s_configHolder.GetConfig(ServiceJob::GetDefaultConfig());
  29. }
  30. ServiceClientJob(bool isAutoDelete, IConfig* config = GetDefaultConfig())
  31. : ServiceJob(isAutoDelete, config)
  32. {
  33. }
  34. protected:
  35. using ServiceClientJobType = ServiceClientJob<ServiceTraitsType>;
  36. };
  37. /// Defines a class that extends ServiceTraits and implements that
  38. /// required static functions.
  39. #define AWS_FEATURE_GEM_SERVICE(SERVICE_NAME) \
  40. AWS_SERVICE_TRAITS_TEMPLATE(SERVICE_NAME, nullptr, nullptr) \
  41. using SERVICE_NAME##ServiceClientJob = AWSCore::ServiceClientJob<SERVICE_NAME##ServiceTraits>;
  42. #define AWS_CUSTOM_SERVICE(SERVICE_NAME, RESTAPI_ID, RESTAPI_STAGE) \
  43. AWS_SERVICE_TRAITS_TEMPLATE(SERVICE_NAME, RESTAPI_ID, RESTAPI_STAGE) \
  44. using SERVICE_NAME##ServiceClientJob = AWSCore::ServiceClientJob<SERVICE_NAME##ServiceTraits>;
  45. } // namespace AWSCore