AlexaClientSDK  1.26.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_
Timer.h
alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent::cancelDirective
void cancelDirective(std::shared_ptr< DirectiveInfo > info) override
Definition: RangeControllerCapabilityAgent.cpp:333
alexaClientSDK::avsCommon::utils::RequiresShutdown
Definition: RequiresShutdown.h:32
alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent::getConfiguration
avsCommon::avs::DirectiveHandlerConfiguration getConfiguration() const override
Definition: RangeControllerCapabilityAgent.cpp:351
alexaClientSDK::avsCommon::sdkInterfaces::ContextRequestToken
unsigned int ContextRequestToken
Alias for the token used to identify a context request.
Definition: ContextRequestToken.h:23
alexaClientSDK::avsCommon::sdkInterfaces::rangeController::RangeControllerObserverInterface
Definition: RangeControllerObserverInterface.h:31
alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent::preHandleDirective
void preHandleDirective(std::shared_ptr< DirectiveInfo > info) override
Definition: RangeControllerCapabilityAgent.cpp:262
alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent::canStateBeRetrieved
bool canStateBeRetrieved() override
Definition: RangeControllerCapabilityAgent.cpp:323
alexaClientSDK::avsCommon::sdkInterfaces::rangeController::RangeControllerObserverInterface::RangeState
Definition: RangeControllerObserverInterface.h:41
alexaClientSDK::avsCommon::sdkInterfaces::rangeController::RangeControllerInterface::RangeControllerConfiguration
Definition: RangeControllerInterface.h:50
alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent
Definition: RangeControllerCapabilityAgent.h:42
alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent::handleDirectiveImmediately
void handleDirectiveImmediately(std::shared_ptr< avsCommon::avs::AVSDirective > directive) override
Definition: RangeControllerCapabilityAgent.cpp:253
alexaClientSDK::avsCommon::utils::threading::Executor
Definition: Executor.h:40
alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent::EndpointIdentifier
avsCommon::sdkInterfaces::endpoints::EndpointIdentifier EndpointIdentifier
Alias to improve readability.
Definition: RangeControllerCapabilityAgent.h:49
alexaClientSDK::avsCommon::sdkInterfaces::AlexaStateChangeCauseType
AlexaStateChangeCauseType
Definition: AlexaStateChangeCauseType.h:28
AlexaInterfaceMessageSenderInterface.h
RequiresShutdown.h
Executor.h
alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent::onRangeChanged
void onRangeChanged(const RangeState &rangeState, avsCommon::sdkInterfaces::AlexaStateChangeCauseType causeType) override
Definition: RangeControllerCapabilityAgent.cpp:411
CapabilityAgent.h
alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent::hasReportableStateProperties
bool hasReportableStateProperties() override
Definition: RangeControllerCapabilityAgent.cpp:328
alexaClientSDK::avsCommon::sdkInterfaces::rangeController::RangeControllerAttributes
Definition: RangeControllerAttributes.h:38
alexaClientSDK::avsCommon::avs::ExceptionErrorType
ExceptionErrorType
Definition: ExceptionErrorType.h:28
alexaClientSDK
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
alexaClientSDK::avsCommon::sdkInterfaces::endpoints::EndpointIdentifier
std::string EndpointIdentifier
Definition: EndpointIdentifier.h:38
alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent::handleDirective
void handleDirective(std::shared_ptr< DirectiveInfo > info) override
Definition: RangeControllerCapabilityAgent.cpp:267
alexaClientSDK::avsCommon::avs::DirectiveHandlerConfiguration
std::unordered_map< directiveRoutingRule::DirectiveRoutingRule, BlockingPolicy > DirectiveHandlerConfiguration
Definition: DirectiveHandlerConfiguration.h:32
ContextManagerInterface.h
alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent::provideState
void provideState(const avsCommon::avs::CapabilityTag &stateProviderName, const avsCommon::sdkInterfaces::ContextRequestToken contextRequestToken) override
Definition: RangeControllerCapabilityAgent.cpp:310
alexaClientSDK::avsCommon::avs::CapabilityState
Definition: CapabilityState.h:31
RangeControllerObserverInterface.h
alexaClientSDK::avsCommon::avs::CapabilityAgent
Definition: CapabilityAgent.h:47
CapabilityResources.h
alexaClientSDK::avsCommon::sdkInterfaces::rangeController::RangeControllerInterface::RangeState
avsCommon::sdkInterfaces::rangeController::RangeControllerObserverInterface::RangeState RangeState
Alias to improve readability.
Definition: RangeControllerInterface.h:40
RangeControllerAttributeBuilderInterface.h
RangeControllerInterface.h
alexaClientSDK::avsCommon::avs::CapabilityConfiguration
Definition: CapabilityConfiguration.h:42
alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent::create
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)
Definition: RangeControllerCapabilityAgent.cpp:150
CapabilityConfiguration.h
CapabilityState.h
alexaClientSDK::avsCommon::avs::CapabilityTag
Definition: CapabilityTag.h:32
alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent::getCapabilityConfiguration
avsCommon::avs::CapabilityConfiguration getCapabilityConfiguration()
Definition: RangeControllerCapabilityAgent.cpp:389

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