AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
ReportStateHandler.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_SYSTEM_INCLUDE_SYSTEM_REPORTSTATEHANDLER_H_
17 #define ALEXA_CLIENT_SDK_CAPABILITYAGENTS_SYSTEM_INCLUDE_SYSTEM_REPORTSTATEHANDLER_H_
18 
19 #include <memory>
20 #include <string>
21 #include <thread>
22 
31 
33 
34 namespace alexaClientSDK {
35 namespace capabilityAgents {
36 namespace system {
37 
44 public:
56  static std::unique_ptr<ReportStateHandler> create(
57  std::shared_ptr<registrationManager::CustomerDataManagerInterface> dataManager,
58  std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> exceptionEncounteredSender,
59  std::shared_ptr<avsCommon::sdkInterfaces::AVSConnectionManagerInterface> connectionManager,
60  std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface> messageSender,
61  std::shared_ptr<avsCommon::sdkInterfaces::storage::MiscStorageInterface> settingStorage,
62  const std::vector<StateReportGenerator>& generators);
63 
67  void handleDirectiveImmediately(std::shared_ptr<avsCommon::avs::AVSDirective> directive) override;
68  void preHandleDirective(std::shared_ptr<avsCommon::avs::CapabilityAgent::DirectiveInfo> info) override;
69  void handleDirective(std::shared_ptr<avsCommon::avs::CapabilityAgent::DirectiveInfo> info) override;
70  void cancelDirective(std::shared_ptr<avsCommon::avs::CapabilityAgent::DirectiveInfo> info) override;
72 
75  void clearData() override;
77 
82 
88  void addStateReportGenerator(const StateReportGenerator& generator);
89 
90 private:
103  std::shared_ptr<registrationManager::CustomerDataManagerInterface> dataManager,
104  std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> exceptionEncounteredSender,
105  std::shared_ptr<avsCommon::sdkInterfaces::AVSConnectionManagerInterface> connectionManager,
106  std::shared_ptr<avsCommon::sdkInterfaces::storage::MiscStorageInterface> storage,
107  std::unique_ptr<settings::SettingEventSenderInterface> eventSender,
108  const std::vector<StateReportGenerator>& generators,
109  bool pendingReport);
110 
116  bool handleReportState(const avsCommon::avs::AVSDirective& directive);
117 
121  void sendReportState();
122 
126  void initialize();
127 
128 private:
130  std::mutex m_stateMutex;
131 
134 
136  std::shared_ptr<avsCommon::sdkInterfaces::AVSConnectionManagerInterface> m_connectionManager;
137 
139  std::shared_ptr<avsCommon::sdkInterfaces::storage::MiscStorageInterface> m_storage;
140 
142  std::vector<StateReportGenerator> m_generators;
143 
145  std::unique_ptr<settings::SettingEventSenderInterface> m_eventSender;
146 
148  std::shared_ptr<settings::SettingConnectionObserver> m_connectionObserver;
149 
151  bool m_pendingReport;
152 };
153 
154 } // namespace system
155 } // namespace capabilityAgents
156 } // namespace alexaClientSDK
157 
158 #endif // ALEXA_CLIENT_SDK_CAPABILITYAGENTS_SYSTEM_INCLUDE_SYSTEM_REPORTSTATEHANDLER_H_
Definition: CapabilityAgent.h:47
Single-thread executor implementation.
Definition: Executor.h:45
void addStateReportGenerator(const StateReportGenerator &generator)
std::unordered_map< directiveRoutingRule::DirectiveRoutingRule, BlockingPolicy > DirectiveHandlerConfiguration
Definition: DirectiveHandlerConfiguration.h:32
void handleDirectiveImmediately(std::shared_ptr< avsCommon::avs::AVSDirective > directive) override
static std::unique_ptr< ReportStateHandler > create(std::shared_ptr< registrationManager::CustomerDataManagerInterface > dataManager, std::shared_ptr< avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface > exceptionEncounteredSender, std::shared_ptr< avsCommon::sdkInterfaces::AVSConnectionManagerInterface > connectionManager, std::shared_ptr< avsCommon::sdkInterfaces::MessageSenderInterface > messageSender, std::shared_ptr< avsCommon::sdkInterfaces::storage::MiscStorageInterface > settingStorage, const std::vector< StateReportGenerator > &generators)
void handleDirective(std::shared_ptr< avsCommon::avs::CapabilityAgent::DirectiveInfo > info) override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
void preHandleDirective(std::shared_ptr< avsCommon::avs::CapabilityAgent::DirectiveInfo > info) override
void cancelDirective(std::shared_ptr< avsCommon::avs::CapabilityAgent::DirectiveInfo > info) override
avsCommon::avs::DirectiveHandlerConfiguration getConfiguration() const 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