AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
alexaClientSDK::settings::SettingInterface< ValueT > Class Template Referenceabstract

#include <SettingInterface.h>

Inheritance diagram for alexaClientSDK::settings::SettingInterface< ValueT >:
Inheritance graph
[legend]

Public Types

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

virtual ~SettingInterface ()=default
 
virtual SetSettingResult setLocalChange (const ValueType &value)=0
 
virtual bool setAvsChange (const ValueType &value)=0
 
virtual bool clearData (const ValueType &value)=0
 
ValueType get () const
 
ValueType getDefault () const
 
bool addObserver (std::shared_ptr< ObserverType > observer)
 
void removeObserver (std::shared_ptr< ObserverType > &observer)
 

Protected Types

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

 SettingInterface (const ValueType &value)
 
void notifyObservers (SettingNotifications notification)
 

Protected Attributes

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...
 

Detailed Description

template<typename ValueT>
class alexaClientSDK::settings::SettingInterface< ValueT >

Interface for setting objects. Second template argument is used to restrict usage to the types accepted.

The setting implementation only support types that have the following properties:

Template Parameters
ValueTThe setting value type.

Member Typedef Documentation

◆ GuardedValue

template<typename ValueT >
using alexaClientSDK::settings::SettingInterface< ValueT >::GuardedValue = avsCommon::utils::GuardedValue<ValueType>
protected

Alias for GuardedValue with the templated value ValueType.

◆ LogEntry

template<typename ValueT >
using alexaClientSDK::settings::SettingInterface< ValueT >::LogEntry = avsCommon::utils::logger::LogEntry
protected

Alias to make log entries less verbose.

◆ ObserverType

Define the observer type for this setting.

◆ ValueType

template<typename ValueT >
using alexaClientSDK::settings::SettingInterface< ValueT >::ValueType = ValueT

Define the setting value type.

Constructor & Destructor Documentation

◆ ~SettingInterface()

template<typename ValueT >
virtual alexaClientSDK::settings::SettingInterface< ValueT >::~SettingInterface ( )
virtualdefault

Destructor.

◆ SettingInterface()

template<typename ValueT >
alexaClientSDK::settings::SettingInterface< ValueT >::SettingInterface ( const ValueType value)
protected

Constructor that initialize m_value with the given value.

Member Function Documentation

◆ addObserver()

template<typename ValueT >
bool alexaClientSDK::settings::SettingInterface< ValueT >::addObserver ( std::shared_ptr< ObserverType observer)
inline

Register a setting observer.

The observer will be executed every time the setting value changes or a request fails.

Parameters
observerThe connector to register for calling back whenever the setting notifications.
Returns
true if the observer was added, false otherwise.

◆ clearData()

template<typename ValueT >
virtual bool alexaClientSDK::settings::SettingInterface< ValueT >::clearData ( const ValueType value)
pure virtual

Clear the data this Setting.

Parameters
valueThe default value for this setting.
Returns
true if it data is cleared; otherwise.

Implemented in alexaClientSDK::diagnostics::test::SettingStub< ValueT >, alexaClientSDK::settings::Setting< ValueT >, and alexaClientSDK::settings::test::SettingStub< SettingT >.

◆ get()

template<typename ValueT >
ValueT alexaClientSDK::settings::SettingInterface< ValueT >::get ( ) const
inline

Get the current value of this setting. This will not take into consideration pending set requests.

Returns
The setting value.

◆ getDefault()

template<typename ValueT >
ValueT alexaClientSDK::settings::SettingInterface< ValueT >::getDefault ( ) const
inline

Get the default value of this setting.

Returns
The setting default value.

◆ notifyObservers()

template<typename ValueT >
void alexaClientSDK::settings::SettingInterface< ValueT >::notifyObservers ( SettingNotifications  notification)
protected

Notifies observers of the status of applying a setting and it's current value.

Parameters
notificationThe type of notification to send to the observers.

◆ removeObserver()

template<typename ValueT >
void alexaClientSDK::settings::SettingInterface< ValueT >::removeObserver ( std::shared_ptr< ObserverType > &  observer)
inline

Remove a setting observer.

Parameters
observerThe observer to remove.

◆ setAvsChange()

template<typename ValueT >
virtual bool alexaClientSDK::settings::SettingInterface< ValueT >::setAvsChange ( const ValueType value)
pure virtual

Request to set the managed setting to the given value. This should be used when the request came from AVS.

Parameters
valueThe target value.
Returns
true if it succeeds to enqueue the request; otherwise.

Implemented in alexaClientSDK::diagnostics::test::SettingStub< ValueT >, alexaClientSDK::settings::Setting< ValueT >, and alexaClientSDK::settings::test::SettingStub< SettingT >.

◆ setLocalChange()

template<typename ValueT >
virtual SetSettingResult alexaClientSDK::settings::SettingInterface< ValueT >::setLocalChange ( const ValueType value)
pure virtual

Request to set the managed setting to the given value. Note that this is an asynchronous operation.

Parameters
valueThe target value.
Returns
The result of the enqueue operation.

Implemented in alexaClientSDK::settings::Setting< ValueT >, alexaClientSDK::diagnostics::test::SettingStub< ValueT >, and alexaClientSDK::settings::test::SettingStub< SettingT >.

Member Data Documentation

◆ m_defaultValue

template<typename ValueT >
const ValueType alexaClientSDK::settings::SettingInterface< ValueT >::m_defaultValue
protected

The default setting value.

◆ m_observerMutex

template<typename ValueT >
std::mutex alexaClientSDK::settings::SettingInterface< ValueT >::m_observerMutex
protected

Mutex used to guard observers.

◆ m_observers

template<typename ValueT >
std::unordered_set<std::shared_ptr<ObserverType> > alexaClientSDK::settings::SettingInterface< ValueT >::m_observers
protected

Set of all observers of this setting.

◆ m_value

template<typename ValueT >
std::conditional<std::is_scalar<ValueType>::value, std::atomic<ValueType>, GuardedValue>::type alexaClientSDK::settings::SettingInterface< ValueT >::m_value
protected

The setting value. (is_trivially_copyable is not supported on gcc4.8)


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