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::capabilityAgents::powerController::PowerControllerCapabilityAgent Class Reference

#include <PowerControllerCapabilityAgent.h>

Inheritance diagram for alexaClientSDK::capabilityAgents::powerController::PowerControllerCapabilityAgent:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::capabilityAgents::powerController::PowerControllerCapabilityAgent:
Collaboration graph
[legend]

Public Types

using EndpointIdentifier = avsCommon::sdkInterfaces::endpoints::EndpointIdentifier
 Alias to improve readability. More...
 
using PowerState = avsCommon::sdkInterfaces::powerController::PowerControllerInterface::PowerState
 

Public Member Functions

avsCommon::avs::CapabilityConfiguration getCapabilityConfiguration ()
 
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
 
StateProviderInterface Functions
void provideState (const avsCommon::avs::CapabilityTag &stateProviderName, const avsCommon::sdkInterfaces::ContextRequestToken contextRequestToken) override
 
bool canStateBeRetrieved () override
 
bool hasReportableStateProperties () override
 
PowerControllerObserverInterface Function
void onPowerStateChanged (const PowerState &powerState, avsCommon::sdkInterfaces::AlexaStateChangeCauseType cause) 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
 
void onFocusChanged (FocusState newFocus, MixingBehavior behavior) override
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::DirectiveHandlerInterface
virtual ~DirectiveHandlerInterface ()=default
 
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 bool shouldQueryState ()
 
- 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::sdkInterfaces::powerController::PowerControllerObserverInterface
virtual ~PowerControllerObserverInterface ()=default
 
- 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
 

Static Public Member Functions

static std::shared_ptr< PowerControllerCapabilityAgentcreate (const EndpointIdentifier &endpointId, std::shared_ptr< avsCommon::sdkInterfaces::powerController::PowerControllerInterface > powerController, std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface > contextManager, std::shared_ptr< avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface > responseSender, std::shared_ptr< avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface > exceptionSender, bool isProactivelyReported, bool isRetrievable)
 

Additional Inherited Members

- 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

The PowerControllerCapabilityAgent is responsible for handling Alexa.PowerController directives and calls the PowerControllerInterface APIs.

This class implements a CapabilityAgent that handles the Alexa.PowerContoller Interface.

Member Typedef Documentation

◆ EndpointIdentifier

Alias to improve readability.

◆ PowerState

Member Function Documentation

◆ cancelDirective()

void alexaClientSDK::capabilityAgents::powerController::PowerControllerCapabilityAgent::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.

◆ canStateBeRetrieved()

bool alexaClientSDK::capabilityAgents::powerController::PowerControllerCapabilityAgent::canStateBeRetrieved ( )
overridevirtual

Returns whether the provider can be queried for its state / properties. If not, the provider is omitted from the context altogether. ContextManager will not query or report its state.

Returns
Whether this provider can be queried about its state when a new context request arrives.
Note
In future versions, this method will be made pure virtual.

Reimplemented from alexaClientSDK::avsCommon::sdkInterfaces::StateProviderInterface.

◆ create()

static std::shared_ptr<PowerControllerCapabilityAgent> alexaClientSDK::capabilityAgents::powerController::PowerControllerCapabilityAgent::create ( const EndpointIdentifier endpointId,
std::shared_ptr< avsCommon::sdkInterfaces::powerController::PowerControllerInterface powerController,
std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface contextManager,
std::shared_ptr< avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface responseSender,
std::shared_ptr< avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface exceptionSender,
bool  isProactivelyReported,
bool  isRetrievable 
)
static

Create an instance of PowerControllerCapabilityAgent.

Parameters
endpointIdA endpoint to which this capability is associated.
powerControllerAn interface that this object will use to perform the power controller operations.
contextManagerAn interface to which this object will send property state updates.
responseSenderAn interface that this object will use to send the reponse to AVS.
exceptionSenderAn interface to report exceptions to AVS.
isProactivelyReportedWhether the power state property change is proactively reported to Alexa in a change report.
isRetrievableWhether the power state property can be retrieved when Alexa sends a state report request to the endpoint.
Returns
nullptr if the inputs are invalid, else a new instance of PowerControllerCapabilityAgent.

◆ getCapabilityConfiguration()

avsCommon::avs::CapabilityConfiguration alexaClientSDK::capabilityAgents::powerController::PowerControllerCapabilityAgent::getCapabilityConfiguration ( )

Get the capability configuration for this agent.

Returns
The capability configuration.

◆ getConfiguration()

avsCommon::avs::DirectiveHandlerConfiguration alexaClientSDK::capabilityAgents::powerController::PowerControllerCapabilityAgent::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::powerController::PowerControllerCapabilityAgent::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::powerController::PowerControllerCapabilityAgent::handleDirectiveImmediately ( std::shared_ptr< avsCommon::avs::AVSDirective directive)
overridevirtual

Handle the action specified AVSDirective. Once this has been called the DirectiveHandler 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.
If this operation fails, an ExceptionEncountered message should be sent to AVS.
Parameters
directiveThe directive to handle.

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

◆ hasReportableStateProperties()

bool alexaClientSDK::capabilityAgents::powerController::PowerControllerCapabilityAgent::hasReportableStateProperties ( )
overridevirtual

Returns whether the provider has Reportable State Properties.

See also
https://developer.amazon.com/en-US/docs/alexa/alexa-voice-service/reportable-state-properties.html
Returns
Whether this provider has reportable state properties.

Reimplemented from alexaClientSDK::avsCommon::sdkInterfaces::StateProviderInterface.

◆ onPowerStateChanged()

void alexaClientSDK::capabilityAgents::powerController::PowerControllerCapabilityAgent::onPowerStateChanged ( const PowerState powerState,
avsCommon::sdkInterfaces::AlexaStateChangeCauseType  cause 
)
overridevirtual

Notifies the change in the power state property of the endpoint.

Parameters
powerStateThe power state specified using PowerState.
causeThe cause for this change specified using AlexaStateChangeCauseType.

Implements alexaClientSDK::avsCommon::sdkInterfaces::powerController::PowerControllerObserverInterface.

◆ preHandleDirective()

void alexaClientSDK::capabilityAgents::powerController::PowerControllerCapabilityAgent::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.

◆ provideState()

void alexaClientSDK::capabilityAgents::powerController::PowerControllerCapabilityAgent::provideState ( const avsCommon::avs::CapabilityTag stateProviderName,
const avsCommon::sdkInterfaces::ContextRequestToken  stateRequestToken 
)
overridevirtual

A request to a StateProvider to provide the state. The StateProvider should perform minimum processing and return quickly, otherwise it will block the processing of updating the states of other StateProviders. The ContextManager specifies a token which it uses to track the getContext request associated with this provideState request. The stateProviderInterface must use the same token when it updates its state via the setState call.

: The setState method MUST be called from a different thread from where the provideState method is being called from.

Parameters
stateProviderIdentifierThe identifier of the state provider.
stateRequestTokenThe token to use in the setState call.
Note
In future versions, this method will be made pure virtual.

Reimplemented from alexaClientSDK::avsCommon::sdkInterfaces::StateProviderInterface.


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