AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
EndpointBuilder.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 ALEXA_CLIENT_SDK_ENDPOINTS_INCLUDE_ENDPOINTS_ENDPOINTBUILDER_H_
17 #define ALEXA_CLIENT_SDK_ENDPOINTS_INCLUDE_ENDPOINTS_ENDPOINTBUILDER_H_
18 
19 #include <list>
20 #include <memory>
21 #include <string>
22 
37 
38 namespace alexaClientSDK {
39 namespace endpoints {
40 
52 public:
61 
71  static std::unique_ptr<EndpointBuilder> create(
72  const std::shared_ptr<avsCommon::utils::DeviceInfo>& deviceInfo,
73  const std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface>& contextManager,
74  const std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface>& exceptionSender,
75  const std::shared_ptr<capabilityAgents::alexa::AlexaInterfaceMessageSenderInternalInterface>&
76  alexaMessageSender);
77 
88  static std::unique_ptr<EndpointBuilder> create(
89  const avsCommon::utils::DeviceInfo& deviceInfo,
90  std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> contextManager,
91  std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> exceptionSender,
92  std::shared_ptr<capabilityAgents::alexa::AlexaInterfaceMessageSenderInternalInterface> alexaMessageSender);
93 
97  virtual ~EndpointBuilder();
98 
101  EndpointBuilder& withDerivedEndpointId(const std::string& suffix) override;
103  EndpointBuilder& withEndpointId(const EndpointIdentifier& endpointId) override;
104  EndpointBuilder& withFriendlyName(const std::string& friendlyName) override;
105  EndpointBuilder& withDescription(const std::string& description) override;
106  EndpointBuilder& withManufacturerName(const std::string& manufacturerName) override;
107  EndpointBuilder& withDisplayCategory(const std::vector<std::string>& displayCategories) override;
109  const std::string& manufacturer,
110  const std::string& model,
111  const std::string& serialNumber,
112  const std::string& firmwareVersion,
113  const std::string& softwareVersion,
114  const std::string& customIdentifier) override;
115  EndpointBuilder& withConnections(const std::vector<std::map<std::string, std::string>>& connections) override;
116  EndpointBuilder& withCookies(const std::map<std::string, std::string>& cookies) override;
118  std::shared_ptr<avsCommon::sdkInterfaces::powerController::PowerControllerInterface> powerController,
119  bool isProactivelyReported,
120  bool isRetrievable) override;
122  std::shared_ptr<avsCommon::sdkInterfaces::toggleController::ToggleControllerInterface> toggleController,
123  const std::string& instance,
125  bool isProactivelyReported,
126  bool isRetrievable,
127  bool isNonControllable = false) override;
129  const std::shared_ptr<avsCommon::sdkInterfaces::endpoints::EndpointCapabilitiesBuilderInterface>&
130  endpointCapabilitiesBuilder) override;
132  std::shared_ptr<avsCommon::sdkInterfaces::modeController::ModeControllerInterface> modeController,
133  const std::string& instance,
135  bool isProactivelyReported,
136  bool isRetrievable,
137  bool isNonControllable = false) override;
139  std::shared_ptr<avsCommon::sdkInterfaces::rangeController::RangeControllerInterface> rangeController,
140  const std::string& instance,
142  bool isProactivelyReported,
143  bool isRetrievable,
144  bool isNonControllable = false) override;
146  const CapabilityConfiguration& configuration,
147  std::shared_ptr<DirectiveHandlerInterface> directiveHandler) override;
149  const std::shared_ptr<avsCommon::sdkInterfaces::CapabilityConfigurationInterface>& configurationInterface,
150  std::shared_ptr<DirectiveHandlerInterface> directiveHandler) override;
152  const std::shared_ptr<avsCommon::sdkInterfaces::CapabilityConfigurationInterface>& configurationInterface)
153  override;
154  std::unique_ptr<EndpointInterface> build() override;
156 
163  void finalizeAttributes();
164 
165 private:
168 
170  using CapabilityBuilder =
171  std::function<std::pair<CapabilityConfiguration, std::shared_ptr<DirectiveHandlerInterface>>()>;
172 
182  std::shared_ptr<avsCommon::utils::DeviceInfo> deviceInfo,
183  std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> contextManager,
184  std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> exceptionSender,
185  std::shared_ptr<capabilityAgents::alexa::AlexaInterfaceMessageSenderInternalInterface> alexaMessageSender);
186 
190  void configureDefaultEndpoint();
191 
197  std::unique_ptr<EndpointInterface> buildImplementation();
198 
200  bool m_isConfigurationFinalized;
201 
203  bool m_hasBeenBuilt;
204 
206  bool m_invalidConfiguration;
207 
210  bool m_isDefaultEndpoint;
211 
213  std::shared_ptr<avsCommon::utils::DeviceInfo> m_deviceInfo;
214 
216  EndpointAttributes m_attributes;
217 
219  std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> m_contextManager;
220 
222  std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> m_exceptionSender;
223 
225  std::shared_ptr<capabilityAgents::alexa::AlexaInterfaceMessageSenderInternalInterface> m_alexaMessageSender;
226 
228  std::list<CapabilityBuilder> m_capabilitiesBuilders;
229 
231  std::list<CapabilityConfiguration> m_capabilityConfigurations;
232 
234  std::list<std::shared_ptr<DirectiveHandlerInterface>> m_directiveHandlers;
235 
237  std::list<std::shared_ptr<avsCommon::utils::RequiresShutdown>> m_requireShutdownObjects;
238 };
239 
240 } // namespace endpoints
241 } // namespace alexaClientSDK
242 
243 #endif // ALEXA_CLIENT_SDK_ENDPOINTS_INCLUDE_ENDPOINTS_ENDPOINTBUILDER_H_
EndpointBuilder & withDescription(const std::string &description) override
EndpointBuilder & withEndpointId(const EndpointIdentifier &endpointId) override
EndpointBuilder & withRangeController(std::shared_ptr< avsCommon::sdkInterfaces::rangeController::RangeControllerInterface > rangeController, const std::string &instance, const avsCommon::sdkInterfaces::rangeController::RangeControllerAttributes &rangeControllerAttributes, bool isProactivelyReported, bool isRetrievable, bool isNonControllable=false) override
EndpointBuilder & withFriendlyName(const std::string &friendlyName) override
EndpointBuilder & withModeController(std::shared_ptr< avsCommon::sdkInterfaces::modeController::ModeControllerInterface > modeController, const std::string &instance, const avsCommon::sdkInterfaces::modeController::ModeControllerAttributes &modeControllerAttributes, bool isProactivelyReported, bool isRetrievable, bool isNonControllable=false) override
std::unique_ptr< EndpointInterface > build() override
::std::string string
Definition: gtest-port.h:1097
EndpointBuilder & withDerivedEndpointId(const std::string &suffix) override
EndpointBuilder & withDeviceRegistration() override
static std::unique_ptr< EndpointBuilder > create(const std::shared_ptr< avsCommon::utils::DeviceInfo > &deviceInfo, const std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface > &contextManager, const std::shared_ptr< avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface > &exceptionSender, const std::shared_ptr< capabilityAgents::alexa::AlexaInterfaceMessageSenderInternalInterface > &alexaMessageSender)
EndpointBuilder & withAdditionalAttributes(const std::string &manufacturer, const std::string &model, const std::string &serialNumber, const std::string &firmwareVersion, const std::string &softwareVersion, const std::string &customIdentifier) override
avsCommon::sdkInterfaces::endpoints::EndpointIdentifier EndpointIdentifier
Definition: EndpointBuilder.h:56
Definition: EndpointBuilder.h:51
EndpointBuilder & withCapabilityConfiguration(const std::shared_ptr< avsCommon::sdkInterfaces::CapabilityConfigurationInterface > &configurationInterface) override
EndpointBuilder & withCapability(const CapabilityConfiguration &configuration, std::shared_ptr< DirectiveHandlerInterface > directiveHandler) override
Definition: AVSDiscoveryEndpointAttributes.h:41
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
EndpointBuilder & withEndpointCapabilitiesBuilder(const std::shared_ptr< avsCommon::sdkInterfaces::endpoints::EndpointCapabilitiesBuilderInterface > &endpointCapabilitiesBuilder) override
EndpointBuilder & withPowerController(std::shared_ptr< avsCommon::sdkInterfaces::powerController::PowerControllerInterface > powerController, bool isProactivelyReported, bool isRetrievable) override
Definition: DefaultEndpointBuilder.h:52
EndpointBuilder & withConnections(const std::vector< std::map< std::string, std::string >> &connections) override
std::string EndpointIdentifier
Definition: EndpointIdentifier.h:38
EndpointBuilder & withDisplayCategory(const std::vector< std::string > &displayCategories) override
Definition: CapabilityConfiguration.h:42
EndpointBuilder & withManufacturerName(const std::string &manufacturerName) override
EndpointBuilder & withCookies(const std::map< std::string, std::string > &cookies) override
EndpointBuilder & withToggleController(std::shared_ptr< avsCommon::sdkInterfaces::toggleController::ToggleControllerInterface > toggleController, const std::string &instance, const avsCommon::sdkInterfaces::toggleController::ToggleControllerAttributes &toggleControllerAttributes, bool isProactivelyReported, bool isRetrievable, bool isNonControllable=false) override

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