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::contextManager::ContextManager Class Reference

#include <ContextManager.h>

Inheritance diagram for alexaClientSDK::contextManager::ContextManager:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::contextManager::ContextManager:
Collaboration graph
[legend]

Public Member Functions

 ~ContextManager () override
 Destructor. More...
 
ContextManagerInterface methods.
void setStateProvider (const avsCommon::avs::CapabilityTag &stateProviderName, std::shared_ptr< avsCommon::sdkInterfaces::StateProviderInterface > stateProvider) override
 
void addStateProvider (const avsCommon::avs::CapabilityTag &capabilityIdentifier, std::shared_ptr< avsCommon::sdkInterfaces::StateProviderInterface > stateProvider) override
 
void removeStateProvider (const avsCommon::avs::CapabilityTag &capabilityIdentifier) override
 
avsCommon::sdkInterfaces::SetStateResult setState (const avsCommon::avs::CapabilityTag &stateProviderName, const std::string &jsonState, const avsCommon::avs::StateRefreshPolicy &refreshPolicy, const avsCommon::sdkInterfaces::ContextRequestToken stateRequestToken=0) override
 
avsCommon::sdkInterfaces::ContextRequestToken getContext (std::shared_ptr< avsCommon::sdkInterfaces::ContextRequesterInterface > contextRequester, const std::string &endpointId, const std::chrono::milliseconds &timeout) override
 
avsCommon::sdkInterfaces::ContextRequestToken getContextWithoutReportableStateProperties (std::shared_ptr< avsCommon::sdkInterfaces::ContextRequesterInterface > contextRequester, const std::string &endpointId, const std::chrono::milliseconds &timeout) override
 
void reportStateChange (const avsCommon::avs::CapabilityTag &capabilityIdentifier, const avsCommon::avs::CapabilityState &capabilityState, avsCommon::sdkInterfaces::AlexaStateChangeCauseType cause) override
 
void provideStateResponse (const avsCommon::avs::CapabilityTag &capabilityIdentifier, const avsCommon::avs::CapabilityState &capabilityState, avsCommon::sdkInterfaces::ContextRequestToken stateRequestToken) override
 
void provideStateUnavailableResponse (const avsCommon::avs::CapabilityTag &capabilityIdentifier, avsCommon::sdkInterfaces::ContextRequestToken stateRequestToken, bool isEndpointUnreachable) override
 
void addContextManagerObserver (std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerObserverInterface > observer) override
 
void removeContextManagerObserver (const std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerObserverInterface > &observer) override
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ContextManagerInterface
virtual ~ContextManagerInterface ()=default
 
virtual void setStateProvider (const avs::CapabilityTag &capabilityIdentifier, std::shared_ptr< StateProviderInterface > stateProvider)=0
 
virtual void addStateProvider (const avsCommon::avs::CapabilityTag &capabilityIdentifier, std::shared_ptr< avsCommon::sdkInterfaces::StateProviderInterface > stateProvider)=0
 
virtual ContextRequestToken getContext (std::shared_ptr< ContextRequesterInterface > contextRequester, const std::string &endpointId="", const std::chrono::milliseconds &timeout=std::chrono::seconds(2))=0
 
virtual ContextRequestToken getContextWithoutReportableStateProperties (std::shared_ptr< ContextRequesterInterface > contextRequester, const std::string &endpointId="", const std::chrono::milliseconds &timeout=std::chrono::seconds(2))=0
 
virtual void addContextManagerObserver (std::shared_ptr< ContextManagerObserverInterface > observer)=0
 
virtual void removeContextManagerObserver (const std::shared_ptr< ContextManagerObserverInterface > &observer)=0
 

Static Public Member Functions

static std::shared_ptr< ContextManagerInterface > createContextManagerInterface (const std::shared_ptr< avsCommon::utils::DeviceInfo > &deviceInfo, const std::shared_ptr< avsCommon::utils::timing::MultiTimer > &multiTimer=std::make_shared< avsCommon::utils::timing::MultiTimer >(), const std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > &metricRecorder=nullptr)
 
static std::shared_ptr< ContextManagercreate (const avsCommon::utils::DeviceInfo &deviceInfo, std::shared_ptr< avsCommon::utils::timing::MultiTimer > multiTimer=std::make_shared< avsCommon::utils::timing::MultiTimer >(), std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder=nullptr)
 

Detailed Description

Class manages the requests for getting context from ContextRequesters and updating the state from StateProviders.

Constructor & Destructor Documentation

◆ ~ContextManager()

alexaClientSDK::contextManager::ContextManager::~ContextManager ( )
override

Destructor.

Member Function Documentation

◆ addContextManagerObserver()

void alexaClientSDK::contextManager::ContextManager::addContextManagerObserver ( std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerObserverInterface observer)
override

◆ addStateProvider()

void alexaClientSDK::contextManager::ContextManager::addStateProvider ( const avsCommon::avs::CapabilityTag capabilityIdentifier,
std::shared_ptr< avsCommon::sdkInterfaces::StateProviderInterface stateProvider 
)
override

◆ create()

static std::shared_ptr<ContextManager> alexaClientSDK::contextManager::ContextManager::create ( const avsCommon::utils::DeviceInfo deviceInfo,
std::shared_ptr< avsCommon::utils::timing::MultiTimer multiTimer = std::make_shared< avsCommon::utils::timing::MultiTimer >(),
std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface metricRecorder = nullptr 
)
static

Create a new ContextManager instance.

Deprecated:
Parameters
deviceInfoStructure used to retrieve the default endpoint id.
multiTimerObject used to schedule request timeout.
metricRecorderThe metric recorder.
Returns
Returns a new ContextManager.

◆ createContextManagerInterface()

static std::shared_ptr<ContextManagerInterface> alexaClientSDK::contextManager::ContextManager::createContextManagerInterface ( const std::shared_ptr< avsCommon::utils::DeviceInfo > &  deviceInfo,
const std::shared_ptr< avsCommon::utils::timing::MultiTimer > &  multiTimer = std::make_shared< avsCommon::utils::timing::MultiTimer >(),
const std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > &  metricRecorder = nullptr 
)
static

Create a new ContextManager instance.

Parameters
deviceInfoStructure used to retrieve the default endpoint id.
multiTimerObject used to schedule request timeout.
metricRecorderThe metric recorder.
Returns
Returns a new ContextManager.

◆ getContext()

avsCommon::sdkInterfaces::ContextRequestToken alexaClientSDK::contextManager::ContextManager::getContext ( std::shared_ptr< avsCommon::sdkInterfaces::ContextRequesterInterface contextRequester,
const std::string &  endpointId,
const std::chrono::milliseconds &  timeout 
)
override

◆ getContextWithoutReportableStateProperties()

avsCommon::sdkInterfaces::ContextRequestToken alexaClientSDK::contextManager::ContextManager::getContextWithoutReportableStateProperties ( std::shared_ptr< avsCommon::sdkInterfaces::ContextRequesterInterface contextRequester,
const std::string &  endpointId,
const std::chrono::milliseconds &  timeout 
)
override

◆ provideStateResponse()

void alexaClientSDK::contextManager::ContextManager::provideStateResponse ( const avsCommon::avs::CapabilityTag capabilityIdentifier,
const avsCommon::avs::CapabilityState capabilityState,
avsCommon::sdkInterfaces::ContextRequestToken  stateRequestToken 
)
overridevirtual

Provides the capability state information as a response to provideState request.

When a provideState request is sent to a StateProviderInterface, the ContextManager will provide a stateRequestToken. The same token needs to be sent on a provideState in response to the provideState. If the token sent in the provideState request does not match the token in the ContextManager, the response will be dropped.

Parameters
capabilityIdentifierIdentifies which capability state is being provided.
capabilityStateThe new state being provided.
stateRequestTokenThe token that was provided in a provideState request.

Implements alexaClientSDK::avsCommon::sdkInterfaces::ContextManagerInterface.

◆ provideStateUnavailableResponse()

void alexaClientSDK::contextManager::ContextManager::provideStateUnavailableResponse ( const avsCommon::avs::CapabilityTag capabilityIdentifier,
avsCommon::sdkInterfaces::ContextRequestToken  stateRequestToken,
bool  isEndpointUnreachable 
)
overridevirtual

Response method used to inform that the capability state is not available.

The same token needs to be sent on a setState in response to the provideState. If the token sent in the setState request does not match the token in the ContextManager, setState will return an error.

Parameters
capabilityIdentifierThe capability message identifier of the StateProviderInterface whose state is not available.
stateRequestTokenThe token that was provided in a provideState request.
isEndpointUnreachableWhether the failure was due to the endpoint being unreachable.

Implements alexaClientSDK::avsCommon::sdkInterfaces::ContextManagerInterface.

◆ removeContextManagerObserver()

void alexaClientSDK::contextManager::ContextManager::removeContextManagerObserver ( const std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerObserverInterface > &  observer)
override

◆ removeStateProvider()

void alexaClientSDK::contextManager::ContextManager::removeStateProvider ( const avsCommon::avs::CapabilityTag capabilityIdentifier)
overridevirtual

Remove the state provider for the given capability with the ContextManager.

Parameters
capabilityIdentifierThe capability message identifier of the StateProviderInterface.

Implements alexaClientSDK::avsCommon::sdkInterfaces::ContextManagerInterface.

◆ reportStateChange()

void alexaClientSDK::contextManager::ContextManager::reportStateChange ( const avsCommon::avs::CapabilityTag capabilityIdentifier,
const avsCommon::avs::CapabilityState capabilityState,
avsCommon::sdkInterfaces::AlexaStateChangeCauseType  cause 
)
overridevirtual

Function used to proactively notify the context manager that the state of a capability has changed.

Parameters
capabilityIdentifierIdentifies which capability has an updated state.
capabilityStateThe new state being reported.
causeThe reason for the state change.

Implements alexaClientSDK::avsCommon::sdkInterfaces::ContextManagerInterface.

◆ setState()

avsCommon::sdkInterfaces::SetStateResult alexaClientSDK::contextManager::ContextManager::setState ( const avsCommon::avs::CapabilityTag capabilityIdentifier,
const std::string &  jsonState,
const avsCommon::avs::StateRefreshPolicy refreshPolicy,
const avsCommon::sdkInterfaces::ContextRequestToken  stateRequestToken = 0 
)
overridevirtual

Sets the state information. The refresh policy indicates to the ContextManager whether on a getContext request the state needs to be updated. If the refreshPolicy is ALWAYS, then the StateProviderInterface needs to be registered with the ContextManager, else setState returns an error.

For the states for which the refresh policy is ALWAYS, the ContextManager requests for provideStates from the StateProviderInterfaces. When a provideState request is sent to a StateProviderInterface, the ContextManager will provide a stateRequestToken. The same token needs to be sent on a setState in response to the provideState. If the token sent in the setState request does not match the token in the ContextManager, setState will return an error.

Deprecated:
Use the provideStateResponse for responding to provideState request and reportStateChange to proactively report to the ContextManager that the state has changed.
Note
Token needs to be set only if the setState is in response to a provideState request. Setting the token to 0 is equivalent to no token.

The jsonState is the json value that is associated with the key "payload".

Parameters
capabilityIdentifierThe capability message identifier of the StateProviderInterface whose state is being updated.
jsonStateThe state of the StateProviderInterface. The StateProviderInterface with a refreshPolicy of SOMETIMES can pass in an empty string to indicate no contexts needs to be sent by the provider.
refreshPolicyThe refresh policy for the state.
stateRequestTokenThe token that was provided in a provideState request. Defaults to 0.
Returns
The status of the setState operation.

Implements alexaClientSDK::avsCommon::sdkInterfaces::ContextManagerInterface.

◆ setStateProvider()

void alexaClientSDK::contextManager::ContextManager::setStateProvider ( const avsCommon::avs::CapabilityTag stateProviderName,
std::shared_ptr< avsCommon::sdkInterfaces::StateProviderInterface stateProvider 
)
override

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