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::storage::sqliteStorage::SQLiteMiscStorage Class Reference

#include <SQLiteMiscStorage.h>

Inheritance diagram for alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage:
Collaboration graph
[legend]

Public Member Functions

 ~SQLiteMiscStorage ()
 
SQLiteDatabasegetDatabase ()
 Provides reference to a database. More...
 
MiscStorageInterface method overrides.
bool createDatabase () override
 
bool open () override
 
bool isOpened () override
 
void close () override
 
bool createTable (const std::string &componentName, const std::string &tableName, KeyType keyType, ValueType valueType) override
 
bool clearTable (const std::string &componentName, const std::string &tableName) override
 
bool deleteTable (const std::string &componentName, const std::string &tableName) override
 
bool get (const std::string &componentName, const std::string &tableName, const std::string &key, std::string *value) override
 
bool add (const std::string &componentName, const std::string &tableName, const std::string &key, const std::string &value) override
 
bool update (const std::string &componentName, const std::string &tableName, const std::string &key, const std::string &value) override
 
bool put (const std::string &componentName, const std::string &tableName, const std::string &key, const std::string &value) override
 
bool remove (const std::string &componentName, const std::string &tableName, const std::string &key) override
 
bool tableEntryExists (const std::string &componentName, const std::string &tableName, const std::string &key, bool *tableEntryExistsValue) override
 
bool tableExists (const std::string &componentName, const std::string &tableName, bool *tableExistsValue) override
 
bool load (const std::string &componentName, const std::string &tableName, std::unordered_map< std::string, std::string > *valueContainer) override
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface
virtual ~MiscStorageInterface ()=default
 

Static Public Member Functions

static std::shared_ptr< avsCommon::sdkInterfaces::storage::MiscStorageInterfacecreateMiscStorageInterface (const std::shared_ptr< avsCommon::utils::configuration::ConfigurationNode > &configurationRoot)
 
static std::unique_ptr< SQLiteMiscStoragecreate (const avsCommon::utils::configuration::ConfigurationNode &configurationRoot)
 
static std::unique_ptr< SQLiteMiscStoragecreate (const std::string &databasePath)
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface
enum  KeyType { KeyType::UNKNOWN_KEY, KeyType::STRING_KEY }
 The type of the key column in Misc DB. More...
 
enum  ValueType { ValueType::UNKNOWN_VALUE, ValueType::STRING_VALUE }
 The type of the value column in Misc DB. More...
 

Detailed Description

A class that provides a SQLite implementation of MiscStorage database.

Constructor & Destructor Documentation

◆ ~SQLiteMiscStorage()

alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::~SQLiteMiscStorage ( )

Destructor

Member Function Documentation

◆ add()

bool alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::add ( const std::string &  componentName,
const std::string &  tableName,
const std::string &  key,
const std::string &  value 
)
overridevirtual

Adds a value in the table.

Parameters
componentNameThe component name.
tableNameThe table name.
keyThe key for the table entry.
valueThe value of the table entry.
Note
value should be a string literal.
Returns
true If the value was added ok, false if not.

Implements alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface.

◆ clearTable()

bool alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::clearTable ( const std::string &  componentName,
const std::string &  tableName 
)
overridevirtual

Removes all the entries in the table. The table itself will continue to exist.

Parameters
componentNameThe component name.
tableNameThe table name.
Returns
true If the table is cleared ok, false if the table couldn't be cleared.

Implements alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface.

◆ close()

void alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::close ( )
overridevirtual

Close the currently open database, if one is open.

Implements alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface.

◆ create() [1/2]

static std::unique_ptr<SQLiteMiscStorage> alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::create ( const avsCommon::utils::configuration::ConfigurationNode configurationRoot)
static

Factory method for creating a storage object for a SQLite database. Note that the actual database will not be created by this function.

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

◆ create() [2/2]

static std::unique_ptr<SQLiteMiscStorage> alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::create ( const std::string &  databasePath)
static

Factory method for creating a storage object for a SQLite database. Note that the actual database will not be created by this function.

Deprecated:
Parameters
[in]databasePathPath to database
Returns
Pointer to the SQLiteAlertStorage object, nullptr if there's an error creating it.

◆ createDatabase()

bool alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::createDatabase ( )
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.

Returns
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::avsCommon::sdkInterfaces::storage::MiscStorageInterface.

◆ createMiscStorageInterface()

static std::shared_ptr<avsCommon::sdkInterfaces::storage::MiscStorageInterface> alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::createMiscStorageInterface ( const std::shared_ptr< avsCommon::utils::configuration::ConfigurationNode > &  configurationRoot)
static

Factory method for creating a storage object for a SQLite database. Note that the actual database will not be created by this function.

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

◆ createTable()

bool alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::createTable ( const std::string &  componentName,
const std::string &  tableName,
KeyType  keyType,
ValueType  valueType 
)
overridevirtual

Create a simple key/value pair table. If there is a problem creating the table, this function returns false.

Parameters
componentNameThe component name.
tableNameThe table name.
keyTypeThe key type.
valueTypeThe value type.
Returns
true If the table is created ok, false if the table couldn't be created.

Implements alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface.

◆ deleteTable()

bool alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::deleteTable ( const std::string &  componentName,
const std::string &  tableName 
)
overridevirtual

Deletes the table. The table must be empty before you can delete the table.

Parameters
componentNameThe component name.
tableNameThe table name.
Returns
true If the table is deleted ok, false if the table couldn't be deleted.

Implements alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface.

◆ get()

bool alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::get ( const std::string &  componentName,
const std::string &  tableName,
const std::string &  key,
std::string *  value 
)
overridevirtual

Gets the value associated with a key in the table.

Parameters
componentNameThe component name.
tableNameThe table name.
keyThe key for the table entry.
[out]valueThe value associated with the key in the table.
Returns
true If the value was found out ok, false if not.

Implements alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface.

◆ getDatabase()

SQLiteDatabase& alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::getDatabase ( )

Provides reference to a database.

This method provides a reference to inner database object for database maintenance operations. The access to the database is not serialized against parallel access and should be used only when it is guaranteed there are no other consumers of the objects.

Returns
Reference to database.

◆ isOpened()

bool alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::isOpened ( )
overridevirtual

Returns true if this object is already managing an open database, false otherwise.

Returns
True if this object is already managing an open database, false otherwise.

Implements alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface.

◆ load()

bool alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::load ( const std::string &  componentName,
const std::string &  tableName,
std::unordered_map< std::string, std::string > *  valueContainer 
)
overridevirtual

Loads the table entries into a map.

Parameters
componentNameThe component name.
tableNameThe table name.
[out]valueContainerThe container for the values in the table.
Returns
true If the values were loaded ok, false if not.

Implements alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface.

◆ open()

bool alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::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::avsCommon::sdkInterfaces::storage::MiscStorageInterface.

◆ put()

bool alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::put ( const std::string &  componentName,
const std::string &  tableName,
const std::string &  key,
const std::string &  value 
)
overridevirtual

Puts a value in the table. Basically, this will add the entry for the key if it doesn't already exist, or it will update the entry for the key if it already exists.

Parameters
componentNameThe component name.
tableNameThe table name.
keyThe key for the table entry.
valueThe value of the table entry.
Note
value should be a literal string.
Returns
true If the value was put ok, false if not.

Implements alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface.

◆ remove()

bool alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::remove ( const std::string &  componentName,
const std::string &  tableName,
const std::string &  key 
)
overridevirtual

Removes a value from the table.

Parameters
componentNameThe component name.
tableNameThe table name.
keyThe key for the table entry.
Returns
true If the value was removed ok, false if not.

Implements alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface.

◆ tableEntryExists()

bool alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::tableEntryExists ( const std::string &  componentName,
const std::string &  tableName,
const std::string &  key,
bool *  tableEntryExistsValue 
)
overridevirtual

Checks if a key exists in the table.

Parameters
componentNameThe component name.
tableNameThe table name.
keyThe key for the table entry.
[out]tableEntryExistsValueTrue if the key exists, false if not.
Returns
true if the table entry's existence was found out ok, else false..

Implements alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface.

◆ tableExists()

bool alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::tableExists ( const std::string &  componentName,
const std::string &  tableName,
bool *  tableExistsValue 
)
overridevirtual

Checks if a table exists in the DB.

Parameters
componentNameThe component name.
tableNameThe table name.
[out]tableExistsValueTrue if the table exists, false if not.
Returns
true if the table's existence was found out ok, else false.

Implements alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface.

◆ update()

bool alexaClientSDK::storage::sqliteStorage::SQLiteMiscStorage::update ( const std::string &  componentName,
const std::string &  tableName,
const std::string &  key,
const std::string &  value 
)
overridevirtual

Updates a value in the table.

Parameters
tableNameThe table name.
keyThe key for the table entry.
valueThe value of the table entry.
Note
value should be a literal string.
Returns
true If the value was updated ok, false if not (including if the entry does not exist).

Implements alexaClientSDK::avsCommon::sdkInterfaces::storage::MiscStorageInterface.


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