rcpp_framework/database/database_manager.h

42 lines
935 B
C
Raw Normal View History

2020-12-01 14:00:49 +01:00
#ifndef DATABASE_MANAGER_H
#define DATABASE_MANAGER_H
#include "core/string.h"
2020-12-01 14:00:49 +01:00
#include <vector>
#include <map>
#include <functional>
2020-12-01 14:00:49 +01:00
#include "core/object.h"
2020-12-01 14:00:49 +01:00
#include "database.h"
class DatabaseManager : public Object {
RCPP_OBJECT(DatabaseManager, Object);
2020-12-01 14:00:49 +01:00
public:
std::vector<Database *> databases;
Database *ddb;
2020-12-01 14:00:49 +01:00
void load();
static DatabaseManager *get_singleton();
//note: not threadsafe, create these at the start of your program!
uint32_t create_database(const String &name);
static void _register_db_creation_func(const String &name, std::function<Database*()> func);
static void _unregister_db_creation_func(const String &name);
static Database *_create_database(const String &name);
2020-12-01 14:00:49 +01:00
DatabaseManager();
~DatabaseManager();
private:
static DatabaseManager * _instance;
static std::map<String, std::function<Database *()> > _db_creation_func_map;
2020-12-01 14:00:49 +01:00
};
#endif