AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
DNDSettingProtocol.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 ACSDKDONOTDISTURB_DNDSETTINGPROTOCOL_H_
17 #define ACSDKDONOTDISTURB_DNDSETTINGPROTOCOL_H_
18 
19 #include <memory>
20 #include <string>
21 #include <utility>
22 
30 #include <Settings/SettingStatus.h>
32 
33 namespace alexaClientSDK {
34 namespace capabilityAgents {
35 namespace doNotDisturb {
36 
42 public:
52  static std::unique_ptr<DNDSettingProtocol> create(
53  const settings::SettingEventMetadata& metadata,
54  std::shared_ptr<settings::SettingEventSenderInterface> eventSender,
55  std::shared_ptr<settings::storage::DeviceSettingStorageInterface> settingStorage,
56  const std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface>& metricRecorder);
57 
61  ApplyChangeFunction applyChange,
62  RevertChangeFunction revertChange,
64 
65  bool avsChange(
66  ApplyChangeFunction applyChange,
67  RevertChangeFunction revertChange,
68  SettingNotificationFunction notifyObservers) override;
69 
70  bool restoreValue(ApplyDbChangeFunction applyChange, SettingNotificationFunction notifyObservers) override;
71 
72  bool clearData() override;
74 
78  ~DNDSettingProtocol() = default;
79 
80 private:
89  const std::string& settingKey,
90  std::shared_ptr<settings::SettingEventSenderInterface> eventSender,
91  std::shared_ptr<settings::storage::DeviceSettingStorageInterface> settingStorage,
92  const std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface>& metricRecorder);
93 
95  const std::string m_key;
96 
98  std::shared_ptr<settings::SettingEventSenderInterface> m_eventSender;
99 
101  std::shared_ptr<settings::storage::DeviceSettingStorageInterface> m_storage;
102 
104  std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> m_metricRecorder;
105 
108 };
109 
110 } // namespace doNotDisturb
111 } // namespace capabilityAgents
112 } // namespace alexaClientSDK
113 
114 #endif // ACSDKDONOTDISTURB_DNDSETTINGPROTOCOL_H_
std::function< std::pair< bool, std::string >()> ApplyChangeFunction
Definition: SettingProtocolInterface.h:46
std::function< std::pair< bool, std::string >(const std::string &dbValue)> ApplyDbChangeFunction
Definition: SettingProtocolInterface.h:56
Definition: SettingEventMetadata.h:27
SetSettingResult localChange(ApplyChangeFunction applyChange, RevertChangeFunction revertChange, SettingNotificationFunction notifyObservers) override
Definition: DNDSettingProtocol.cpp:117
bool restoreValue(ApplyDbChangeFunction applyChange, SettingNotificationFunction notifyObservers) override
Definition: DNDSettingProtocol.cpp:223
bool avsChange(ApplyChangeFunction applyChange, RevertChangeFunction revertChange, SettingNotificationFunction notifyObservers) override
Definition: DNDSettingProtocol.cpp:167
std::function< void(SettingNotifications notification)> SettingNotificationFunction
Definition: SettingProtocolInterface.h:63
static std::unique_ptr< DNDSettingProtocol > create(const settings::SettingEventMetadata &metadata, std::shared_ptr< settings::SettingEventSenderInterface > eventSender, std::shared_ptr< settings::storage::DeviceSettingStorageInterface > settingStorage, const std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > &metricRecorder)
Definition: DNDSettingProtocol.cpp:94
std::function< std::string()> RevertChangeFunction
Definition: SettingProtocolInterface.h:70
SetSettingResult
Definition: SetSettingResult.h:23
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
bool clearData() override
Definition: DNDSettingProtocol.cpp:256
Definition: SettingProtocolInterface.h:38
static void notifyObservers(const ModeControllerInterface::ModeState &modeState, avsCommon::sdkInterfaces::AlexaStateChangeCauseType cause, const std::list< std::shared_ptr< ModeControllerObserverInterface >> &observers)
Definition: DefaultEndpointModeControllerHandler.cpp:61

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