AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#include <Setting.h>
Public Types | |
using | ValueType = ValueT |
Define an alias for setting value type. More... | |
Public Types inherited from alexaClientSDK::settings::SettingInterface< ValueT > | |
using | ValueType = ValueT |
Define the setting value type. More... | |
using | ObserverType = SettingObserverInterface< SettingInterface< ValueType > > |
Define the observer type for this setting. More... | |
Public Member Functions | |
SettingInterface methods. | |
SetSettingResult | setLocalChange (const ValueType &value) override |
bool | setAvsChange (const ValueType &value) override |
bool | clearData (const ValueType &value) override |
Public Member Functions inherited from alexaClientSDK::settings::SettingInterface< ValueT > | |
virtual | ~SettingInterface ()=default |
ValueType | get () const |
ValueType | getDefault () const |
bool | addObserver (std::shared_ptr< ObserverType > observer) |
void | removeObserver (std::shared_ptr< ObserverType > &observer) |
Static Public Member Functions | |
static std::shared_ptr< Setting< ValueT > > | create (const ValueType &defaultValue, std::unique_ptr< SettingProtocolInterface > settingProtocol, std::function< bool(const ValueType &)> applyValueFn=std::function< bool(const ValueType &)>()) |
Additional Inherited Members | |
Protected Types inherited from alexaClientSDK::settings::SettingInterface< ValueT > | |
using | GuardedValue = avsCommon::utils::GuardedValue< ValueType > |
Alias for GuardedValue with the templated value ValueType . More... | |
using | LogEntry = avsCommon::utils::logger::LogEntry |
Alias to make log entries less verbose. More... | |
Protected Member Functions inherited from alexaClientSDK::settings::SettingInterface< ValueT > | |
SettingInterface (const ValueType &value) | |
void | notifyObservers (SettingNotifications notification) |
Protected Attributes inherited from alexaClientSDK::settings::SettingInterface< ValueT > | |
std::mutex | m_observerMutex |
Mutex used to guard observers. More... | |
std::unordered_set< std::shared_ptr< ObserverType > > | m_observers |
Set of all observers of this setting. More... | |
std::conditional< std::is_scalar< ValueType >::value, std::atomic< ValueType >, GuardedValue >::type | m_value |
The setting value. (is_trivially_copyable is not supported on gcc4.8) More... | |
const ValueType | m_defaultValue |
The default setting value. More... | |
The setting class implements the setting interface for the given value.
This class provide methods to set value through local request (set
method) and through AVS request (setAvsChange
). This setting should also be able to persist the current value as well as revert to previous value if a transaction fails.
The setting can be configured to use multiple avs synchronization protocols. See SettingProtocolInterface
.
ValueT | The type of the value used to represent a given setting. |
using alexaClientSDK::settings::Setting< ValueT >::ValueType = ValueT |
Define an alias for setting value type.
|
overridevirtual |
Clear the data this Setting
.
value | The default value for this setting. |
true
if it data is cleared; otherwise. Implements alexaClientSDK::settings::SettingInterface< ValueT >.
|
static |
Create a Setting
object.
defaultValue | The default value to be used if no value was found in the storage. |
settingProtocol | The avs protocol used to persist and synchronize values with avs. |
applyValueFn | Function responsible for validating and applying a new setting value to the device. |
applyValueFn
should succeed if there is no value change. nullptr
otherwise.
|
overridevirtual |
Request to set the managed setting to the given value
. This should be used when the request came from AVS.
value | The target value. |
true
if it succeeds to enqueue the request; otherwise. Implements alexaClientSDK::settings::SettingInterface< ValueT >.
|
overridevirtual |
Request to set the managed setting to the given value
. Note that this is an asynchronous operation.
value | The target value. |
Implements alexaClientSDK::settings::SettingInterface< ValueT >.
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0