Add property repository.

This commit is contained in:
Christian Speckner 2020-12-30 17:00:11 +01:00
parent 791324caf3
commit 2b01bc76a8
2 changed files with 8 additions and 0 deletions

View File

@ -35,12 +35,16 @@ bool SettingsDb::initialize()
mySettingsRepository = make_unique<KeyValueRepositorySqlite>(*myDb, "settings");
mySettingsRepository->initialize();
myPropertyRepository = make_unique<CompositeKeyValueRepositorySqlite>(*myDb, "properties");
myPropertyRepository->initialize();
}
catch (const SqliteError& err) {
Logger::info("sqlite DB " + databaseFileName() + " failed to initialize: " + err.what());
myDb.reset();
mySettingsRepository.reset();
myPropertyRepository.reset();
return false;
}

View File

@ -21,6 +21,7 @@
#include "bspf.hxx"
#include "SqliteDatabase.hxx"
#include "KeyValueRepositorySqlite.hxx"
#include "CompositeKeyValueRepositorySqlite.hxx"
class SettingsDb
{
@ -32,6 +33,8 @@ class SettingsDb
KeyValueRepository& settingsRepository() const { return *mySettingsRepository; }
CompositeKeyValueRepository& propertyRepository() const { return *myPropertyRepository; }
const string& databaseFileName() const { return myDb->fileName(); }
private:
@ -41,6 +44,7 @@ class SettingsDb
unique_ptr<SqliteDatabase> myDb;
unique_ptr<KeyValueRepositorySqlite> mySettingsRepository;
unique_ptr<CompositeKeyValueRepositorySqlite> myPropertyRepository;
};
#endif // SETTINGS_DB_HXX