AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
RangeControllerCapabilityAgent.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_CAPABILITYAGENTS_RANGECONTROLLER_INCLUDE_RANGECONTROLLER_RANGECONTROLLERCAPABILITYAGENT_H_
17 #define ALEXA_CLIENT_SDK_CAPABILITYAGENTS_RANGECONTROLLER_INCLUDE_RANGECONTROLLER_RANGECONTROLLERCAPABILITYAGENT_H_
18 
31 
32 namespace alexaClientSDK {
33 namespace capabilityAgents {
34 namespace rangeController {
35 
46  , public std::enable_shared_from_this<RangeControllerCapabilityAgent> {
47 public:
51 
70  static std::shared_ptr<RangeControllerCapabilityAgent> create(
71  const EndpointIdentifier& endpointId,
72  const std::string& instance,
74  std::shared_ptr<avsCommon::sdkInterfaces::rangeController::RangeControllerInterface> rangeController,
75  std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> contextManager,
76  std::shared_ptr<avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface> responseSender,
77  std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> exceptionSender,
78  bool isProactivelyReported,
79  bool isRetrievable,
80  bool isNonControllable = false);
81 
84  void handleDirectiveImmediately(std::shared_ptr<avsCommon::avs::AVSDirective> directive) override;
85  void preHandleDirective(std::shared_ptr<DirectiveInfo> info) override;
86  void handleDirective(std::shared_ptr<DirectiveInfo> info) override;
87  void cancelDirective(std::shared_ptr<DirectiveInfo> info) override;
90 
93  void provideState(
94  const avsCommon::avs::CapabilityTag& stateProviderName,
95  const avsCommon::sdkInterfaces::ContextRequestToken contextRequestToken) override;
96  bool canStateBeRetrieved() override;
97  bool hasReportableStateProperties() override;
99 
106 
110  override;
112 
113 private:
132  const EndpointIdentifier& endpointId,
133  const std::string& instance,
135  std::shared_ptr<avsCommon::sdkInterfaces::rangeController::RangeControllerInterface> rangeController,
136  std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> contextManager,
137  std::shared_ptr<avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface> responseSender,
138  std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> exceptionSender,
139  bool isProactivelyReported,
140  bool isRetrievable,
141  bool isNonControllable = false);
142 
143  // @name RequiresShutdown Functions
145  void doShutdown() override;
147 
153  bool initialize();
154 
160  void removeDirective(std::shared_ptr<DirectiveInfo> info);
161 
167  void executeSetHandlingCompleted(std::shared_ptr<DirectiveInfo> info);
168 
174  std::string buildRangeConfigurationJson();
175 
182  void executeSetRangeValueDirective(std::shared_ptr<DirectiveInfo> info, rapidjson::Document& payload);
183 
190  void executeAdjustRangeValueDirective(std::shared_ptr<DirectiveInfo> info, rapidjson::Document& payload);
191 
198  void executeUnknownDirective(std::shared_ptr<DirectiveInfo> info, avsCommon::avs::ExceptionErrorType type);
199 
207  bool validateRangeValue(double rangeValue);
208 
215  void executeProvideState(
216  const avsCommon::avs::CapabilityTag& stateProviderName,
217  const avsCommon::sdkInterfaces::ContextRequestToken contextRequestToken);
218 
226  void executeSendResponseEvent(
227  const std::shared_ptr<avsCommon::avs::CapabilityAgent::DirectiveInfo> info,
228  std::pair<avsCommon::avs::AlexaResponseType, std::string> result);
229 
235  avsCommon::avs::CapabilityState buildCapabilityState(const RangeState& rangeState);
236 
238  EndpointIdentifier m_endpointId;
239 
241  std::string m_instance;
242 
244  bool m_isProactivelyReported;
245 
247  bool m_isRetrievable;
248 
250  bool m_isNonControllable;
251 
254 
256  std::shared_ptr<avsCommon::sdkInterfaces::rangeController::RangeControllerInterface> m_rangeController;
257 
259  std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> m_contextManager;
260 
262  std::shared_ptr<avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface> m_responseSender;
263 
266  m_rangeControllerConfiguration;
267 
270 };
271 
272 } // namespace rangeController
273 } // namespace capabilityAgents
274 } // namespace alexaClientSDK
275 
276 #endif // ALEXA_CLIENT_SDK_CAPABILITYAGENTS_RANGECONTROLLER_INCLUDE_RANGECONTROLLER_RANGECONTROLLERCAPABILITYAGENT_H_
Definition: CapabilityAgent.h:47
void handleDirective(std::shared_ptr< DirectiveInfo > info) override
void preHandleDirective(std::shared_ptr< DirectiveInfo > info) override
Definition: CapabilityTag.h:32
::std::string string
Definition: gtest-port.h:1097
Single-thread executor implementation.
Definition: Executor.h:45
unsigned int ContextRequestToken
Alias for the token used to identify a context request.
Definition: ContextRequestToken.h:23
ExceptionErrorType
Definition: ExceptionErrorType.h:28
AlexaStateChangeCauseType
Definition: AlexaStateChangeCauseType.h:28
static std::shared_ptr< RangeControllerCapabilityAgent > create(const EndpointIdentifier &endpointId, const std::string &instance, const avsCommon::sdkInterfaces::rangeController::RangeControllerAttributes &rangeControllerAttributes, std::shared_ptr< avsCommon::sdkInterfaces::rangeController::RangeControllerInterface > rangeController, std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface > contextManager, std::shared_ptr< avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface > responseSender, std::shared_ptr< avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface > exceptionSender, bool isProactivelyReported, bool isRetrievable, bool isNonControllable=false)
std::unordered_map< directiveRoutingRule::DirectiveRoutingRule, BlockingPolicy > DirectiveHandlerConfiguration
Definition: DirectiveHandlerConfiguration.h:32
void handleDirectiveImmediately(std::shared_ptr< avsCommon::avs::AVSDirective > directive) override
Definition: CapabilityState.h:31
void onRangeChanged(const RangeState &rangeState, avsCommon::sdkInterfaces::AlexaStateChangeCauseType causeType) override
void cancelDirective(std::shared_ptr< DirectiveInfo > info) override
void provideState(const avsCommon::avs::CapabilityTag &stateProviderName, const avsCommon::sdkInterfaces::ContextRequestToken contextRequestToken) override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
avsCommon::sdkInterfaces::endpoints::EndpointIdentifier EndpointIdentifier
Alias to improve readability.
Definition: RangeControllerCapabilityAgent.h:49
avsCommon::sdkInterfaces::rangeController::RangeControllerObserverInterface::RangeState RangeState
Alias to improve readability.
Definition: RangeControllerInterface.h:40
type
Definition: upload.py:443
std::string EndpointIdentifier
Definition: EndpointIdentifier.h:38
avsCommon::avs::DirectiveHandlerConfiguration getConfiguration() const override
Definition: CapabilityConfiguration.h:42

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