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

#include <Alert.h>

Inheritance diagram for alexaClientSDK::acsdkAlerts::Alert:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::acsdkAlerts::Alert:
Collaboration graph
[legend]

Classes

struct  Asset
 
struct  AssetConfiguration
 
struct  ContextInfo
 
struct  DynamicData
 
struct  StaticData
 

Public Types

enum  State {
  State::UNSET, State::SET, State::READY, State::ACTIVATING,
  State::ACTIVE, State::SNOOZING, State::SNOOZED, State::STOPPING,
  State::STOPPED, State::COMPLETED
}
 
enum  StopReason {
  StopReason::UNSET, StopReason::AVS_STOP, StopReason::LOCAL_STOP, StopReason::SHUTDOWN,
  StopReason::LOG_OUT
}
 
enum  ParseFromJsonStatus { ParseFromJsonStatus::OK, ParseFromJsonStatus::MISSING_REQUIRED_PROPERTY, ParseFromJsonStatus::INVALID_VALUE }
 
- Public Types inherited from alexaClientSDK::acsdkAlerts::renderer::RendererObserverInterface
enum  State {
  State::UNSET, State::STARTED, State::STOPPED, State::COMPLETED,
  State::ERROR
}
 

Public Member Functions

 Alert (std::function< std::pair< std::unique_ptr< std::istream >, const avsCommon::utils::MediaType >()> defaultAudioFactory, std::function< std::pair< std::unique_ptr< std::istream >, const avsCommon::utils::MediaType >()> shortAudioFactory, std::shared_ptr< settings::DeviceSettingsManager > settingsManager)
 
virtual std::string getTypeName () const =0
 
std::function< std::pair< std::unique_ptr< std::istream >, const avsCommon::utils::MediaType >)> getDefaultAudioFactory () const
 
std::function< std::pair< std::unique_ptr< std::istream >, const avsCommon::utils::MediaType >)> getShortAudioFactory () const
 
Alert::ContextInfo getContextInfo () const
 
acsdkAlertsInterfaces::AlertObserverInterface::AlertInfo createAlertInfo (acsdkAlertsInterfaces::AlertObserverInterface::State state, const std::string &reason="") const
 
void onRendererStateChange (renderer::RendererObserverInterface::State state, const std::string &reason) override
 
ParseFromJsonStatus parseFromJson (const rapidjson::Value &payload, std::string *errorMessage)
 
void setRenderer (std::shared_ptr< renderer::RendererInterface > renderer)
 
void setObserver (acsdkAlertsInterfaces::AlertObserverInterface *observer)
 
void activate ()
 
void deactivate (StopReason reason)
 
bool updateScheduledTime (const std::string &newScheduledTime)
 
bool snooze (const std::string &updatedScheduledTime)
 
void setFocusState (avsCommon::avs::FocusState focusState, avsCommon::avs::MixingBehavior behavior)
 
bool setStateActive ()
 
void reset ()
 
std::string getToken () const
 
int64_t getScheduledTime_Unix () const
 
std::string getScheduledTime_ISO_8601 () const
 
std::chrono::system_clock::time_point getScheduledTime_Utc_TimePoint () const
 
acsdkAlertsInterfaces::AlertObserverInterface::Type getType () const
 
avsCommon::utils::Optional< acsdkAlertsInterfaces::AlertObserverInterface::OriginalTimegetOriginalTime () const
 
avsCommon::utils::Optional< std::string > getLabel () const
 
Alert::State getState () const
 
StopReason getStopReason () const
 
void getAlertData (StaticData *staticData, DynamicData *dynamicData) const
 
bool setAlertData (StaticData *staticData, DynamicData *dynamicData)
 
int getId () const
 
bool isPastDue (int64_t currentUnixTime, std::chrono::seconds timeLimit)
 
int getLoopCount () const
 
std::chrono::milliseconds getLoopPause () const
 
std::string getBackgroundAssetId () const
 
AssetConfiguration getAssetConfiguration () const
 
bool setAssetConfiguration (const AssetConfiguration &assetConfiguration)
 
void printDiagnostic ()
 
- Public Member Functions inherited from alexaClientSDK::acsdkAlerts::renderer::RendererObserverInterface
virtual ~RendererObserverInterface ()=default
 

Static Public Member Functions

static avsCommon::utils::Optional< acsdkAlertsInterfaces::AlertObserverInterface::OriginalTimevalidateOriginalTimeString (const std::string &originalTimeStr)
 
static avsCommon::utils::Optional< std::string > validateLabelString (const std::string &label)
 
static std::string stateToString (Alert::State state)
 
static std::string stopReasonToString (Alert::StopReason stopReason)
 
static std::string parseFromJsonStatusToString (Alert::ParseFromJsonStatus parseFromJsonStatus)
 
- Static Public Member Functions inherited from alexaClientSDK::acsdkAlerts::renderer::RendererObserverInterface
static std::string stateToString (State state)
 

Detailed Description

A class to manage the concept of an AVS Alert.

This class is decoupled from the Renderer, which is set by its owning object. This class encpasulates and translates all renderer states, so that an owning object need only know if the alert object is 'active', for example, rather than also query rendering state. An alert object in an 'active' state implies the user perceivable rendering is occurring (whether that means audible, visual, or other perceivable stimulus).

Member Enumeration Documentation

◆ ParseFromJsonStatus

An enum class which captures the various JSON parse states which may occur.

Enumerator
OK 

Parsing was successful.

MISSING_REQUIRED_PROPERTY 

A required property was missing from the JSON.

INVALID_VALUE 

An invalid value was detected while parsing the JSON.

◆ State

An enum class which captures the state an alert object can be in.

Enumerator
UNSET 

An uninitialized value.

SET 

The alert is set and is expected to become active at some point in the future.

READY 

The alert is ready to activate, and is waiting for the channel to be acquired.

ACTIVATING 

Rendering has been initiated, but is not yet perceivable from a user's point of view.

ACTIVE 

Rendering has been initiated, and is perceivable from a user's point of view.

SNOOZING 

The alert is active, but has been asked to snooze.

SNOOZED 

The alert is active, but is now stopping due to user interaction.

STOPPING 

The renderer is now stopped due to a snooze request.

STOPPED 

The alert has stopped in response to user interaction.

COMPLETED 

The alert has completed on its own, without user interaction.

◆ StopReason

An enum class which captures the reasons an alert may have stopped.

Enumerator
UNSET 

An uninitalized value.

AVS_STOP 

The alert has been stopped due to a Directive from AVS.

LOCAL_STOP 

The alert has been stopped due to a local user action.

SHUTDOWN 

The alert is being stopped due to an SDK shutdown operation.

LOG_OUT 

Logout customer logged out or deregistered.

Constructor & Destructor Documentation

◆ Alert()

alexaClientSDK::acsdkAlerts::Alert::Alert ( std::function< std::pair< std::unique_ptr< std::istream >, const avsCommon::utils::MediaType >()>  defaultAudioFactory,
std::function< std::pair< std::unique_ptr< std::istream >, const avsCommon::utils::MediaType >()>  shortAudioFactory,
std::shared_ptr< settings::DeviceSettingsManager settingsManager 
)

Constructor.

Member Function Documentation

◆ activate()

void alexaClientSDK::acsdkAlerts::Alert::activate ( )

Activate the alert.

◆ createAlertInfo()

acsdkAlertsInterfaces::AlertObserverInterface::AlertInfo alexaClientSDK::acsdkAlerts::Alert::createAlertInfo ( acsdkAlertsInterfaces::AlertObserverInterface::State  state,
const std::string &  reason = "" 
) const

Create AlertInfo object for this alert with the specified state and reason.

Parameters
statestate of the alertInfo, which is of different type from Alert.state
reasonreason for alert state change
Returns
AlertInfo object for the alert with the specified state

◆ deactivate()

void alexaClientSDK::acsdkAlerts::Alert::deactivate ( StopReason  reason)

Deactivate the alert.

Parameters
reasonThe reason why the alert is being stopped.

◆ getAlertData()

void alexaClientSDK::acsdkAlerts::Alert::getAlertData ( StaticData staticData,
DynamicData dynamicData 
) const

Gets the data associated with this alert.

Parameters
dynamicDataA pointer to a DynamicData struct. If this is not nullptr, it will be populated with this alert's DynamicData.
staticDataA pointer to a StaticData struct. If this is not nullptr, it will be populated with this alert's StaticData.

◆ getAssetConfiguration()

AssetConfiguration alexaClientSDK::acsdkAlerts::Alert::getAssetConfiguration ( ) const

Returns the utility structure, containing the Context data associated with this alert.

Returns
The utility structure, containing the Context data associated with this alert.

◆ getBackgroundAssetId()

std::string alexaClientSDK::acsdkAlerts::Alert::getBackgroundAssetId ( ) const

Get the background custom asset id, as specified by AVS.

Returns
The background custom asset id, as specified by AVS.

◆ getContextInfo()

Alert::ContextInfo alexaClientSDK::acsdkAlerts::Alert::getContextInfo ( ) const

Returns the Context data which may be shared with AVS.

Returns
The Context data which may be shared with AVS.

◆ getDefaultAudioFactory()

std::function<std::pair<std::unique_ptr<std::istream>, const avsCommon::utils::MediaType>)> alexaClientSDK::acsdkAlerts::Alert::getDefaultAudioFactory ( ) const

A function that gets a factory to create a stream to the default audio for an alert.

Returns
A factory function that generates a default audio stream.

◆ getId()

int alexaClientSDK::acsdkAlerts::Alert::getId ( ) const

Returns the database id for the alert, if one is set.

Returns
The database id for the alert, if one is set.

◆ getLabel()

avsCommon::utils::Optional<std::string> alexaClientSDK::acsdkAlerts::Alert::getLabel ( ) const

Gets the optional with label string.

Returns
An optional with label string if label is valid for the alert; an empty optional otherwise.

◆ getLoopCount()

int alexaClientSDK::acsdkAlerts::Alert::getLoopCount ( ) const

Get the loop count of custom assets.

Returns
The loop count of custom assets.

◆ getLoopPause()

std::chrono::milliseconds alexaClientSDK::acsdkAlerts::Alert::getLoopPause ( ) const

Get the time, in milliseconds, to be paused between custom-asset loop rendering.

Returns
The time, in milliseconds, to be paused between custom-asset loop rendering.

◆ getOriginalTime()

avsCommon::utils::Optional<acsdkAlertsInterfaces::AlertObserverInterface::OriginalTime> alexaClientSDK::acsdkAlerts::Alert::getOriginalTime ( ) const

Gets the optional with OriginalTime.

Returns
An optional with OriginalTime if originalTime is valid for the alert; an empty optional otherwise.

◆ getScheduledTime_ISO_8601()

std::string alexaClientSDK::acsdkAlerts::Alert::getScheduledTime_ISO_8601 ( ) const

Gets the time the alert should occur, in ISO-8601 format.

Returns
The time the alert should occur, in ISO-8601 format.

◆ getScheduledTime_Unix()

int64_t alexaClientSDK::acsdkAlerts::Alert::getScheduledTime_Unix ( ) const

Gets the time the alert should occur, in Unix epoch time.

Returns
The time the alert should occur, in Unix epoch time.

◆ getScheduledTime_Utc_TimePoint()

std::chrono::system_clock::time_point alexaClientSDK::acsdkAlerts::Alert::getScheduledTime_Utc_TimePoint ( ) const

Gets the UTC time for when the alert should occur.

Returns
The UTC time for when the alert should occur.

◆ getShortAudioFactory()

std::function<std::pair<std::unique_ptr<std::istream>, const avsCommon::utils::MediaType>)> alexaClientSDK::acsdkAlerts::Alert::getShortAudioFactory ( ) const

A function that gets a factory to create a stream to the short audio for an alert.

Returns
A factory function that generates a short audio stream.

◆ getState()

Alert::State alexaClientSDK::acsdkAlerts::Alert::getState ( ) const

Returns the state of the alert.

Returns
The state of the alert.

◆ getStopReason()

StopReason alexaClientSDK::acsdkAlerts::Alert::getStopReason ( ) const

Returns the reason the alert stopped.

Returns
The reason the alert stopped.

◆ getToken()

std::string alexaClientSDK::acsdkAlerts::Alert::getToken ( ) const

Returns the AVS token for the alert.

Returns
The AVS token for the alert.

◆ getType()

acsdkAlertsInterfaces::AlertObserverInterface::Type alexaClientSDK::acsdkAlerts::Alert::getType ( ) const

Gets the Type of the alert.

Returns
The type of the alert.

◆ getTypeName()

virtual std::string alexaClientSDK::acsdkAlerts::Alert::getTypeName ( ) const
pure virtual

◆ isPastDue()

bool alexaClientSDK::acsdkAlerts::Alert::isPastDue ( int64_t  currentUnixTime,
std::chrono::seconds  timeLimit 
)

Queries whether the alert is past-due.

Parameters
currentUnixTimeThe time with which to compare the activation time of the alert.
timeLimitSecondsHow long an alert may be late, and still considered valid.
Returns
If the alert is considered past-due.

◆ onRendererStateChange()

void alexaClientSDK::acsdkAlerts::Alert::onRendererStateChange ( renderer::RendererObserverInterface::State  state,
const std::string &  reason 
)
overridevirtual

A callback function to communicate a change in render state.

Parameters
stateThe current state of the renderer.
reasonThe reason for the change of state, if required. This is typically set on an error.

Implements alexaClientSDK::acsdkAlerts::renderer::RendererObserverInterface.

◆ parseFromJson()

ParseFromJsonStatus alexaClientSDK::acsdkAlerts::Alert::parseFromJson ( const rapidjson::Value &  payload,
std::string *  errorMessage 
)

Given a rapidjson pre-parsed Value, parse the fields required for a valid alert.

Parameters
payloadThe pre-parsed rapidjson::Value.
[out]errorMessageAn output parameter where a parse error message may be stored.
Returns
The status of the parse.

◆ parseFromJsonStatusToString()

static std::string alexaClientSDK::acsdkAlerts::Alert::parseFromJsonStatusToString ( Alert::ParseFromJsonStatus  parseFromJsonStatus)
static

A utility function to convert a ParseFromJsonStatus enum value to a string.

Parameters
parseFromJsonStatusThe parse status.
Returns
The string conversion.

◆ printDiagnostic()

void alexaClientSDK::acsdkAlerts::Alert::printDiagnostic ( )

A utility function to print the internals of an alert.

◆ reset()

void alexaClientSDK::acsdkAlerts::Alert::reset ( )

Sets the alert back to being set to go off in the future.

◆ setAlertData()

bool alexaClientSDK::acsdkAlerts::Alert::setAlertData ( StaticData staticData,
DynamicData dynamicData 
)

Sets the data associated with this alert.

Parameters
dynamicDataA pointer to a DynamicData struct. If this is not nullptr, this alert's DynamicData will be set.
staticDataA pointer to a StaticData struct. If this is not nullptr, this alert's StaticData will be set.
Returns
True if the alert data was successfully set.

◆ setAssetConfiguration()

bool alexaClientSDK::acsdkAlerts::Alert::setAssetConfiguration ( const AssetConfiguration assetConfiguration)

Sets the asset configuration of this alert.

Returns
whether the asset configuration was set.

◆ setFocusState()

void alexaClientSDK::acsdkAlerts::Alert::setFocusState ( avsCommon::avs::FocusState  focusState,
avsCommon::avs::MixingBehavior  behavior 
)

Sets the focus state for the alert.

Parameters
focusStateThe focus state.
behaviorThe mixing behavior.

◆ setObserver()

void alexaClientSDK::acsdkAlerts::Alert::setObserver ( acsdkAlertsInterfaces::AlertObserverInterface observer)

Set an observer on the alert. An alert may have only one observer - repeated calls to this function will replace any previous value with the new one.

Parameters
observerThe observer to set on this alert.

◆ setRenderer()

void alexaClientSDK::acsdkAlerts::Alert::setRenderer ( std::shared_ptr< renderer::RendererInterface renderer)

Set the renderer on the alert.

Parameters
rendererThe renderer to set on the alert.

◆ setStateActive()

bool alexaClientSDK::acsdkAlerts::Alert::setStateActive ( )

Sets the state of this alert to active. Only has effect if the Alert's state is State::ACTIVATING.

◆ snooze()

bool alexaClientSDK::acsdkAlerts::Alert::snooze ( const std::string &  updatedScheduledTime)

Performs relevant operations to snooze this alarm to the new time provided.

Parameters
updatedScheduledTimeThe new time for the alarm to occur, in ISO-8601 format.
Returns
true if it succeeds; false otherwise.

◆ stateToString()

static std::string alexaClientSDK::acsdkAlerts::Alert::stateToString ( Alert::State  state)
static

A utility function to convert an alert state enum value to a string.

Parameters
stateThe alert state.
Returns
The string conversion.

◆ stopReasonToString()

static std::string alexaClientSDK::acsdkAlerts::Alert::stopReasonToString ( Alert::StopReason  stopReason)
static

A utility function to convert a StopReason enum value to a string.

Parameters
stopReasonThe stop reason.
Returns
The string conversion.

◆ updateScheduledTime()

bool alexaClientSDK::acsdkAlerts::Alert::updateScheduledTime ( const std::string &  newScheduledTime)

Performs relevant operations to update this alarm to the new time provided.

Note
Use snooze for active alarms. This method will fail since it does not stop alarm rendering.
The caller should validate the new schedule which should not be more than 30 minutes in the past.
Parameters
newScheduledTimeThe new time for the alarm to occur, in ISO-8601 format.
Returns
true if it succeeds; false otherwise.

◆ validateLabelString()

static avsCommon::utils::Optional<std::string> alexaClientSDK::acsdkAlerts::Alert::validateLabelString ( const std::string &  label)
static

A utility function to convert a label string to an optional.

Parameters
labela string of label.
Returns
An optional with a valid label string; an empty optional otherwise.

◆ validateOriginalTimeString()

static avsCommon::utils::Optional<acsdkAlertsInterfaces::AlertObserverInterface::OriginalTime> alexaClientSDK::acsdkAlerts::Alert::validateOriginalTimeString ( const std::string &  originalTimeStr)
static

A utility function to convert an originalTime string to an optional of OriginalTime.

Parameters
originalTimeStra string of original time.
Returns
An optional with a valid originalTime string; an empty optional otherwise.

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