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:
@@ -8,6 +8,8 @@
|
||||
#include "utility/ConfigManager.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
#include "settings/SettingsMigrator.h"
|
||||
|
||||
class Settings
|
||||
{
|
||||
public:
|
||||
@@ -15,14 +17,20 @@ public:
|
||||
Settings& operator=(const Settings& other);
|
||||
virtual ~Settings();
|
||||
|
||||
virtual bool load(const FilePath& filePath);
|
||||
virtual void save();
|
||||
virtual void save(const FilePath& filePath);
|
||||
bool load(const FilePath& filePath);
|
||||
void save();
|
||||
void save(const FilePath& filePath);
|
||||
|
||||
void clear();
|
||||
|
||||
virtual const FilePath& getFilePath() const;
|
||||
|
||||
size_t getVersion() const;
|
||||
void setVersion(size_t version);
|
||||
|
||||
static Settings createFromText(const std::shared_ptr<TextAccess> textAccess);
|
||||
std::string getAsText() const;
|
||||
|
||||
protected:
|
||||
Settings();
|
||||
|
||||
@@ -47,9 +55,13 @@ protected:
|
||||
|
||||
bool isValueDefined(const std::string& key) const;
|
||||
|
||||
void removeValues(const std::string& key);
|
||||
|
||||
void enableWarnings() const;
|
||||
void disableWarnings() const;
|
||||
|
||||
friend bool SettingsMigrator::migrate(Settings* settings, size_t targetVersion) const;
|
||||
|
||||
private:
|
||||
FilePath m_filePath;
|
||||
std::shared_ptr<ConfigManager> m_config;
|
||||
|
||||
Reference in New Issue
Block a user