AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Public Member Functions | Static Public Member Functions | List of all members
alexaClientSDK::afml::FocusManager Class Reference

#include <FocusManager.h>

Inheritance diagram for alexaClientSDK::afml::FocusManager:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::afml::FocusManager:
Collaboration graph
[legend]

Classes

class  ChannelConfiguration
 

Public Member Functions

 FocusManager (const std::vector< ChannelConfiguration > &channelConfigurations, std::shared_ptr< ActivityTrackerInterface > activityTrackerInterface=nullptr, const std::vector< ChannelConfiguration > &virtualChannelConfigurations=std::vector< ChannelConfiguration >(), std::shared_ptr< interruptModel::InterruptModel > interruptModel=nullptr)
 
bool acquireChannel (const std::string &channelName, std::shared_ptr< avsCommon::sdkInterfaces::ChannelObserverInterface > channelObserver, const std::string &interfaceName) override
 
bool acquireChannel (const std::string &channelName, std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface::Activity > channelActivity) override
 
std::future< bool > releaseChannel (const std::string &channelName, std::shared_ptr< avsCommon::sdkInterfaces::ChannelObserverInterface > channelObserver) override
 
void stopForegroundActivity () override
 
void stopAllActivities () override
 
void addObserver (const std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerObserverInterface > &observer) override
 
void removeObserver (const std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerObserverInterface > &observer) override
 
void modifyContentType (const std::string &channelName, const std::string &interfaceName, avsCommon::avs::ContentType contentType) override
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::FocusManagerInterface
virtual ~FocusManagerInterface ()=default
 Destructor. More...
 
virtual bool acquireChannel (const std::string &channelName, std::shared_ptr< avsCommon::sdkInterfaces::ChannelObserverInterface > channelObserver, const std::string &interfaceName)=0
 
virtual bool acquireChannel (const std::string &channelName, std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface::Activity > channelActivity)=0
 
virtual std::future< bool > releaseChannel (const std::string &channelName, std::shared_ptr< avsCommon::sdkInterfaces::ChannelObserverInterface > channelObserver)=0
 
virtual void addObserver (const std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerObserverInterface > &observer)=0
 
virtual void removeObserver (const std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerObserverInterface > &observer)=0
 

Static Public Member Functions

static const std::vector< FocusManager::ChannelConfigurationgetDefaultAudioChannels ()
 
static const std::vector< FocusManager::ChannelConfigurationgetDefaultVisualChannels ()
 

Additional Inherited Members

- Static Public Attributes inherited from alexaClientSDK::avsCommon::sdkInterfaces::FocusManagerInterface
static constexpr const char * DIALOG_CHANNEL_NAME = "Dialog"
 The default Dialog Channel name. More...
 
static constexpr unsigned int DIALOG_CHANNEL_PRIORITY = 100
 The default dialog Channel priority. More...
 
static constexpr const char * COMMUNICATIONS_CHANNEL_NAME = "Communications"
 The default Communications Channel name. More...
 
static constexpr unsigned int COMMUNICATIONS_CHANNEL_PRIORITY = 150
 The default Communications Channel priority. More...
 
static constexpr const char * ALERT_CHANNEL_NAME = "Alert"
 The default Alert Channel name. More...
 
static constexpr unsigned int ALERT_CHANNEL_PRIORITY = 200
 The default Alert Channel priority. More...
 
static constexpr const char * CONTENT_CHANNEL_NAME = "Content"
 The default Content Channel name. More...
 
static constexpr unsigned int CONTENT_CHANNEL_PRIORITY = 300
 The default Content Channel priority. More...
 
static constexpr const char * VISUAL_CHANNEL_NAME = "Visual"
 The default Visual Channel name. More...
 
static constexpr unsigned int VISUAL_CHANNEL_PRIORITY = 100
 The default Visual Channel priority. More...
 

Detailed Description

The FocusManager takes requests to acquire and release Channels and updates the focuses of other Channels based on their priorities so that the invariant that there can only be one Foreground Channel is held. The following operations are provided:

acquire Channel - clients should call the acquireChannel() method, passing in the name of the Channel they wish to acquire, a pointer to the observer that they want to be notified once they get focus, and a unique interface name.

release Channel - clients should call the releaseChannel() method, passing in the name of the Channel and the observer of the Channel they wish to release.

stop foreground Channel - clients should call the stopForegroundActivity() method.

All of these methods will notify the observer of the Channel of focus changes via an asynchronous callback to the ChannelObserverInterface##onFocusChanged() method, at which point the client should make a user observable change based on the focus it receives.

Constructor & Destructor Documentation

◆ FocusManager()

alexaClientSDK::afml::FocusManager::FocusManager ( const std::vector< ChannelConfiguration > &  channelConfigurations,
std::shared_ptr< ActivityTrackerInterface activityTrackerInterface = nullptr,
const std::vector< ChannelConfiguration > &  virtualChannelConfigurations = std::vector< ChannelConfiguration >(),
std::shared_ptr< interruptModel::InterruptModel interruptModel = nullptr 
)

This constructor creates Channels based on the provided configurations.

Parameters
channelConfigurationsA vector of channelConfiguration objects that will be used to create the Channels. No two Channels should have the same name or priority. If there are multiple configurations with the same name or priority, the latter Channels with that name or priority will not be created.
activityTrackerInterfaceThe interface to notify the activity tracker a vector of channel states that has been updated.
virtualChannelConfigurationsA vector of channelConfiguration objects that will be used to create the Virtual Channels. No two Channels should have the same name or priority. If there are multiple configurations with the same name or priority, the latter Channels with that name or priority will not be created.
interruptModelInterruptModel object that provides MixingBehavior inputs to ChannelObservers upon Focus State Change.

Member Function Documentation

◆ acquireChannel() [1/2]

bool alexaClientSDK::afml::FocusManager::acquireChannel ( const std::string &  channelName,
std::shared_ptr< avsCommon::sdkInterfaces::ChannelObserverInterface channelObserver,
const std::string &  interfaceName 
)
override

◆ acquireChannel() [2/2]

bool alexaClientSDK::afml::FocusManager::acquireChannel ( const std::string &  channelName,
std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface::Activity channelActivity 
)
override

◆ addObserver()

void alexaClientSDK::afml::FocusManager::addObserver ( const std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerObserverInterface > &  observer)
override

◆ getDefaultAudioChannels()

static const std::vector<FocusManager::ChannelConfiguration> alexaClientSDK::afml::FocusManager::getDefaultAudioChannels ( )
static

Retrieves the default ChannelConfiguration for AVS audio channels.

Returns
the default ChannelConfiguration for AVS audio channels.

◆ getDefaultVisualChannels()

static const std::vector<FocusManager::ChannelConfiguration> alexaClientSDK::afml::FocusManager::getDefaultVisualChannels ( )
static

Retrieves the default ChannelConfiguration for AVS visual channels.

Returns
the default ChannelConfiguration for AVS visual channels.

◆ modifyContentType()

void alexaClientSDK::afml::FocusManager::modifyContentType ( const std::string &  channelName,
const std::string &  interfaceName,
avsCommon::avs::ContentType  contentType 
)
overridevirtual

This function allows ChannelObservers to modify the ContentType rendering on their associated Activity This will cause the focus manager to reconsult the interruptModel in order to determine the new MixingBehavior for all backgrounded channels.

Parameters
channelNamethe channel associated with the ChannelObserver
interfaceNamethe interface name associated with the ChannelObserver
contentTypethe new content type

Implements alexaClientSDK::avsCommon::sdkInterfaces::FocusManagerInterface.

◆ releaseChannel()

std::future<bool> alexaClientSDK::afml::FocusManager::releaseChannel ( const std::string &  channelName,
std::shared_ptr< avsCommon::sdkInterfaces::ChannelObserverInterface channelObserver 
)
override

◆ removeObserver()

void alexaClientSDK::afml::FocusManager::removeObserver ( const std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerObserverInterface > &  observer)
override

◆ stopAllActivities()

void alexaClientSDK::afml::FocusManager::stopAllActivities ( )
overridevirtual

This method will request to stop all active channels. This will be performed asynchronously, and so, if at the time performing the stop, the channel is owned by another interface, this channel won't get stopped.

Implements alexaClientSDK::avsCommon::sdkInterfaces::FocusManagerInterface.

◆ stopForegroundActivity()

void alexaClientSDK::afml::FocusManager::stopForegroundActivity ( )
overridevirtual

This method will request that the currently foregrounded Channel activity be stopped, if there is one. This will be performed asynchronously, and so, if at the time of processing, the activity has stopped for any reason, then no stop will be performed. If something was stopped, the next highest priority active Channel will be brought to the foreground.

Implements alexaClientSDK::avsCommon::sdkInterfaces::FocusManagerInterface.


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