2022-06-30 13:23:48 +02:00
|
|
|
#ifndef DATABASE_MANAGER_H
|
|
|
|
#define DATABASE_MANAGER_H
|
|
|
|
|
2022-07-05 23:30:14 +02:00
|
|
|
#include "core/reference.h"
|
|
|
|
#include "core/ustring.h"
|
2022-07-23 13:37:24 +02:00
|
|
|
#include "core/vector.h"
|
2022-06-30 13:23:48 +02:00
|
|
|
|
|
|
|
#include "core/object.h"
|
|
|
|
|
2022-07-05 23:30:14 +02:00
|
|
|
class Database;
|
2022-06-30 13:23:48 +02:00
|
|
|
|
|
|
|
class DatabaseManager : public Object {
|
2022-07-05 23:30:14 +02:00
|
|
|
GDCLASS(DatabaseManager, Object);
|
2022-06-30 13:23:48 +02:00
|
|
|
|
|
|
|
public:
|
2022-07-23 13:37:24 +02:00
|
|
|
//ddb = default database
|
2022-07-05 23:30:14 +02:00
|
|
|
Ref<Database> get_ddb();
|
|
|
|
void set_ddb(const Ref<Database> &db);
|
2022-06-30 13:23:48 +02:00
|
|
|
|
2022-07-23 13:37:24 +02:00
|
|
|
void add_database(const Ref<Database> &db, bool set_as_default = true);
|
|
|
|
void remove_database(const int index, const bool unset_if_default = true);
|
|
|
|
Ref<Database> get_database(const int index);
|
|
|
|
int get_database_count();
|
|
|
|
|
|
|
|
Vector<Ref<Database>> get_databases();
|
|
|
|
Vector<Variant> get_databases_bind();
|
|
|
|
|
2022-07-05 23:30:14 +02:00
|
|
|
void load();
|
2022-06-30 13:23:48 +02:00
|
|
|
|
2022-07-05 23:30:14 +02:00
|
|
|
static DatabaseManager *get_singleton();
|
2022-06-30 13:23:48 +02:00
|
|
|
|
2022-07-05 23:30:14 +02:00
|
|
|
DatabaseManager();
|
|
|
|
~DatabaseManager();
|
2022-06-30 13:23:48 +02:00
|
|
|
|
2022-07-05 23:30:14 +02:00
|
|
|
protected:
|
|
|
|
Vector<Ref<Database>> _databases;
|
|
|
|
Ref<Database> _ddb;
|
2022-06-30 13:23:48 +02:00
|
|
|
|
|
|
|
private:
|
2022-07-23 13:37:24 +02:00
|
|
|
static void _bind_methods();
|
|
|
|
|
2022-07-05 23:30:14 +02:00
|
|
|
static DatabaseManager *_instance;
|
2022-06-30 13:23:48 +02:00
|
|
|
};
|
|
|
|
|
2022-07-05 23:30:14 +02:00
|
|
|
#endif
|