AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Static Public Member Functions | List of all members
alexaClientSDK::capabilityAgents::doNotDisturb::DNDSettingProtocol Class Reference

#include <DNDSettingProtocol.h>

Inheritance diagram for alexaClientSDK::capabilityAgents::doNotDisturb::DNDSettingProtocol:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::capabilityAgents::doNotDisturb::DNDSettingProtocol:
Collaboration graph
[legend]

Public Member Functions

 ~DNDSettingProtocol ()=default
 
SettingProtocolInterface methods.
SetSettingResult localChange (ApplyChangeFunction applyChange, RevertChangeFunction revertChange, SettingNotificationFunction notifyObservers) override
 
bool avsChange (ApplyChangeFunction applyChange, RevertChangeFunction revertChange, SettingNotificationFunction notifyObservers) override
 
bool restoreValue (ApplyDbChangeFunction applyChange, SettingNotificationFunction notifyObservers) override
 
bool clearData () override
 
- Public Member Functions inherited from alexaClientSDK::settings::SettingProtocolInterface
virtual ~SettingProtocolInterface ()=default
 

Static Public Member Functions

static std::unique_ptr< DNDSettingProtocolcreate (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)
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::settings::SettingProtocolInterface
using ApplyChangeFunction = std::function< std::pair< bool, std::string >()>
 
using ApplyDbChangeFunction = std::function< std::pair< bool, std::string >(const std::string &dbValue)>
 
using SettingNotificationFunction = std::function< void(SettingNotifications notification)>
 
using RevertChangeFunction = std::function< std::string()>
 

Detailed Description

Implement the logic of DoNotDisturb protocol where AVS is the source of truth. This implementation corresponds to Alexa.DoNotDisturb v1.0 AVS interface.

Constructor & Destructor Documentation

◆ ~DNDSettingProtocol()

alexaClientSDK::capabilityAgents::doNotDisturb::DNDSettingProtocol::~DNDSettingProtocol ( )
default

Destructor.

Member Function Documentation

◆ avsChange()

bool alexaClientSDK::capabilityAgents::doNotDisturb::DNDSettingProtocol::avsChange ( ApplyChangeFunction  applyChange,
RevertChangeFunction  revertChange,
SettingNotificationFunction  notifyObservers 
)
overridevirtual

Implements the protocol for changing a setting value triggered by an AVS directive.

Parameters
applyChangeFunction that can be used to apply the new value.
revertChangeFunction that can be used to revert the change. This function should only be called if the apply change succeeded but some other part of the protocol has failed.
notifyObserversFunction used to notify the observers of the protocol result.
Returns
true if the directive was enqueued correctly; false otherwise.

We need to sent the report for failure or success case.

Implements alexaClientSDK::settings::SettingProtocolInterface.

◆ clearData()

bool alexaClientSDK::capabilityAgents::doNotDisturb::DNDSettingProtocol::clearData ( )
overridevirtual

Clear the data for this setting.

Returns
true if it data is cleared; otherwise.

Implements alexaClientSDK::settings::SettingProtocolInterface.

◆ create()

std::unique_ptr< DNDSettingProtocol > alexaClientSDK::capabilityAgents::doNotDisturb::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 
)
static

Create a protocol object.

Parameters
metadataThe setting metadata used to generate a unique database key.
eventSenderObject used to send events to avs in order to report changes to the device.
settingStorageThe setting storage object.
metricRecorderThe MetricRecorderInterface instance to record metrics.
Returns
A pointer to the new DNDSettingProtocol object if it succeeds; nullptr otherwise.

◆ localChange()

SetSettingResult alexaClientSDK::capabilityAgents::doNotDisturb::DNDSettingProtocol::localChange ( ApplyChangeFunction  applyChange,
RevertChangeFunction  revertChange,
SettingNotificationFunction  notifyObservers 
)
overridevirtual

Implements the protocol for changing a setting value through local UI.

Parameters
applyChangeFunction that can be used to apply the new value.
revertChangeFunction that can be used to revert the change. This function should only be called if the apply change succeeded but some other part of the protocol has failed.
notifyObserversFunction used to notify the observers of the protocol result.
Returns
Returns what was the set result.

Implements alexaClientSDK::settings::SettingProtocolInterface.

◆ restoreValue()

bool alexaClientSDK::capabilityAgents::doNotDisturb::DNDSettingProtocol::restoreValue ( ApplyDbChangeFunction  applyChange,
SettingNotificationFunction  notifyObservers 
)
overridevirtual

Implements the protocol for restoring a value from the storage.

Parameters
applyChangeFunction that can be used to apply the value restored from the storage. This function will be called with empty string if no value was found in the database.
notifyObserversFunction used to notify the observers of the protocol result.
Returns
true if the directive was enqueued correctly; false otherwise.

Implements alexaClientSDK::settings::SettingProtocolInterface.


The documentation for this class was generated from the following files:

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