mirror of https://github.com/stella-emu/stella.git
Rename SettingsDb -> StellaDb .
This commit is contained in:
parent
ba24fe7430
commit
419a23183f
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "SettingsDb.hxx"
|
#include "StellaDb.hxx"
|
||||||
#include "Logger.hxx"
|
#include "Logger.hxx"
|
||||||
#include "SqliteError.hxx"
|
#include "SqliteError.hxx"
|
||||||
#include "repository/KeyValueRepositoryNoop.hxx"
|
#include "repository/KeyValueRepositoryNoop.hxx"
|
||||||
|
@ -34,14 +34,14 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
SettingsDb::SettingsDb(const string& databaseDirectory, const string& databaseName)
|
StellaDb::StellaDb(const string& databaseDirectory, const string& databaseName)
|
||||||
: myDatabaseDirectory{databaseDirectory},
|
: myDatabaseDirectory{databaseDirectory},
|
||||||
myDatabaseName{databaseName}
|
myDatabaseName{databaseName}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void SettingsDb::initialize()
|
void StellaDb::initialize()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
myDb = make_unique<SqliteDatabase>(myDatabaseDirectory, myDatabaseName);
|
myDb = make_unique<SqliteDatabase>(myDatabaseDirectory, myDatabaseName);
|
||||||
|
@ -75,7 +75,7 @@ void SettingsDb::initialize()
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void SettingsDb::initializeDb() const
|
void StellaDb::initializeDb() const
|
||||||
{
|
{
|
||||||
FilesystemNode legacyConfigFile{myDatabaseDirectory};
|
FilesystemNode legacyConfigFile{myDatabaseDirectory};
|
||||||
legacyConfigFile /= "stellarc";
|
legacyConfigFile /= "stellarc";
|
||||||
|
@ -87,7 +87,7 @@ void SettingsDb::initializeDb() const
|
||||||
legacyPropertyFile /= "stella.pro";
|
legacyPropertyFile /= "stella.pro";
|
||||||
|
|
||||||
if (legacyConfigDatabase.exists() && legacyConfigDatabase.isFile())
|
if (legacyConfigDatabase.exists() && legacyConfigDatabase.isFile())
|
||||||
importOldSettingsDB(legacyConfigDatabase);
|
importOldStellaDb(legacyConfigDatabase);
|
||||||
else if (legacyConfigFile.exists() && legacyConfigFile.isFile())
|
else if (legacyConfigFile.exists() && legacyConfigFile.isFile())
|
||||||
importStellarc(legacyConfigFile);
|
importStellarc(legacyConfigFile);
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ void SettingsDb::initializeDb() const
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void SettingsDb::importStellarc(const FilesystemNode& node) const
|
void StellaDb::importStellarc(const FilesystemNode& node) const
|
||||||
{
|
{
|
||||||
Logger::info("importing old settings from " + node.getPath());
|
Logger::info("importing old settings from " + node.getPath());
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ void SettingsDb::importStellarc(const FilesystemNode& node) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void SettingsDb::importOldSettingsDB(const FilesystemNode& node) const {
|
void StellaDb::importOldStellaDb(const FilesystemNode& node) const {
|
||||||
Logger::info("importing old settings from " + node.getPath());
|
Logger::info("importing old settings from " + node.getPath());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -126,7 +126,7 @@ void SettingsDb::importOldSettingsDB(const FilesystemNode& node) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void SettingsDb::importOldPropset(const FilesystemNode& node) const
|
void StellaDb::importOldPropset(const FilesystemNode& node) const
|
||||||
{
|
{
|
||||||
Logger::info("importing old game properties from " + node.getPath());
|
Logger::info("importing old game properties from " + node.getPath());
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ void SettingsDb::importOldPropset(const FilesystemNode& node) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void SettingsDb::migrate() const
|
void StellaDb::migrate() const
|
||||||
{
|
{
|
||||||
Int32 version = myDb->getUserVersion();
|
Int32 version = myDb->getUserVersion();
|
||||||
switch (version) {
|
switch (version) {
|
|
@ -15,8 +15,8 @@
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef SETTINGS_DB_HXX
|
#ifndef STELLA_DB_HXX
|
||||||
#define SETTINGS_DB_HXX
|
#define STELLA_DB_HXX
|
||||||
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
#include "SqliteDatabase.hxx"
|
#include "SqliteDatabase.hxx"
|
||||||
|
@ -24,11 +24,11 @@
|
||||||
#include "repository/CompositeKeyValueRepository.hxx"
|
#include "repository/CompositeKeyValueRepository.hxx"
|
||||||
#include "FSNode.hxx"
|
#include "FSNode.hxx"
|
||||||
|
|
||||||
class SettingsDb
|
class StellaDb
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SettingsDb(const string& databaseDirectory, const string& databaseName);
|
StellaDb(const string& databaseDirectory, const string& databaseName);
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class SettingsDb
|
||||||
|
|
||||||
void initializeDb() const;
|
void initializeDb() const;
|
||||||
void importStellarc(const FilesystemNode& node) const;
|
void importStellarc(const FilesystemNode& node) const;
|
||||||
void importOldSettingsDB(const FilesystemNode& node) const;
|
void importOldStellaDb(const FilesystemNode& node) const;
|
||||||
void importOldPropset(const FilesystemNode& node) const;
|
void importOldPropset(const FilesystemNode& node) const;
|
||||||
|
|
||||||
void migrate() const;
|
void migrate() const;
|
||||||
|
@ -58,4 +58,4 @@ class SettingsDb
|
||||||
unique_ptr<CompositeKeyValueRepository> myPropertyRepository;
|
unique_ptr<CompositeKeyValueRepository> myPropertyRepository;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGS_DB_HXX
|
#endif // STELLA_DB_HXX
|
|
@ -4,7 +4,7 @@ MODULE_OBJS := \
|
||||||
src/common/repository/sqlite/AbstractKeyValueRepositorySqlite.o \
|
src/common/repository/sqlite/AbstractKeyValueRepositorySqlite.o \
|
||||||
src/common/repository/sqlite/KeyValueRepositorySqlite.o \
|
src/common/repository/sqlite/KeyValueRepositorySqlite.o \
|
||||||
src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.o \
|
src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.o \
|
||||||
src/common/repository/sqlite/SettingsDb.o \
|
src/common/repository/sqlite/StellaDb.o \
|
||||||
src/common/repository/sqlite/SqliteDatabase.o \
|
src/common/repository/sqlite/SqliteDatabase.o \
|
||||||
src/common/repository/sqlite/SqliteStatement.o \
|
src/common/repository/sqlite/SqliteStatement.o \
|
||||||
src/common/repository/sqlite/SqliteTransaction.o
|
src/common/repository/sqlite/SqliteTransaction.o
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#include "Widget.hxx"
|
#include "Widget.hxx"
|
||||||
#endif
|
#endif
|
||||||
#include "KeyValueRepositorySqlite.hxx"
|
#include "KeyValueRepositorySqlite.hxx"
|
||||||
#include "SettingsDb.hxx"
|
#include "StellaDb.hxx"
|
||||||
|
|
||||||
#include "FSNode.hxx"
|
#include "FSNode.hxx"
|
||||||
#include "MD5.hxx"
|
#include "MD5.hxx"
|
||||||
|
@ -223,9 +223,9 @@ void OSystem::loadConfig(const Settings::Options& options)
|
||||||
if(!myHomeDir.isDirectory())
|
if(!myHomeDir.isDirectory())
|
||||||
myHomeDir.makeDir();
|
myHomeDir.makeDir();
|
||||||
|
|
||||||
mySettingsDb = make_shared<SettingsDb>(myBaseDir.getPath(), "stella");
|
myStellaDb = make_shared<StellaDb>(myBaseDir.getPath(), "stella");
|
||||||
mySettingsDb->initialize();
|
myStellaDb->initialize();
|
||||||
myConfigFile = FilesystemNode(mySettingsDb->databaseFileName());
|
myConfigFile = FilesystemNode(myStellaDb->databaseFileName());
|
||||||
|
|
||||||
mySettings->setRepository(getSettingsRepository());
|
mySettings->setRepository(getSettingsRepository());
|
||||||
myPropSet->setRepository(getPropertyRepository());
|
myPropSet->setRepository(getPropertyRepository());
|
||||||
|
@ -881,12 +881,12 @@ void OSystem::mainLoop()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
shared_ptr<KeyValueRepository> OSystem::getSettingsRepository()
|
shared_ptr<KeyValueRepository> OSystem::getSettingsRepository()
|
||||||
{
|
{
|
||||||
return shared_ptr<KeyValueRepository>(mySettingsDb, &mySettingsDb->settingsRepository());
|
return shared_ptr<KeyValueRepository>(myStellaDb, &myStellaDb->settingsRepository());
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<CompositeKeyValueRepository> OSystem::getPropertyRepository()
|
shared_ptr<CompositeKeyValueRepository> OSystem::getPropertyRepository()
|
||||||
{
|
{
|
||||||
return shared_ptr<CompositeKeyValueRepository>(mySettingsDb, &mySettingsDb->propertyRepository());
|
return shared_ptr<CompositeKeyValueRepository>(myStellaDb, &myStellaDb->propertyRepository());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ class AudioSettings;
|
||||||
#ifdef PNG_SUPPORT
|
#ifdef PNG_SUPPORT
|
||||||
class PNGLibrary;
|
class PNGLibrary;
|
||||||
#endif
|
#endif
|
||||||
class SettingsDb;
|
class StellaDb;
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
@ -568,7 +568,7 @@ class OSystem
|
||||||
static string ourOverrideBaseDir;
|
static string ourOverrideBaseDir;
|
||||||
static bool ourOverrideBaseDirWithApp;
|
static bool ourOverrideBaseDirWithApp;
|
||||||
|
|
||||||
shared_ptr<SettingsDb> mySettingsDb;
|
shared_ptr<StellaDb> myStellaDb;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue