AWSCoreSystemComponent.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 <AWSCoreBus.h>
  11. namespace AZ
  12. {
  13. class JobManager;
  14. class JobCancelGroup;
  15. class JobContext;
  16. }
  17. namespace AWSCore
  18. {
  19. class AWSCoreConfiguration;
  20. class AWSCredentialManager;
  21. class AWSResourceMappingManager;
  22. class AWSCoreSystemComponent
  23. : public AZ::Component
  24. , protected AWSCoreRequestBus::Handler
  25. {
  26. public:
  27. static const char* AWS_API_ALLOC_TAG;
  28. static const char* AWS_API_LOG_PREFIX;
  29. AZ_COMPONENT(AWSCoreSystemComponent, "{940EEC1D-BABE-4F28-8E70-8AC12E22BD58}");
  30. AWSCoreSystemComponent();
  31. static void Reflect(AZ::ReflectContext* context);
  32. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  33. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  34. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  35. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  36. ////////////////////////////////////////////////////////////////////////
  37. // AWSCoreRequestBus interface implementation
  38. AZ::JobContext* GetDefaultJobContext() override;
  39. AwsApiJobConfig* GetDefaultConfig() override;
  40. //! Returns true if the AWS C++ SDK has been initialized and is ready for use
  41. bool IsAWSApiInitialized() const;
  42. protected:
  43. ////////////////////////////////////////////////////////////////////////
  44. // AZ::Component interface implementation
  45. void Init() override;
  46. void Activate() override;
  47. void Deactivate() override;
  48. ////////////////////////////////////////////////////////////////////////
  49. void InitAWSApi();
  50. void ShutdownAWSApi();
  51. private:
  52. int m_threadCount; ///! Number of threads used for AWS requests
  53. int m_firstThreadCPU; ///! Internal tracker of cpu id for first thread
  54. int m_threadPriority; ///! Priority size for AWS threads, defaults to platform value
  55. int m_threadStackSize; ///! Stack size for threads, defaults to platform value
  56. // Order here is of importance. To be correct, JobContext needs to
  57. // destruct before the JobManager and the JobCancelGroup.
  58. AZStd::unique_ptr<AZ::JobCancelGroup> m_jobCancelGroup;
  59. AZStd::unique_ptr<AZ::JobManager> m_jobManager;
  60. AZStd::unique_ptr<AZ::JobContext> m_jobContext;
  61. AZStd::unique_ptr<AWSCoreConfiguration> m_awsCoreConfiguration;
  62. AZStd::unique_ptr<AWSCredentialManager> m_awsCredentialManager;
  63. AZStd::unique_ptr<AWSResourceMappingManager> m_awsResourceMappingManager;
  64. bool m_ownsAwsNativeInitialization = false; // Track whether or not this module initialized the native layer
  65. };
  66. } // namespace AWSCore