AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
SDKClientRegistry.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ACSDK_SDKCLIENT_INCLUDE_ACSDK_SDKCLIENT_SDKCLIENTREGISTRY_H_
17 #define ACSDK_SDKCLIENT_INCLUDE_ACSDK_SDKCLIENT_SDKCLIENTREGISTRY_H_
18 
19 #include <memory>
20 #include <unordered_map>
21 
27 
28 #include "Annotated.h"
29 #include "FeatureClientInterface.h"
30 #include "internal/Utils.h"
31 
32 namespace alexaClientSDK {
33 namespace sdkClient {
34 
46 class SDKClientRegistry
47  : public std::enable_shared_from_this<SDKClientRegistry>
48  , public avsCommon::utils::RequiresShutdown {
49 public:
55  template <
56  typename ClientType,
57  typename std::enable_if<std::is_base_of<FeatureClientInterface, ClientType>::value>::type* = nullptr>
58  ACSDK_INLINE_VISIBILITY inline std::shared_ptr<ClientType> get();
59 
66  template <typename ComponentType>
68  getComponent();
69 
76  template <typename ComponentType>
77  ACSDK_INLINE_VISIBILITY inline bool registerComponent(std::shared_ptr<ComponentType> component);
78 
86  template <typename AnnotatedName, typename ComponentType>
87  ACSDK_INLINE_VISIBILITY inline bool registerComponent(Annotated<AnnotatedName, ComponentType> component);
88 
96  template <typename FeatureClientBuilderType>
97  ACSDK_INLINE_VISIBILITY inline bool addFeature(std::unique_ptr<FeatureClientBuilderType> featureBuilder);
98 
101  void doShutdown() override;
103 
104 private:
106  SDKClientRegistry();
107 
109  bool initialize();
110 
117  bool registerClient(
118  const avsCommon::utils::TypeIndex& clientTypeId,
119  std::shared_ptr<FeatureClientInterface> client);
120 
127  bool registerComponent(const avsCommon::utils::TypeIndex& clientTypeId, std::shared_ptr<void> component);
128 
136  bool addFeature(
137  const avsCommon::utils::TypeIndex& clientTypeId,
138  std::unique_ptr<FeatureClientBuilderInterface> featureBuilder,
139  std::function<std::shared_ptr<FeatureClientInterface>(const std::shared_ptr<SDKClientRegistry>&)>
140  constructorFn);
141 
143  std::unordered_map<avsCommon::utils::TypeIndex, std::shared_ptr<FeatureClientInterface>> m_clientMapping;
144 
146  std::unordered_map<avsCommon::utils::TypeIndex, std::shared_ptr<void>> m_componentMapping;
147 
149  std::shared_ptr<acsdkShutdownManagerInterfaces::ShutdownManagerInterface> m_shutdownManager;
150 
152  std::shared_ptr<acsdkShutdownManagerInterfaces::ShutdownNotifierInterface> m_shutdownNotifier;
153 
155  friend class SDKClientBuilder;
156 };
157 } // namespace sdkClient
158 } // namespace alexaClientSDK
159 
161 #endif // ACSDK_SDKCLIENT_INCLUDE_ACSDK_SDKCLIENT_SDKCLIENTREGISTRY_H_
ADSLComponent getComponent()
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
#define ACSDK_INLINE_VISIBILITY
Compiler-specific macro for inline-only methods.
Definition: PlatformDefinitions.h:116
type
Definition: upload.py:443

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0