AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Static Public Member Functions | List of all members
alexaClientSDK::certifiedSender::SQLiteMessageStorage Class Reference

#include <SQLiteMessageStorage.h>

Inheritance diagram for alexaClientSDK::certifiedSender::SQLiteMessageStorage:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::certifiedSender::SQLiteMessageStorage:
Collaboration graph
[legend]

Public Member Functions

 SQLiteMessageStorage (const std::string &databaseFilePath)
 
 ~SQLiteMessageStorage ()
 
bool createDatabase () override
 
bool open () override
 
void close () override
 
bool store (const std::string &message, int *id) override
 
bool store (const std::string &message, const std::string &uriPathExtension, int *id) override
 
bool load (std::queue< StoredMessage > *messageContainer) override
 
bool erase (int messageId) override
 
bool clearDatabase () override
 
- Public Member Functions inherited from alexaClientSDK::certifiedSender::MessageStorageInterface
virtual ~MessageStorageInterface ()=default
 

Static Public Member Functions

static std::shared_ptr< MessageStorageInterfacecreateMessageStorageInterface (const std::shared_ptr< avsCommon::utils::configuration::ConfigurationNode > &configurationRoot)
 
static std::unique_ptr< SQLiteMessageStoragecreate (const avsCommon::utils::configuration::ConfigurationNode &configurationRoot)
 

Detailed Description

An implementation that allows us to store messages using SQLite.

This class is not thread-safe.

Constructor & Destructor Documentation

◆ SQLiteMessageStorage()

alexaClientSDK::certifiedSender::SQLiteMessageStorage::SQLiteMessageStorage ( const std::string &  databaseFilePath)

Constructor.

Parameters
dbFilePathThe location of the SQLite database file.

◆ ~SQLiteMessageStorage()

alexaClientSDK::certifiedSender::SQLiteMessageStorage::~SQLiteMessageStorage ( )

Member Function Documentation

◆ clearDatabase()

bool alexaClientSDK::certifiedSender::SQLiteMessageStorage::clearDatabase ( )
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.

Returns
Whether the database was successfully cleared.

Implements alexaClientSDK::certifiedSender::MessageStorageInterface.

◆ close()

void alexaClientSDK::certifiedSender::SQLiteMessageStorage::close ( )
overridevirtual

Close the currently open database, if one is open.

Implements alexaClientSDK::certifiedSender::MessageStorageInterface.

◆ create()

static std::unique_ptr<SQLiteMessageStorage> alexaClientSDK::certifiedSender::SQLiteMessageStorage::create ( const avsCommon::utils::configuration::ConfigurationNode configurationRoot)
static

Factory method for creating a storage object for Messages based on an SQLite database.

Parameters
configurationRootThe global config object.
Returns
Pointer to the SQLiteMessagetStorge object, nullptr if there's an error creating it.

◆ createDatabase()

bool alexaClientSDK::certifiedSender::SQLiteMessageStorage::createDatabase ( )
overridevirtual

Creates a new database with the given filePath. If a database is already being handled by this object, or there is are other errors creating the database, this function returns false.

Returns
true If the database is created ok, or false if a database is already being handled by this object or there is an internal error creating the database.

Implements alexaClientSDK::certifiedSender::MessageStorageInterface.

◆ createMessageStorageInterface()

static std::shared_ptr<MessageStorageInterface> alexaClientSDK::certifiedSender::SQLiteMessageStorage::createMessageStorageInterface ( const std::shared_ptr< avsCommon::utils::configuration::ConfigurationNode > &  configurationRoot)
static

Factory method for creating a storage object for Messages based on an SQLite database.

Parameters
configurationRootThe global config object.
Returns
Pointer to the SQLiteMessagetStorge object, nullptr if there's an error creating it.

◆ erase()

bool alexaClientSDK::certifiedSender::SQLiteMessageStorage::erase ( int  messageId)
overridevirtual

Erases a single message from the database.

Parameters
messageIdThe id of the message to be erased.
Returns
Whether the message was successfully erased.

Implements alexaClientSDK::certifiedSender::MessageStorageInterface.

◆ load()

bool alexaClientSDK::certifiedSender::SQLiteMessageStorage::load ( std::queue< StoredMessage > *  messageContainer)
overridevirtual

Loads all messages in the database.

Parameters
[out]messageContainerThe container where messages should be stored.
Returns
Whether the StoredMessages were successfully loaded.

Implements alexaClientSDK::certifiedSender::MessageStorageInterface.

◆ open()

bool alexaClientSDK::certifiedSender::SQLiteMessageStorage::open ( )
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.

Returns
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::certifiedSender::MessageStorageInterface.

◆ store() [1/2]

bool alexaClientSDK::certifiedSender::SQLiteMessageStorage::store ( const std::string &  message,
int *  id 
)
overridevirtual

Stores a single message in the database.

Parameters
Themessage to store.
[out]idThe id associated with the stored messsage, if successfully stored.
Returns
Whether the message was successfully stored.

Implements alexaClientSDK::certifiedSender::MessageStorageInterface.

◆ store() [2/2]

bool alexaClientSDK::certifiedSender::SQLiteMessageStorage::store ( const std::string &  message,
const std::string &  uriPathExtension,
int *  id 
)
overridevirtual

Stores a single message and its uri in the database.

Parameters
Themessage to store.
uriPathExtensionpath extension which will be appended to the base url of the AVS when sending the event.
[out]idThe id associated with the stored messsage, if successfully stored.
Returns
Whether the message was successfully stored.

Implements alexaClientSDK::certifiedSender::MessageStorageInterface.


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