summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/resumption/resumption_data_db.cc
diff options
context:
space:
mode:
authorVeronica Veremjova <vveremjova@luxoft.com>2016-05-11 16:32:39 +0300
committerVeronica Veremjova <vveremjova@luxoft.com>2016-05-12 15:52:17 +0300
commitb908974e224a6375e3d4aa1bbda859dfbb4a58dc (patch)
tree9b749c95982bbb8305f74adae87dd62559b0b25b /src/components/application_manager/src/resumption/resumption_data_db.cc
parentb58e6058ea5be28b09583a7f57757b7cf369591c (diff)
downloadsdl_core-b908974e224a6375e3d4aa1bbda859dfbb4a58dc.tar.gz
Refactoring: deleted unuseful members and functions in resumption data
Added ability to create database in memory Fixed code after merge
Diffstat (limited to 'src/components/application_manager/src/resumption/resumption_data_db.cc')
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_db.cc55
1 files changed, 15 insertions, 40 deletions
diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc
index 063cb332f1..08de6d8190 100644
--- a/src/components/application_manager/src/resumption/resumption_data_db.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_db.cc
@@ -50,15 +50,23 @@ namespace resumption {
CREATE_LOGGERPTR_GLOBAL(logger_, "Resumption")
ResumptionDataDB::ResumptionDataDB(
+ DbStorage db_storage,
const application_manager::ApplicationManager& application_manager)
- : ResumptionData(application_manager)
- , db_(new utils::dbms::SQLDatabase(kDatabaseName)) {
+ : ResumptionData(application_manager) {
+ if (db_storage == In_File_Storage) {
+ db_ = new utils::dbms::SQLDatabase(kDatabaseName);
#ifndef __QNX__
- std::string path = application_manager_.get_settings().app_storage_folder();
- if (!path.empty()) {
- db_->set_path(path + "/");
- }
+ std::string path = application_manager_.get_settings().app_storage_folder();
+ if (!path.empty()) {
+ db_->set_path(path + "/");
+ }
+ } else if (db_storage == In_Memory_Storage) {
+ db_ = new utils::dbms::SQLDatabase();
#endif // __QNX__
+ } else {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_ERROR(logger_, "Get not existed type of database storage");
+ }
}
ResumptionDataDB::~ResumptionDataDB() {
@@ -189,45 +197,12 @@ void ResumptionDataDB::SaveApplication(
WriteDb();
}
-int32_t ResumptionDataDB::GetStoredHMILevel(
- const std::string& policy_app_id, const std::string& device_id) const {
- LOG4CXX_AUTO_TRACE(logger_);
-
- int hmi_level;
- if (SelectHMILevel(policy_app_id, device_id, hmi_level)) {
- LOG4CXX_INFO(logger_,
- "Application with policy application id = "
- << policy_app_id << " and device id = " << device_id
- << "has hmi level = " << hmi_level);
- return hmi_level;
- }
- LOG4CXX_FATAL(logger_, "HMI level doesn't exists in saved data");
- return -1;
-}
-
bool ResumptionDataDB::IsHMIApplicationIdExist(uint32_t hmi_app_id) const {
LOG4CXX_AUTO_TRACE(logger_);
return CheckExistenceHMIId(hmi_app_id);
}
-bool ResumptionDataDB::CheckSavedApplication(const std::string& policy_app_id,
- const std::string& device_id) {
- LOG4CXX_AUTO_TRACE(logger_);
- bool application_exist = false;
- if (!CheckExistenceApplication(policy_app_id, device_id, application_exist) ||
- !application_exist) {
- LOG4CXX_WARN(logger_,
- "Problem with access to DB or application does not exist");
- return false;
- }
- LOG4CXX_INFO(logger_,
- "Application with policy_app_id = "
- << policy_app_id << " and device_id = " << device_id
- << " does exist");
- return true;
-}
-
uint32_t ResumptionDataDB::GetHMIApplicationID(
const std::string& policy_app_id, const std::string& device_id) const {
LOG4CXX_AUTO_TRACE(logger_);
@@ -545,7 +520,7 @@ uint32_t ResumptionDataDB::SelectIgnOffTime() const {
bool ResumptionDataDB::CheckExistenceApplication(
const std::string& policy_app_id,
const std::string& device_id,
- bool application_exist) const {
+ bool& application_exist) const {
LOG4CXX_AUTO_TRACE(logger_);
bool result = false;
utils::dbms::SQLQuery query(db());