AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
ToggleControllerCapabilityAgent.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_TOGGLECONTROLLER_INCLUDE_TOGGLECONTROLLER_TOGGLECONTROLLERCAPABILITYAGENT_H_
17 #define ALEXA_CLIENT_SDK_CAPABILITYAGENTS_TOGGLECONTROLLER_INCLUDE_TOGGLECONTROLLER_TOGGLECONTROLLERCAPABILITYAGENT_H_
18 
30 
31 namespace alexaClientSDK {
32 namespace capabilityAgents {
33 namespace toggleController {
34 
45  , public std::enable_shared_from_this<ToggleControllerCapabilityAgent> {
46 public:
50 
69  static std::shared_ptr<ToggleControllerCapabilityAgent> create(
70  const EndpointIdentifier& endpointId,
71  const std::string& instance,
73  std::shared_ptr<avsCommon::sdkInterfaces::toggleController::ToggleControllerInterface> toggleController,
74  std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> contextManager,
75  std::shared_ptr<avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface> responseSender,
76  std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> exceptionSender,
77  bool isProactivelyReported,
78  bool isRetrievable,
79  bool isNonControllable = false);
80 
83  void handleDirectiveImmediately(std::shared_ptr<avsCommon::avs::AVSDirective> directive) override;
84  void preHandleDirective(std::shared_ptr<DirectiveInfo> info) override;
85  void handleDirective(std::shared_ptr<DirectiveInfo> info) override;
86  void cancelDirective(std::shared_ptr<DirectiveInfo> info) override;
89 
92  void provideState(
93  const avsCommon::avs::CapabilityTag& stateProviderName,
94  const avsCommon::sdkInterfaces::ContextRequestToken contextRequestToken) override;
95  bool canStateBeRetrieved() override;
96  bool hasReportableStateProperties() override;
98 
105 
109  override;
111 
112 private:
131  const EndpointIdentifier& endpointId,
132  const std::string& instance,
134  std::shared_ptr<avsCommon::sdkInterfaces::toggleController::ToggleControllerInterface> toggleController,
135  std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> contextManager,
136  std::shared_ptr<avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface> responseSender,
137  std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> exceptionSender,
138  bool isProactivelyReported,
139  bool isRetrievable,
140  bool isNonControllable = false);
141 
142  // @name RequiresShutdown Functions
144  void doShutdown() override;
146 
152  bool initialize();
153 
159  void removeDirective(std::shared_ptr<DirectiveInfo> info);
160 
166  void executeSetHandlingCompleted(std::shared_ptr<DirectiveInfo> info);
167 
174  void executeUnknownDirective(std::shared_ptr<DirectiveInfo> info, avsCommon::avs::ExceptionErrorType type);
175 
182  void executeProvideState(
183  const avsCommon::avs::CapabilityTag& stateProviderName,
184  const avsCommon::sdkInterfaces::ContextRequestToken contextRequestToken);
185 
193  void executeSendResponseEvent(
194  const std::shared_ptr<avsCommon::avs::CapabilityAgent::DirectiveInfo> info,
195  std::pair<avsCommon::avs::AlexaResponseType, std::string> result);
196 
202  avsCommon::avs::CapabilityState buildCapabilityState(const ToggleState& toggleState);
203 
205  EndpointIdentifier m_endpointId;
206 
208  std::string m_instance;
209 
211  bool m_isProactivelyReported;
212 
214  bool m_isRetrievable;
215 
217  bool m_isNonControllable;
218 
221 
223  std::shared_ptr<avsCommon::sdkInterfaces::toggleController::ToggleControllerInterface> m_toggleController;
224 
226  std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> m_contextManager;
227 
229  std::shared_ptr<avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface> m_responseSender;
230 
233 };
234 
235 } // namespace toggleController
236 } // namespace capabilityAgents
237 } // namespace alexaClientSDK
238 
239 #endif // ALEXA_CLIENT_SDK_CAPABILITYAGENTS_TOGGLECONTROLLER_INCLUDE_TOGGLECONTROLLER_TOGGLECONTROLLERCAPABILITYAGENT_H_
Definition: CapabilityAgent.h:47
void handleDirectiveImmediately(std::shared_ptr< avsCommon::avs::AVSDirective > directive) override
Definition: CapabilityTag.h:32
avsCommon::avs::DirectiveHandlerConfiguration getConfiguration() const override
::std::string string
Definition: gtest-port.h:1097
void cancelDirective(std::shared_ptr< DirectiveInfo > info) override
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
static std::shared_ptr< ToggleControllerCapabilityAgent > create(const EndpointIdentifier &endpointId, const std::string &instance, const avsCommon::sdkInterfaces::toggleController::ToggleControllerAttributes &toggleControllerAttributes, std::shared_ptr< avsCommon::sdkInterfaces::toggleController::ToggleControllerInterface > toggleController, 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)
void handleDirective(std::shared_ptr< DirectiveInfo > info) override
avsCommon::sdkInterfaces::endpoints::EndpointIdentifier EndpointIdentifier
Alias to improve readability.
Definition: ToggleControllerCapabilityAgent.h:48
AlexaStateChangeCauseType
Definition: AlexaStateChangeCauseType.h:28
avsCommon::sdkInterfaces::toggleController::ToggleControllerObserverInterface::ToggleState ToggleState
Alias to improve readability.
Definition: ToggleControllerInterface.h:41
std::unordered_map< directiveRoutingRule::DirectiveRoutingRule, BlockingPolicy > DirectiveHandlerConfiguration
Definition: DirectiveHandlerConfiguration.h:32
Definition: CapabilityState.h:31
void onToggleStateChanged(const ToggleState &toggleState, avsCommon::sdkInterfaces::AlexaStateChangeCauseType cause) override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
type
Definition: upload.py:443
std::string EndpointIdentifier
Definition: EndpointIdentifier.h:38
Definition: CapabilityConfiguration.h:42
void preHandleDirective(std::shared_ptr< DirectiveInfo > info) override
void provideState(const avsCommon::avs::CapabilityTag &stateProviderName, const avsCommon::sdkInterfaces::ContextRequestToken contextRequestToken) 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