logic: Application settings migration system

* Added version number to ApplicationSettings
* Added SettingsMigrator for defining migration rules for different ApplicationSettings versions
* Migrate ApplicationSettings when loading
This commit is contained in:
Eberhard Graether
2016-08-25 12:40:54 +02:00
parent cc8ea7c8fb
commit 03bbce45c9
13 changed files with 489 additions and 23 deletions
+32
View File
@@ -3,6 +3,8 @@
#include "utility/ResourcePaths.h"
#include "utility/utility.h"
const size_t ApplicationSettings::VERSION = 1;
std::shared_ptr<ApplicationSettings> ApplicationSettings::s_instance;
std::shared_ptr<ApplicationSettings> ApplicationSettings::getInstance()
@@ -23,6 +25,36 @@ ApplicationSettings::~ApplicationSettings()
{
}
bool ApplicationSettings::load(const FilePath& filePath)
{
bool loaded = Settings::load(filePath);
if (!loaded)
{
return false;
}
SettingsMigrator migrator;
migrator.addMigration(1,
"source/header_search_paths/header_search_path",
"indexing/cxx/header_search_paths/header_search_path");
migrator.addMigration(1,
"source/framework_search_paths/framework_search_path",
"indexing/cxx/framework_search_paths/framework_search_path");
migrator.addMigration(1,
"application/indexer_thread_count",
"indexing/indexer_thread_count");
bool migrated = migrator.migrate(this, ApplicationSettings::VERSION);
if (migrated)
{
save();
}
return true;
}
bool ApplicationSettings::operator==(const ApplicationSettings& other) const
{
return