AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Types | Public Member Functions | List of all members
alexaClientSDK::settings::SettingProtocolInterface Class Referenceabstract

#include <SettingProtocolInterface.h>

Inheritance diagram for alexaClientSDK::settings::SettingProtocolInterface:
Inheritance graph
[legend]

Public Types

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()>
 

Public Member Functions

virtual SetSettingResult localChange (ApplyChangeFunction applyChange, RevertChangeFunction revertChange, SettingNotificationFunction notifyObservers)=0
 
virtual bool avsChange (ApplyChangeFunction applyChange, RevertChangeFunction revertChange, SettingNotificationFunction notifyObservers)=0
 
virtual bool restoreValue (ApplyDbChangeFunction applyChange, SettingNotificationFunction notifyObservers)=0
 
virtual bool clearData ()=0
 
virtual ~SettingProtocolInterface ()=default
 

Detailed Description

Interface for the multiple setting management protocols.

The setting protocol should ensure that events are sent to AVS as expected and the setting value is persisted. The setting protocol also MUST only execute one request at a time.

Member Typedef Documentation

◆ ApplyChangeFunction

using alexaClientSDK::settings::SettingProtocolInterface::ApplyChangeFunction = std::function<std::pair<bool, std::string>()>

Callback function type used for applying new values.

Returns
A pair where the first element indicates if the operation succeeded or not, and the second element is a string representation of the final value.

◆ ApplyDbChangeFunction

using alexaClientSDK::settings::SettingProtocolInterface::ApplyDbChangeFunction = std::function<std::pair<bool, std::string>(const std::string& dbValue)>

Callback function type used for applying value retrieved from the database.

Parameters
dbValueA string representation of the value retrieved from the database. An empty string will be used to indicate that no value was found in the database.
Returns
A pair where the first element indicates if the operation succeeded or not, and the second element is a string representation of the final value.

◆ RevertChangeFunction

Callback function type used to revert the last value change.

Returns
A string representation of the setting value after the revert operation.

◆ SettingNotificationFunction

Callback function type used to notify observers of whether the request succeeded or failed.

Parameters
notificationThe operation result.

Constructor & Destructor Documentation

◆ ~SettingProtocolInterface()

virtual alexaClientSDK::settings::SettingProtocolInterface::~SettingProtocolInterface ( )
virtualdefault

Destructor.

Member Function Documentation

◆ avsChange()

virtual bool alexaClientSDK::settings::SettingProtocolInterface::avsChange ( ApplyChangeFunction  applyChange,
RevertChangeFunction  revertChange,
SettingNotificationFunction  notifyObservers 
)
pure virtual

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.

Implemented in alexaClientSDK::settings::SharedAVSSettingProtocol, alexaClientSDK::settings::CloudControlledSettingProtocol, alexaClientSDK::capabilityAgents::doNotDisturb::DNDSettingProtocol, alexaClientSDK::settings::DeviceControlledSettingProtocol, and alexaClientSDK::settings::test::MockSettingProtocol.

◆ clearData()

virtual bool alexaClientSDK::settings::SettingProtocolInterface::clearData ( )
pure virtual

◆ localChange()

virtual SetSettingResult alexaClientSDK::settings::SettingProtocolInterface::localChange ( ApplyChangeFunction  applyChange,
RevertChangeFunction  revertChange,
SettingNotificationFunction  notifyObservers 
)
pure virtual

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.

Implemented in alexaClientSDK::settings::SharedAVSSettingProtocol, alexaClientSDK::settings::CloudControlledSettingProtocol, alexaClientSDK::capabilityAgents::doNotDisturb::DNDSettingProtocol, alexaClientSDK::settings::DeviceControlledSettingProtocol, and alexaClientSDK::settings::test::MockSettingProtocol.

◆ restoreValue()

virtual bool alexaClientSDK::settings::SettingProtocolInterface::restoreValue ( ApplyDbChangeFunction  applyChange,
SettingNotificationFunction  notifyObservers 
)
pure virtual

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.

Implemented in alexaClientSDK::settings::SharedAVSSettingProtocol, alexaClientSDK::settings::CloudControlledSettingProtocol, alexaClientSDK::capabilityAgents::doNotDisturb::DNDSettingProtocol, alexaClientSDK::settings::DeviceControlledSettingProtocol, and alexaClientSDK::settings::test::MockSettingProtocol.


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

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