mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
Added a specialized singleton convenience getter to DBSettings.
This commit is contained in:
parent
546512f3be
commit
079dd663ee
@ -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
|
@ -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;
|
@ -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
|
Loading…
Reference in New Issue
Block a user