AlexaClientSDK  1.20.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::capabilityAgents::templateRuntime::TemplateRuntime Class Reference

#include <TemplateRuntime.h>

Inheritance diagram for alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime:
Collaboration graph
[legend]

Public Member Functions

virtual ~TemplateRuntime ()=default
 
void addObserver (std::shared_ptr< avsCommon::sdkInterfaces::TemplateRuntimeObserverInterface > observer)
 
void removeObserver (std::shared_ptr< avsCommon::sdkInterfaces::TemplateRuntimeObserverInterface > observer)
 
void displayCardCleared ()
 
void addRenderPlayerInfoCardsProvider (std::shared_ptr< avsCommon::sdkInterfaces::RenderPlayerInfoCardsProviderInterface > cardsProvider)
 
CapabilityAgent/DirectiveHandlerInterface Functions
void handleDirectiveImmediately (std::shared_ptr< avsCommon::avs::AVSDirective > directive) override
 
void preHandleDirective (std::shared_ptr< DirectiveInfo > info) override
 
void handleDirective (std::shared_ptr< DirectiveInfo > info) override
 
void cancelDirective (std::shared_ptr< DirectiveInfo > info) override
 
avsCommon::avs::DirectiveHandlerConfiguration getConfiguration () const override
 
ChannelObserverInterface Functions
void onFocusChanged (avsCommon::avs::FocusState newFocus, avsCommon::avs::MixingBehavior behavior) override
 
RenderPlayerInfoCardsObserverInterface Functions
void onRenderPlayerCardsInfoChanged (avsCommon::avs::PlayerActivity state, const Context &context) override
 
DialogUXStateObserverInterface Functions
void onDialogUXStateChanged (avsCommon::sdkInterfaces::DialogUXStateObserverInterface::DialogUXState newState) override
 
CapabilityConfigurationInterface Functions
std::unordered_set< std::shared_ptr< avsCommon::avs::CapabilityConfiguration > > getCapabilityConfigurations () override
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::avs::CapabilityAgent
virtual ~CapabilityAgent ()=default
 
void preHandleDirective (std::shared_ptr< AVSDirective > directive, std::unique_ptr< sdkInterfaces::DirectiveHandlerResultInterface > result) override final
 
bool handleDirective (const std::string &messageId) override final
 
void cancelDirective (const std::string &messageId) override final
 
void onDeregistered () override
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::DirectiveHandlerInterface
virtual ~DirectiveHandlerInterface ()=default
 
virtual void handleDirectiveImmediately (std::shared_ptr< avsCommon::avs::AVSDirective > directive)=0
 
virtual void preHandleDirective (std::shared_ptr< avsCommon::avs::AVSDirective > directive, std::unique_ptr< DirectiveHandlerResultInterface > result)=0
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ChannelObserverInterface
virtual ~ChannelObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::StateProviderInterface
virtual ~StateProviderInterface ()=default
 
virtual void provideState (const avs::NamespaceAndName &stateProviderName, const ContextRequestToken stateRequestToken)
 
virtual void provideState (const avs::CapabilityTag &stateProviderName, const ContextRequestToken stateRequestToken)
 
virtual bool canStateBeRetrieved ()
 
virtual bool hasReportableStateProperties ()
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ContextRequesterInterface
virtual ~ContextRequesterInterface ()=default
 
virtual void onContextAvailable (const std::string &jsonContext)
 
virtual void onContextAvailable (const endpoints::EndpointIdentifier &endpointId, const avs::AVSContext &endpointContext, ContextRequestToken requestToken)
 
virtual void onContextFailure (const ContextRequestError error)
 
virtual void onContextFailure (const ContextRequestError error, ContextRequestToken token)
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::utils::RequiresShutdown
 RequiresShutdown (const std::string &name)
 
virtual ~RequiresShutdown ()
 Destructor. More...
 
const std::string & name () const
 
void shutdown ()
 
bool isShutdown () const
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::RenderPlayerInfoCardsObserverInterface
virtual ~RenderPlayerInfoCardsObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::CapabilityConfigurationInterface
virtual ~CapabilityConfigurationInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::DialogUXStateObserverInterface
virtual ~DialogUXStateObserverInterface ()=default
 

Static Public Member Functions

static std::shared_ptr< TemplateRuntimecreate (const std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::RenderPlayerInfoCardsProviderInterface >> &renderPlayerInfoCardsInterfaces, std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface > focusManager, std::shared_ptr< avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface > exceptionSender)
 
- Static Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::DialogUXStateObserverInterface
static std::string stateToString (DialogUXState state)
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::DialogUXStateObserverInterface
enum  DialogUXState {
  DialogUXState::IDLE, DialogUXState::LISTENING, DialogUXState::EXPECTING, DialogUXState::THINKING,
  DialogUXState::SPEAKING, DialogUXState::FINISHED
}
 The different dialog specific AVS UX states. More...
 
- Protected Member Functions inherited from alexaClientSDK::avsCommon::avs::CapabilityAgent
 CapabilityAgent (const std::string &nameSpace, std::shared_ptr< sdkInterfaces::ExceptionEncounteredSenderInterface > exceptionEncounteredSender)
 
virtual std::shared_ptr< DirectiveInfocreateDirectiveInfo (std::shared_ptr< AVSDirective > directive, std::unique_ptr< sdkInterfaces::DirectiveHandlerResultInterface > result)
 
void removeDirective (const std::string &messageId)
 
void sendExceptionEncounteredAndReportFailed (std::shared_ptr< DirectiveInfo > info, const std::string &message, avsCommon::avs::ExceptionErrorType type=avsCommon::avs::ExceptionErrorType::INTERNAL_ERROR)
 
const std::pair< std::string, std::string > buildJsonEventString (const std::string &eventName, const std::string &dialogRequestIdString="", const std::string &payload="{}", const std::string &context="") const
 
- Protected Attributes inherited from alexaClientSDK::avsCommon::avs::CapabilityAgent
const std::string m_namespace
 The namespace of the capability agent. More...
 
std::shared_ptr< sdkInterfaces::ExceptionEncounteredSenderInterfacem_exceptionEncounteredSender
 Object to use to send exceptionEncountered messages. More...
 

Detailed Description

This class implements a CapabilityAgent that handles the AVS TemplateRuntime API. The TemplateRuntime CA is responsible for handling the directives with the TemplateRuntime namespace. Due to the fact that the RenderPlayerInfo directives are closely related to the AudioPlayer, the TemplateRuntime CA is an observer to the AudioPlayer and will be synchronizing the RenderPlayerInfo directives with the corresponding AudioItem being handled in the AudioPlayer.

The TemplateRuntime CA is also an observer to the DialogUXState to determine the end of a interaction so that it would know when to clear a RenderTemplate displayCard.

The clients who are interested in any TemplateRuntime directives can subscribe themselves as an observer, and the clients will be notified via the TemplateRuntimeObserverInterface.

Constructor & Destructor Documentation

◆ ~TemplateRuntime()

virtual alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::~TemplateRuntime ( )
virtualdefault

Destructor.

Member Function Documentation

◆ addObserver()

void alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::addObserver ( std::shared_ptr< avsCommon::sdkInterfaces::TemplateRuntimeObserverInterface observer)

This function adds an observer to TemplateRuntime so that it will get notified for renderTemplateCard or renderPlayerInfoCard.

Parameters
observerThe TemplateRuntimeObserverInterface

◆ addRenderPlayerInfoCardsProvider()

void alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::addRenderPlayerInfoCardsProvider ( std::shared_ptr< avsCommon::sdkInterfaces::RenderPlayerInfoCardsProviderInterface cardsProvider)

This function adds a for a client to subscribe TemplateRuntime as an observer of changes for RenderPlayerInfoCards.

Parameters
cardsProviderThe RenderPlayerInfoCardsProviderInterface

◆ cancelDirective()

void alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::cancelDirective ( std::shared_ptr< DirectiveInfo info)
overridevirtual

Cancel an ongoing preHandleDirective() or handleDirective() operation for the AVSDirective in . Once this has been called the CapabilityAgent should not expect to receive further calls regarding this directive.

Note
The implementation of this method MUST be thread-safe.
The implementation of this method MUST return quickly. Failure to do so blocks the processing of subsequent AVSDirectives.
Parameters
infoThe DirectiveInfo instance for the AVSDirective to process.

Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.

◆ create()

std::shared_ptr< TemplateRuntime > alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::create ( const std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::RenderPlayerInfoCardsProviderInterface >> &  renderPlayerInfoCardsInterfaces,
std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface focusManager,
std::shared_ptr< avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface exceptionSender 
)
static

Create an instance of TemplateRuntime.

Parameters
renderPlayerInfoCardsInterfacesA set of objects to use for subscribing TemplateRuntime as an observer of changes for RenderPlayerInfoCards.
exceptionSenderThe object to use for sending AVS Exception messages.
Returns
nullptr if the inputs are not defined, else a new instance of TemplateRuntime.

◆ displayCardCleared()

void alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::displayCardCleared ( )

This function notifies the TemplateRuntime that a displayCard has been cleared from the screen. Upon getting this notification, the TemplateRuntime will release the visual channel.

◆ getCapabilityConfigurations()

std::unordered_set< std::shared_ptr< avsCommon::avs::CapabilityConfiguration > > alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::getCapabilityConfigurations ( )
overridevirtual

Returns the configurations of the capability interfaces being implemented.

Returns
A set of CapabilityConfigurations

Implements alexaClientSDK::avsCommon::sdkInterfaces::CapabilityConfigurationInterface.

◆ getConfiguration()

DirectiveHandlerConfiguration alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::getConfiguration ( ) const
overridevirtual

Returns the configuration of the directive handler.

The configuration consists of multiple directive routing rules and their respective blocking policy. The directives will be matched from the most specific rule (with all fields defined) to the least specific rule (which only matches the directive endpointId).

Returns
The avs::DirectiveHandlerConfiguration of the handler.

Implements alexaClientSDK::avsCommon::sdkInterfaces::DirectiveHandlerInterface.

◆ handleDirective()

void alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::handleDirective ( std::shared_ptr< DirectiveInfo info)
overridevirtual

Handle the action specified by the AVSDirective in info. The handling of subsequent directives with the same DialogRequestId may be blocked until the DirectiveHandler calls the setSucceeded() method of the DirectiveHandlingResult present in info. If handling of this directive fails setFailed() should be called to indicate a failure.

Note
The implementation of this method MUST be thread-safe.
The implementation of this method MUST return quickly. Failure to do so blocks the processing of subsequent AVSDirectives.
Parameters
infoThe DirectiveInfo instance for the AVSDirective to process.

Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.

◆ handleDirectiveImmediately()

void alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::handleDirectiveImmediately ( std::shared_ptr< avsCommon::avs::AVSDirective directive)
override

◆ onDialogUXStateChanged()

void alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::onDialogUXStateChanged ( avsCommon::sdkInterfaces::DialogUXStateObserverInterface::DialogUXState  newState)
overridevirtual

This function is called whenever the AVS UX dialog state of the system changes. This function will block processing of other state changes, so any implementation of this should return quickly.

Parameters
newStateThe new dialog specific AVS UX state.

Implements alexaClientSDK::avsCommon::sdkInterfaces::DialogUXStateObserverInterface.

◆ onFocusChanged()

void alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::onFocusChanged ( avsCommon::avs::FocusState  newFocus,
avsCommon::avs::MixingBehavior  behavior 
)
overridevirtual

Used to notify the observer of the Channel of focus changes. Once called, the client should make a user observable change only and return immediately. Any additional work that needs to be done should be done on a separate thread or after returning. "User observable change" here refers to events that the end user of the product can visibly see or hear. For example, Alexa speech or music playing would be examples of user observable changes. Other work, such as database storing, logging, or communicating via network should be done on a different thread. Not doing so could result in delays for other clients trying to access the Channel.

Parameters
newFocusThe new Focus of the channel.
behaviorThe mixingBehavior for the ChannelObserver to take as per the interrupt model
Note
when newFocus is FocusState::FOREGROUND, the MixingBehavior shall be guaranteed to be PRIMARY when newFocus is FocusState::NONE, the MixingBehavior shall be guaranteed to be MUST_STOP

Reimplemented from alexaClientSDK::avsCommon::avs::CapabilityAgent.

◆ onRenderPlayerCardsInfoChanged()

void alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::onRenderPlayerCardsInfoChanged ( avsCommon::avs::PlayerActivity  state,
const Context context 
)
overridevirtual

Used to notify the observer when there is a change in PlayerActivity or Context.

Parameters
stateThe PlayerActivity of the Player.
contextThe Context of the Player.

Implements alexaClientSDK::avsCommon::sdkInterfaces::RenderPlayerInfoCardsObserverInterface.

◆ preHandleDirective()

void alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::preHandleDirective ( std::shared_ptr< DirectiveInfo info)
overridevirtual

Notification that a directive has arrived. This notification gives the DirectiveHandler a chance to prepare for handling of an AVSDirective. If an error occurs during the pre-Handling phase and that error should cancel the handling of subsequent AVSDirectives with the same DialogRequestId, the DirectiveHandler should call the setFailed method on the result instance passed in to this call.

Note
The implementation of this method MUST be thread-safe.
The implementation of this method MUST return quickly. Failure to do so blocks the processing of subsequent AVSDirectives.
Parameters
infoThe DirectiveInfo instance for the AVSDirective to process.

Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.

◆ removeObserver()

void alexaClientSDK::capabilityAgents::templateRuntime::TemplateRuntime::removeObserver ( std::shared_ptr< avsCommon::sdkInterfaces::TemplateRuntimeObserverInterface observer)

This function removes an observer from TemplateRuntime so that it will no longer be notified of renderTemplateCard or renderPlayerInfoCard callbacks.

Parameters
observerThe TemplateRuntimeObserverInterface

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

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