Globals.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. * SPDX-License-Identifier: Apache-2.0.
  4. */
  5. #include <aws/crt/Api.h>
  6. #include <aws/crt/io/TlsOptions.h>
  7. #include <aws/crt/io/Bootstrap.h>
  8. #include <aws/core/Globals.h>
  9. #include <aws/core/utils/EnumParseOverflowContainer.h>
  10. #include <aws/core/utils/memory/AWSMemory.h>
  11. #include <aws/auth/auth.h>
  12. namespace Aws
  13. {
  14. static const char TAG[] = "GlobalEnumOverflowContainer";
  15. static Aws::Crt::ApiHandle* g_apiHandle;
  16. static std::shared_ptr<Aws::Crt::Io::ClientBootstrap> g_defaultClientBootstrap(nullptr);
  17. static std::shared_ptr<Aws::Crt::Io::TlsConnectionOptions> g_defaultTlsConnectionOptions(nullptr);
  18. Aws::Crt::ApiHandle* GetApiHandle()
  19. {
  20. return g_apiHandle;
  21. }
  22. void SetDefaultClientBootstrap(const std::shared_ptr<Aws::Crt::Io::ClientBootstrap>& clientBootstrap)
  23. {
  24. g_defaultClientBootstrap = clientBootstrap;
  25. }
  26. Aws::Crt::Io::ClientBootstrap* GetDefaultClientBootstrap()
  27. {
  28. return g_defaultClientBootstrap.get();
  29. }
  30. void SetDefaultTlsConnectionOptions(const std::shared_ptr<Aws::Crt::Io::TlsConnectionOptions>& tlsConnectionOptions)
  31. {
  32. g_defaultTlsConnectionOptions = tlsConnectionOptions;
  33. }
  34. Aws::Crt::Io::TlsConnectionOptions* GetDefaultTlsConnectionOptions()
  35. {
  36. return g_defaultTlsConnectionOptions.get();
  37. }
  38. void InitializeCrt()
  39. {
  40. g_apiHandle = Aws::New<Aws::Crt::ApiHandle>(TAG, Aws::get_aws_allocator());
  41. }
  42. void CleanupCrt()
  43. {
  44. Aws::SetDefaultClientBootstrap(nullptr);
  45. Aws::SetDefaultTlsConnectionOptions(nullptr);
  46. Aws::Delete(g_apiHandle);
  47. g_apiHandle = nullptr;
  48. }
  49. static Utils::EnumParseOverflowContainer* g_enumOverflow;
  50. Utils::EnumParseOverflowContainer* GetEnumOverflowContainer()
  51. {
  52. return g_enumOverflow;
  53. }
  54. void InitializeEnumOverflowContainer()
  55. {
  56. g_enumOverflow = Aws::New<Aws::Utils::EnumParseOverflowContainer>(TAG);
  57. }
  58. void CleanupEnumOverflowContainer()
  59. {
  60. Aws::Delete(g_enumOverflow);
  61. }
  62. }