AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Types | Public Member Functions | Static Public Attributes | List of all members
alexaClientSDK::settings::SettingsManager< SettingsT > Class Template Reference

#include <SettingsManager.h>

Inheritance diagram for alexaClientSDK::settings::SettingsManager< SettingsT >:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::settings::SettingsManager< SettingsT >:
Collaboration graph
[legend]

Public Types

template<size_t index>
using SettingType = typename std::tuple_element< index, std::tuple< SettingsT... > >::type
 The setting type kept at index position. More...
 
template<size_t index>
using ValueType = typename SettingType< index >::ValueType
 Define the value type for setting kept on position index. More...
 
template<size_t index>
using ObserverType = typename SettingType< index >::ObserverType
 Define the observer type for setting kept on position index. More...
 
template<typename SettingT >
using SettingPointerType = std::shared_ptr< SettingT >
 Define the shared_ptr type for the given SettingT. More...
 
using SettingConfigurations = std::tuple< SettingConfiguration< SettingsT >... >
 The tuple holding the settings configuration. More...
 

Public Member Functions

 SettingsManager (std::shared_ptr< registrationManager::CustomerDataManagerInterface > dataManager, SettingConfigurations settingConfigurations)
 
 SettingsManager (std::shared_ptr< registrationManager::CustomerDataManagerInterface > dataManager)
 
virtual ~SettingsManager ()=default
 
template<size_t index>
SetSettingResult setValue (const ValueType< index > &value)
 
template<size_t index>
std::pair< bool, ValueType< index > > getValue (const ValueType< index > &defaultValue=ValueType< index >()) const
 
template<size_t index>
std::string getJsonValue () const
 
template<size_t index>
bool addObserver (std::shared_ptr< ObserverType< index >> observer)
 
template<size_t index>
void removeObserver (std::shared_ptr< ObserverType< index >> observer)
 
template<size_t index>
bool addSetting (std::shared_ptr< SettingType< index >> setting)
 
template<size_t index>
void removeSetting (std::shared_ptr< SettingType< index >> setting)
 
template<size_t index>
bool hasSetting ()
 
SettingConfigurations getConfigurations () const
 
template<size_t index>
std::shared_ptr< SettingType< index > > getSetting () const
 
template<size_t index>
std::pair< bool, typename SettingsManager< SettingsT... >::template ValueType< index > > getValue (const ValueType< index > &defaultValue) const
 
template<size_t index>
std::shared_ptr< typename SettingsManager< SettingsT... >::template SettingType< index > > getSetting () const
 
CustomerDataHandler Functions
void clearData () override
 
- Public Member Functions inherited from alexaClientSDK::registrationManager::CustomerDataHandler
 CustomerDataHandler (const std::shared_ptr< registrationManager::CustomerDataManagerInterface > &dataManager)
 
virtual ~CustomerDataHandler ()
 
- Public Member Functions inherited from alexaClientSDK::registrationManager::CustomerDataHandlerInterface
virtual ~CustomerDataHandlerInterface ()=default
 

Static Public Attributes

static constexpr size_t NUMBER_OF_SETTINGS {sizeof...(SettingsT)}
 The number of settings supported by this manager. More...
 

Detailed Description

template<typename... SettingsT>
class alexaClientSDK::settings::SettingsManager< SettingsT >

The SettingsManager is responsible for managing settings.

Member Typedef Documentation

◆ ObserverType

template<typename... SettingsT>
template<size_t index>
using alexaClientSDK::settings::SettingsManager< SettingsT >::ObserverType = typename SettingType<index>::ObserverType

Define the observer type for setting kept on position index.

◆ SettingConfigurations

template<typename... SettingsT>
using alexaClientSDK::settings::SettingsManager< SettingsT >::SettingConfigurations = std::tuple<SettingConfiguration<SettingsT>...>

The tuple holding the settings configuration.

◆ SettingPointerType

template<typename... SettingsT>
template<typename SettingT >
using alexaClientSDK::settings::SettingsManager< SettingsT >::SettingPointerType = std::shared_ptr<SettingT>

Define the shared_ptr type for the given SettingT.

◆ SettingType

template<typename... SettingsT>
template<size_t index>
using alexaClientSDK::settings::SettingsManager< SettingsT >::SettingType = typename std::tuple_element<index, std::tuple<SettingsT...> >::type

The setting type kept at index position.

◆ ValueType

template<typename... SettingsT>
template<size_t index>
using alexaClientSDK::settings::SettingsManager< SettingsT >::ValueType = typename SettingType<index>::ValueType

Define the value type for setting kept on position index.

Constructor & Destructor Documentation

◆ SettingsManager() [1/2]

template<typename... SettingsT>
alexaClientSDK::settings::SettingsManager< SettingsT >::SettingsManager ( std::shared_ptr< registrationManager::CustomerDataManagerInterface dataManager,
SettingConfigurations  settingConfigurations 
)

Settings manager constructor.

Parameters
dataManagerA dataManager object that will track the CustomerDataHandler.
settingConfigurationsThe tuple holding the settings configuration.

◆ SettingsManager() [2/2]

template<typename... SettingsT>
alexaClientSDK::settings::SettingsManager< SettingsT >::SettingsManager ( std::shared_ptr< registrationManager::CustomerDataManagerInterface dataManager)

Settings manager constructor.

Deprecated:
Parameters
dataManagerA dataManager object that will track the CustomerDataHandler.

◆ ~SettingsManager()

template<typename... SettingsT>
virtual alexaClientSDK::settings::SettingsManager< SettingsT >::~SettingsManager ( )
virtualdefault

SettingsManager destructor.

Member Function Documentation

◆ addObserver()

template<typename... SettingsT>
template<size_t index>
bool alexaClientSDK::settings::SettingsManager< SettingsT >::addObserver ( std::shared_ptr< ObserverType< index >>  observer)

Register an observer for a given setting.

Template Parameters
indexThe index of the target setting.
Parameters
observerThe setting observer.
Returns
true if it succeed to add the observer, false otherwise.

◆ addSetting()

template<typename... SettingsT>
template<size_t index>
bool alexaClientSDK::settings::SettingsManager< SettingsT >::addSetting ( std::shared_ptr< SettingType< index >>  setting)

Register a new setting to be managed.

Template Parameters
indexThe index of the target setting.
Parameters
settingThe setting object.
Returns
true if it succeeds; false if manager already has a setting object from the same type.

◆ clearData()

template<typename... SettingsT>
void alexaClientSDK::settings::SettingsManager< SettingsT >::clearData ( )
overridevirtual

Reset any internal state that may be associated with a particular user.

Warning
Object must succeed in deleting any customer data.
This method is called while CustomerDataManager is in a locked state. Do not call or wait for any CustomerDataManager operation.

Implements alexaClientSDK::registrationManager::CustomerDataHandlerInterface.

◆ getConfigurations()

template<typename... SettingsT>
std::tuple< SettingConfiguration< SettingsT >... > alexaClientSDK::settings::SettingsManager< SettingsT >::getConfigurations ( ) const

Gets the settings configuration.

Returns
the settings configuration.

◆ getJsonValue()

template<typename... SettingsT>
template<size_t index>
std::string alexaClientSDK::settings::SettingsManager< SettingsT >::getJsonValue ( ) const

Get a json representation of the current setting value.

Template Parameters
indexThe index of the target setting.
Returns
The json representation of the given setting. An empty string will be returned if the setting doesn't exist or conversion failed.

◆ getSetting() [1/2]

template<typename... SettingsT>
template<size_t index>
std::shared_ptr<SettingType<index> > alexaClientSDK::settings::SettingsManager< SettingsT >::getSetting ( ) const

Gets the setting for the given index.

Template Parameters
indexThe setting index.
Returns
A pointer for the setting kept in index if the setting has been built; nullptr otherwise.
Note
This function should be used after build() has been called.

◆ getSetting() [2/2]

template<typename... SettingsT>
template<size_t index>
std::shared_ptr<typename SettingsManager<SettingsT...>::template SettingType<index> > alexaClientSDK::settings::SettingsManager< SettingsT >::getSetting ( ) const

◆ getValue() [1/2]

template<typename... SettingsT>
template<size_t index>
std::pair<bool, ValueType<index> > alexaClientSDK::settings::SettingsManager< SettingsT >::getValue ( const ValueType< index > &  defaultValue = ValueType< index >()) const

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

Template Parameters
indexThe index of the target setting.
Parameters
defaultValueThe value to be returned in case the setting does not exist.
Returns
A pair representing whether the setting exist and what is its value. If the setting doesn't exist, this function will return {false, defaultValue}. If the setting exist, it will return {true, settingValue}.

◆ getValue() [2/2]

template<typename... SettingsT>
template<size_t index>
std::pair<bool, typename SettingsManager<SettingsT...>::template ValueType<index> > alexaClientSDK::settings::SettingsManager< SettingsT >::getValue ( const ValueType< index > &  defaultValue) const

◆ hasSetting()

template<typename... SettingsT>
template<size_t index>
bool alexaClientSDK::settings::SettingsManager< SettingsT >::hasSetting ( )

Checks if a setting is available.

Template Parameters
indexThe index of the target setting.
Returns
true if the setting is available, false otherwise.

◆ removeObserver()

template<typename... SettingsT>
template<size_t index>
void alexaClientSDK::settings::SettingsManager< SettingsT >::removeObserver ( std::shared_ptr< ObserverType< index >>  observer)

Unregister an observer for a given setting.

Template Parameters
indexThe index of the target setting.
Parameters
observerThe setting observer.

◆ removeSetting()

template<typename... SettingsT>
template<size_t index>
void alexaClientSDK::settings::SettingsManager< SettingsT >::removeSetting ( std::shared_ptr< SettingType< index >>  setting)

Unregister a new setting to be managed.

Template Parameters
indexThe index of the target setting.
Parameters
settingThe setting object.

◆ setValue()

template<typename... SettingsT>
template<size_t index>
SetSettingResult alexaClientSDK::settings::SettingsManager< SettingsT >::setValue ( const ValueType< index > &  value)

Enqueue request to set the given settings represented by id to the given value.

Template Parameters
indexThe index of the target setting.
Parameters
valueThe set value.
Returns
The result of the enqueue operation.

Member Data Documentation

◆ NUMBER_OF_SETTINGS

template<typename... SettingsT>
constexpr size_t alexaClientSDK::settings::SettingsManager< SettingsT >::NUMBER_OF_SETTINGS {sizeof...(SettingsT)}
static

The number of settings supported by this manager.


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

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