Added a specialized singleton convenience getter to DBSettings.

This commit is contained in:
Relintai 2022-02-05 19:19:52 +01:00
parent 546512f3be
commit 079dd663ee
3 changed files with 19 additions and 3 deletions

View File

@ -5,8 +5,8 @@
#include "core/object.h"
#include "core/variant.h"
#include "core/string.h"
#include "core/variant.h"
class Settings : public Object {
RCPP_OBJECT(Settings, Object);
@ -29,9 +29,10 @@ public:
virtual ~Settings();
protected:
static Settings *_singleton;
std::map<String, Variant> _data;
private:
static Settings *_singleton;
};
#endif

View File

@ -70,11 +70,21 @@ void DBSettings::set_table(const String &table) {
_table = table;
}
DBSettings *DBSettings::get_singleton() {
return _db_settings_singleton;
}
DBSettings::DBSettings(const bool singleton) :
Settings(singleton) {
_table = "settings";
if (singleton) {
_db_settings_singleton = this;
}
}
DBSettings::~DBSettings() {
}
DBSettings *DBSettings::_db_settings_singleton = nullptr;

View File

@ -15,6 +15,8 @@ public:
void set_table(const String &table);
static DBSettings *get_singleton();
DBSettings(const bool singleton = false);
virtual ~DBSettings();
@ -22,6 +24,9 @@ protected:
String _table;
std::map<String, int> _key_map;
private:
static DBSettings *_db_settings_singleton;
};
#endif