![]() |
AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#include <SQLiteAlertStorage.h>
Public Types | |
enum | StatLevel { StatLevel::ONE_LINE, StatLevel::ALERTS_SUMMARY, StatLevel::EVERYTHING } |
Public Member Functions | |
~SQLiteAlertStorage () | |
bool | createDatabase () override |
bool | open () override |
void | close () override |
bool | store (std::shared_ptr< Alert > alert) override |
bool | storeOfflineAlert (const std::string &token, const std::string &scheduledTime, const std::string &eventTime) override |
bool | load (std::vector< std::shared_ptr< Alert >> *alertContainer, std::shared_ptr< settings::DeviceSettingsManager > settingsManager) override |
bool | loadOfflineAlerts (rapidjson::Value *alertContainer, rapidjson::Document::AllocatorType &allocator) override |
bool | modify (std::shared_ptr< Alert > alert) override |
bool | erase (std::shared_ptr< Alert > alert) override |
bool | eraseOffline (const std::string &token, int id) override |
bool | bulkErase (const std::list< std::shared_ptr< Alert >> &alertList) override |
bool | clearDatabase () override |
void | printStats (StatLevel level=StatLevel::ONE_LINE) |
![]() | |
virtual | ~AlertStorageInterface ()=default |
Static Public Member Functions | |
static std::shared_ptr< AlertStorageInterface > | createAlertStorageInterface (const std::shared_ptr< avsCommon::utils::configuration::ConfigurationNode > &configurationRoot, const std::shared_ptr< avsCommon::sdkInterfaces::audio::AudioFactoryInterface > &audioFactory, std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder=nullptr) |
static std::unique_ptr< SQLiteAlertStorage > | create (const avsCommon::utils::configuration::ConfigurationNode &configurationRoot, const std::shared_ptr< avsCommon::sdkInterfaces::audio::AlertsAudioFactoryInterface > &alertsAudioFactory, std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder=nullptr) |
An implementation that allows us to store alerts using SQLite. This class is not thread safe.
TODO: ACSDK-390 Investigate adding an abstraction layer between this class and the AlertStorageInterface, where the middle layer is expressed purely in SQL.
An enum class to help debug database contents. This type is used in the printStats function below.
alexaClientSDK::acsdkAlerts::storage::SQLiteAlertStorage::~SQLiteAlertStorage | ( | ) |
On destruction, close the underlying database.
|
overridevirtual |
Erases multiple alerts from the database. This function must be atomic, no alert is to be deleted if there was an error deleting one.
alertList | The list of alerts to be erased. |
Implements alexaClientSDK::acsdkAlerts::storage::AlertStorageInterface.
|
overridevirtual |
A utility function to clear the database of all records. Note that the database will still exist, as will the tables. Only the rows will be erased.
Implements alexaClientSDK::acsdkAlerts::storage::AlertStorageInterface.
|
overridevirtual |
Close the currently open database, if one is open.
Implements alexaClientSDK::acsdkAlerts::storage::AlertStorageInterface.
|
static |
Factory method for creating a storage object for Alerts based on an SQLite database.
configurationRoot | The global config object. |
alertsAudioFactory | A factory that can produce default alert sounds. |
metricRecorder | The MetricRecorderInterface used to record metrics. |
|
static |
Factory method for creating a storage object for Alerts based on an SQLite database.
configurationRoot | The global config object. |
audioFactory | A factory that can produce default alert sounds. |
metricRecorder | The MetricRecorderInterface used to record metrics. |
|
overridevirtual |
Creates a new database. If a database is already being handled by this object or there is another internal error, then this function returns false.
true
If the database is created ok, or false
if a database is already being handled by this object or there is a problem creating the database. Implements alexaClientSDK::acsdkAlerts::storage::AlertStorageInterface.
|
overridevirtual |
Erases a single alert from the database.
alert | The Alert to be erased. |
Alert
was successfully erased. Implements alexaClientSDK::acsdkAlerts::storage::AlertStorageInterface.
|
overridevirtual |
Erases a single alert from the offline database.
token | The alertToken of the alert to be erased. |
id | The id of the alert to be erased |
Implements alexaClientSDK::acsdkAlerts::storage::AlertStorageInterface.
|
overridevirtual |
Loads all alerts in the database.
[out] | alertContainer | The container where alerts should be stored. |
settingsManager | A settingsManager object that manages alarm volume ramp setting. |
Alerts
were successfully loaded. Implements alexaClientSDK::acsdkAlerts::storage::AlertStorageInterface.
|
overridevirtual |
Loads all alerts in the offline database.
[out] | alertContainer | The container where alerts should be stored. |
allocator | The rapidjson allocator, required for the results of this function to be mergable with other rapidjson::Value objects. |
Implements alexaClientSDK::acsdkAlerts::storage::AlertStorageInterface.
|
overridevirtual |
Updates a database record of the Alert
parameter. The fields which are updated by this operation are the state and scheduled times of the alert. All other fields of an alert do not change over time, and so will not be captured in the database when calling this function.
alert | The Alert to be modified. |
Alert
was successfully modified. Implements alexaClientSDK::acsdkAlerts::storage::AlertStorageInterface.
|
overridevirtual |
Open an existing database. If this object is already managing an open database, or there is a problem opening the database, this function returns false.
true
If the database is opened ok, false
if this object is already managing an open database, or if there is another internal reason the database could not be opened. Implements alexaClientSDK::acsdkAlerts::storage::AlertStorageInterface.
void alexaClientSDK::acsdkAlerts::storage::SQLiteAlertStorage::printStats | ( | StatLevel | level = StatLevel::ONE_LINE | ) |
A utility function to print the contents of the database to the SDK logger output. This function is provided for debug use only.
|
overridevirtual |
Stores a single Alert
in the database.
The | Alert to store. |
Alert
was successfully stored. Implements alexaClientSDK::acsdkAlerts::storage::AlertStorageInterface.
|
overridevirtual |
Stores a single Alert
in the offline alerts database.
token | The alertToken of the alert to be erased. |
scheduledTime | The scheduled time of the alert |
eventTime | the time the alert stopped |
Alert
was successfully stored. Implements alexaClientSDK::acsdkAlerts::storage::AlertStorageInterface.
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0