AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Types | Public Member Functions | List of all members
alexaClientSDK::avsCommon::sdkInterfaces::toggleController::ToggleControllerInterface Class Referenceabstract

#include <ToggleControllerInterface.h>

Inheritance diagram for alexaClientSDK::avsCommon::sdkInterfaces::toggleController::ToggleControllerInterface:
Inheritance graph
[legend]

Public Types

using ToggleState = avsCommon::sdkInterfaces::toggleController::ToggleControllerObserverInterface::ToggleState
 Alias to improve readability. More...
 

Public Member Functions

virtual ~ToggleControllerInterface ()=default
 
virtual std::pair< avsCommon::avs::AlexaResponseType, std::string > setToggleState (bool state, AlexaStateChangeCauseType cause)=0
 
virtual std::pair< avsCommon::avs::AlexaResponseType, utils::Optional< ToggleState > > getToggleState ()=0
 
virtual bool addObserver (std::shared_ptr< ToggleControllerObserverInterface > observer)=0
 
virtual void removeObserver (const std::shared_ptr< ToggleControllerObserverInterface > &observer)=0
 

Detailed Description

The ToggleControllerInterface carries out toggle actions on an instance of an endpoint, such as turning it 'ON or 'OFF'.

An implementation of the ToggleControllerInterface controls the instance's toggle state and may allow its methods to be called by multiple callers; for example the Alexa Capability Agent or the application’s GUI.

Note
Implementations of this interface must be thread-safe.

Member Typedef Documentation

◆ ToggleState

Alias to improve readability.

Constructor & Destructor Documentation

◆ ~ToggleControllerInterface()

virtual alexaClientSDK::avsCommon::sdkInterfaces::toggleController::ToggleControllerInterface::~ToggleControllerInterface ( )
virtualdefault

Virtual destructor to assure proper cleanup of derived types.

Member Function Documentation

◆ addObserver()

virtual bool alexaClientSDK::avsCommon::sdkInterfaces::toggleController::ToggleControllerInterface::addObserver ( std::shared_ptr< ToggleControllerObserverInterface observer)
pure virtual

Adds a ToggleControllerObserverInterface observer.

Note
If ToggleControllerInterface implementation has configured its instance's property as proactively reported, then it is required to notify observers of ToggleControllerObserverInterface for any change in its property state. This includes notifying the value when the device starts, if it is different from the last reported value.
Parameters
observerThe pointer to the ToggleControllerObserverInterface.
Returns
true if the object supports observer notification and observer was successfully added; otherwise, return false

◆ getToggleState()

virtual std::pair<avsCommon::avs::AlexaResponseType, utils::Optional<ToggleState> > alexaClientSDK::avsCommon::sdkInterfaces::toggleController::ToggleControllerInterface::getToggleState ( )
pure virtual

Gets the current toggle state of an instance.

Returns
On successful, the instance to return a pair with AlexaResponseType::SUCCESS and ToggleState otherwise returns a pair with the appropriate reason from AlexaResponseType and a empty ToggleState.

Implemented in alexaClientSDK::sampleApplications::common::PeripheralEndpointToggleControllerHandler, and alexaClientSDK::sampleApplications::common::DefaultEndpointToggleControllerHandler.

◆ removeObserver()

virtual void alexaClientSDK::avsCommon::sdkInterfaces::toggleController::ToggleControllerInterface::removeObserver ( const std::shared_ptr< ToggleControllerObserverInterface > &  observer)
pure virtual

Removes a observer of ToggleControllerObserverInterface.

Parameters
observerThe pointer to the ToggleControllerObserverInterface.

◆ setToggleState()

virtual std::pair<avsCommon::avs::AlexaResponseType, std::string> alexaClientSDK::avsCommon::sdkInterfaces::toggleController::ToggleControllerInterface::setToggleState ( bool  state,
AlexaStateChangeCauseType  cause 
)
pure virtual

Set the toggle state of an instance.

Parameters
stateThe desired toggle state of the instance true indicates 'ON' and false as 'OFF'
causeThe cause type for this action represented using AlexaStateChangeCauseType.
Returns
A pair of AlexaResponseType and string. For the successful operation, the controller should return a pair with AlexaResponseType::SUCCESS with an empty string, otherwise returns a pair with the appropriate reason from AlexaResponseType and a description of the error.

Implemented in alexaClientSDK::sampleApplications::common::PeripheralEndpointToggleControllerHandler, and alexaClientSDK::sampleApplications::common::DefaultEndpointToggleControllerHandler.


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