AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#include <Alert.h>
Classes | |
struct | Asset |
struct | AssetConfiguration |
struct | ContextInfo |
struct | DynamicData |
struct | StaticData |
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::OriginalTime > | getOriginalTime () 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::OriginalTime > | validateOriginalTimeString (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) |
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).
|
strong |
An enum class which captures the state an alert object can be in.
|
strong |
An enum class which captures the reasons an alert may have stopped.
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.
void alexaClientSDK::acsdkAlerts::Alert::activate | ( | ) |
Activate the alert.
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.
state | state of the alertInfo, which is of different type from Alert.state |
reason | reason for alert state change |
void alexaClientSDK::acsdkAlerts::Alert::deactivate | ( | StopReason | reason | ) |
Deactivate the alert.
reason | The reason why the alert is being stopped. |
void alexaClientSDK::acsdkAlerts::Alert::getAlertData | ( | StaticData * | staticData, |
DynamicData * | dynamicData | ||
) | const |
Gets the data associated with this alert.
dynamicData | A pointer to a DynamicData struct. If this is not nullptr, it will be populated with this alert's DynamicData. |
staticData | A pointer to a StaticData struct. If this is not nullptr, it will be populated with this alert's StaticData. |
AssetConfiguration alexaClientSDK::acsdkAlerts::Alert::getAssetConfiguration | ( | ) | const |
Returns the utility structure, containing the Context data associated with this alert.
std::string alexaClientSDK::acsdkAlerts::Alert::getBackgroundAssetId | ( | ) | const |
Get the background custom asset id, as specified by AVS.
Alert::ContextInfo alexaClientSDK::acsdkAlerts::Alert::getContextInfo | ( | ) | const |
Returns the Context data which may be shared with AVS.
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.
int alexaClientSDK::acsdkAlerts::Alert::getId | ( | ) | const |
Returns the database id for the alert, if one is set.
avsCommon::utils::Optional<std::string> alexaClientSDK::acsdkAlerts::Alert::getLabel | ( | ) | const |
Gets the optional with label string.
int alexaClientSDK::acsdkAlerts::Alert::getLoopCount | ( | ) | const |
Get the loop count of custom assets.
std::chrono::milliseconds alexaClientSDK::acsdkAlerts::Alert::getLoopPause | ( | ) | const |
Get the time, in milliseconds, to be paused between custom-asset loop rendering.
avsCommon::utils::Optional<acsdkAlertsInterfaces::AlertObserverInterface::OriginalTime> alexaClientSDK::acsdkAlerts::Alert::getOriginalTime | ( | ) | const |
Gets the optional with OriginalTime
.
OriginalTime
if originalTime is valid for the alert; an empty optional otherwise. std::string alexaClientSDK::acsdkAlerts::Alert::getScheduledTime_ISO_8601 | ( | ) | const |
Gets the time the alert should occur, in ISO-8601 format.
int64_t alexaClientSDK::acsdkAlerts::Alert::getScheduledTime_Unix | ( | ) | const |
Gets the time the alert should occur, in Unix epoch time.
std::chrono::system_clock::time_point alexaClientSDK::acsdkAlerts::Alert::getScheduledTime_Utc_TimePoint | ( | ) | const |
Gets the UTC time for when the alert should occur.
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.
Alert::State alexaClientSDK::acsdkAlerts::Alert::getState | ( | ) | const |
Returns the state of the alert.
StopReason alexaClientSDK::acsdkAlerts::Alert::getStopReason | ( | ) | const |
Returns the reason the alert stopped.
std::string alexaClientSDK::acsdkAlerts::Alert::getToken | ( | ) | const |
Returns the AVS token for the alert.
acsdkAlertsInterfaces::AlertObserverInterface::Type alexaClientSDK::acsdkAlerts::Alert::getType | ( | ) | const |
Gets the Type
of the alert.
|
pure virtual |
Returns a string to identify the type of the class. Required for persistent storage.
Implemented in alexaClientSDK::acsdkAlerts::test::MockAlert, alexaClientSDK::acsdkAlerts::test::TestAlert, alexaClientSDK::acsdkAlerts::test::MockAlert, alexaClientSDK::acsdkAlerts::Timer, alexaClientSDK::acsdkAlerts::Reminder, and alexaClientSDK::acsdkAlerts::Alarm.
bool alexaClientSDK::acsdkAlerts::Alert::isPastDue | ( | int64_t | currentUnixTime, |
std::chrono::seconds | timeLimit | ||
) |
Queries whether the alert is past-due.
currentUnixTime | The time with which to compare the activation time of the alert. |
timeLimitSeconds | How long an alert may be late, and still considered valid. |
|
overridevirtual |
A callback function to communicate a change in render state.
state | The current state of the renderer. |
reason | The reason for the change of state, if required. This is typically set on an error. |
Implements alexaClientSDK::acsdkAlerts::renderer::RendererObserverInterface.
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.
payload | The pre-parsed rapidjson::Value. | |
[out] | errorMessage | An output parameter where a parse error message may be stored. |
|
static |
A utility function to convert a ParseFromJsonStatus enum value to a string.
parseFromJsonStatus | The parse status. |
void alexaClientSDK::acsdkAlerts::Alert::printDiagnostic | ( | ) |
A utility function to print the internals of an alert.
void alexaClientSDK::acsdkAlerts::Alert::reset | ( | ) |
Sets the alert back to being set to go off in the future.
bool alexaClientSDK::acsdkAlerts::Alert::setAlertData | ( | StaticData * | staticData, |
DynamicData * | dynamicData | ||
) |
Sets the data associated with this alert.
dynamicData | A pointer to a DynamicData struct. If this is not nullptr, this alert's DynamicData will be set. |
staticData | A pointer to a StaticData struct. If this is not nullptr, this alert's StaticData will be set. |
bool alexaClientSDK::acsdkAlerts::Alert::setAssetConfiguration | ( | const AssetConfiguration & | assetConfiguration | ) |
Sets the asset configuration of this alert.
void alexaClientSDK::acsdkAlerts::Alert::setFocusState | ( | avsCommon::avs::FocusState | focusState, |
avsCommon::avs::MixingBehavior | behavior | ||
) |
Sets the focus state for the alert.
focusState | The focus state. |
behavior | The mixing behavior. |
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.
observer | The observer to set on this alert. |
void alexaClientSDK::acsdkAlerts::Alert::setRenderer | ( | std::shared_ptr< renderer::RendererInterface > | renderer | ) |
Set the renderer on the alert.
renderer | The renderer to set on the alert. |
bool alexaClientSDK::acsdkAlerts::Alert::setStateActive | ( | ) |
Sets the state of this alert to active. Only has effect if the Alert's state is State::ACTIVATING.
bool alexaClientSDK::acsdkAlerts::Alert::snooze | ( | const std::string & | updatedScheduledTime | ) |
Performs relevant operations to snooze this alarm to the new time provided.
updatedScheduledTime | The new time for the alarm to occur, in ISO-8601 format. |
true
if it succeeds; false
otherwise.
|
static |
A utility function to convert an alert state enum value to a string.
state | The alert state. |
|
static |
A utility function to convert a StopReason enum value to a string.
stopReason | The stop reason. |
bool alexaClientSDK::acsdkAlerts::Alert::updateScheduledTime | ( | const std::string & | newScheduledTime | ) |
Performs relevant operations to update this alarm to the new time provided.
snooze
for active alarms. This method will fail since it does not stop alarm rendering. newScheduledTime | The new time for the alarm to occur, in ISO-8601 format. |
true
if it succeeds; false
otherwise.
|
static |
A utility function to convert a label string to an optional.
label | a string of label. |
|
static |
A utility function to convert an originalTime string to an optional of OriginalTime
.
originalTimeStr | a string of original time. |
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0