AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
SQLiteDeviceSettingStorage.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_SETTINGS_INCLUDE_SETTINGS_STORAGE_SQLITEDEVICESETTINGSTORAGE_H_
17 #define ALEXA_CLIENT_SDK_SETTINGS_INCLUDE_SETTINGS_STORAGE_SQLITEDEVICESETTINGSTORAGE_H_
18 
19 #include <memory>
20 #include <mutex>
21 #include <string>
22 #include <utility>
23 
26 
28 #include "Settings/SettingStatus.h"
29 
30 namespace alexaClientSDK {
31 namespace settings {
32 namespace storage {
33 
34 /*
35  * An SQLite implementation of the @c DeviceSettingStorageInterface.
36  */
38 public:
46  static std::shared_ptr<DeviceSettingStorageInterface> createDeviceSettingStorageInterface(
47  const std::shared_ptr<avsCommon::utils::configuration::ConfigurationNode>& configurationRoot);
48 
57  static std::unique_ptr<SQLiteDeviceSettingStorage> create(
59 
60  /*
61  * Destructor.
62  */
64 
67  bool open() override;
68  void close() override;
69  bool storeSetting(const std::string& key, const std::string& value, SettingStatus status) override;
70  bool storeSettings(const std::vector<std::tuple<std::string, std::string, SettingStatus>>& data) override;
71  SettingStatusAndValue loadSetting(const std::string& key) override;
72  bool deleteSetting(const std::string& key) override;
73  bool updateSettingStatus(const std::string& key, SettingStatus status) override;
75 
76 private:
77  /*
78  * Constructor.
79  *
80  * @param dbFilePath The file path of the SQLite database.
81  */
82  SQLiteDeviceSettingStorage(const std::string& dbFilePath);
83 
84  /*
85  * Creates a database table for the settings.
86  *
87  * @return A boolean to specify whether the creation of the table was successful.
88  */
89  bool createSettingsTable();
90 
93 
95  std::mutex m_mutex;
96 };
97 
98 } // namespace storage
99 } // namespace settings
100 } // namespace alexaClientSDK
101 
102 #endif // ALEXA_CLIENT_SDK_SETTINGS_INCLUDE_SETTINGS_STORAGE_SQLITEDEVICESETTINGSTORAGE_H_
bool storeSettings(const std::vector< std::tuple< std::string, std::string, SettingStatus >> &data) override
::std::string string
Definition: gtest-port.h:1097
bool storeSetting(const std::string &key, const std::string &value, SettingStatus status) override
Definition: DeviceSettingStorageInterface.h:36
bool updateSettingStatus(const std::string &key, SettingStatus status) override
std::pair< SettingStatus, std::string > SettingStatusAndValue
Definition: DeviceSettingStorageInterface.h:43
bool deleteSetting(const std::string &key) override
static std::shared_ptr< DeviceSettingStorageInterface > createDeviceSettingStorageInterface(const std::shared_ptr< avsCommon::utils::configuration::ConfigurationNode > &configurationRoot)
SettingStatus
Definition: SettingStatus.h:25
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
static std::unique_ptr< SQLiteDeviceSettingStorage > create(const avsCommon::utils::configuration::ConfigurationNode &configurationRoot)
Definition: SQLiteDeviceSettingStorage.h:37
static const std::string key
The database key to be used by the protocol given the METADATA object.
Definition: SharedAVSSettingProtocolTest.cpp:58
SettingStatusAndValue loadSetting(const std::string &key) override

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0