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

#include <SettingCallbacks.h>

Public Types

template<size_t id>
using ValueType = typename ManagerT::template ValueType< id >
 Setting value type. More...
template<size_t id>
using FunctionType = std::function< void(const ValueType< id > &, SettingNotifications)>
 Callback function value type. More...

Public Member Functions

virtual ~SettingCallbacks ()
template<size_t id>
bool add (FunctionType< id > callback)
void removeAll ()

Static Public Member Functions

static std::shared_ptr< SettingCallbacks< ManagerT > > create (std::shared_ptr< ManagerT > manager)

Detailed Description

template<typename ManagerT>
class alexaClientSDK::settings::SettingCallbacks< ManagerT >

The SettingCallbacks allow easy management of callbacks to monitor multiple settings with one object only.

This object can be used to register multiple callbacks that are member functions, lambdas and static functions. E.g.:

MyClass(std::shared_ptr<DeviceSettingManagers> manager) : m_callbacks {manager} {
m_callbacks.add<ALARM_VOLUME_RAMP>([](bool enable, SettingNotifications notification){
// do something...
m_callbacks.add<WAKEWORD_CONFIRMATION>(std::bind(this, &MyClass::onWakewordConfirmation, std::placeholder::_1));
~MyClass() {
// Observers get removed during destruction.

If you would like to listen notifications related to only one setting, see SettingEventCallback class or extend the SettingObserverInterface class.

Template Parameters
SettingsTSettings type enumeration.

Member Typedef Documentation

◆ FunctionType

template<typename ManagerT >
template<size_t id>
using alexaClientSDK::settings::SettingCallbacks< ManagerT >::FunctionType = std::function<void(const ValueType<id>&, SettingNotifications)>

Callback function value type.

◆ ValueType

template<typename ManagerT >
template<size_t id>
using alexaClientSDK::settings::SettingCallbacks< ManagerT >::ValueType = typename ManagerT::template ValueType<id>

Setting value type.

Constructor & Destructor Documentation

◆ ~SettingCallbacks()

template<typename ManagerT >
alexaClientSDK::settings::SettingCallbacks< ManagerT >::~SettingCallbacks ( )

The destructor.

Member Function Documentation

◆ add()

template<typename ManagerT >
template<size_t id>
bool alexaClientSDK::settings::SettingCallbacks< ManagerT >::add ( SettingCallbacks< ManagerT >::FunctionType< id >  callback)

Add a callback function to the setting with id.

Template Parameters
idThe property id.
callbackThe callback function.
true if it succeeds; false otherwise.

◆ create()

template<typename ManagerT >
std::shared_ptr< SettingCallbacks< ManagerT > > alexaClientSDK::settings::SettingCallbacks< ManagerT >::create ( std::shared_ptr< ManagerT >  manager)

Create a SettingCallbacks object.

This method allow user to use static / lambda functions as the callbacks.

managerThe object that manages all settings.
callbackThe callback function for SettingT.
otherCallbacksThe callback functions for the rest of the settings.
Pointer to new object if it succeeds to add all callbacks, nullptr otherwise.

◆ removeAll()

template<typename ManagerT >
void alexaClientSDK::settings::SettingCallbacks< ManagerT >::removeAll ( )

Disconnects the observed setting from all observed settings. This function also gets called by the destructor.

managerThe object that manages all settings.
observerThe observer object to be disconnected.
if it succeeds, false otherwise.

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

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