rcpp_framework/core/database/database_manager.h

36 lines
849 B
C
Raw Normal View History

2020-12-01 14:00:49 +01:00
#ifndef DATABASE_MANAGER_H
#define DATABASE_MANAGER_H
#include <vector>
#include <map>
#include <functional>
2020-12-01 14:00:49 +01:00
#include "database.h"
class DatabaseManager {
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 std::string &name);
static void _register_db_creation_func(const std::string &name, std::function<Database*()> func);
static void _unregister_db_creation_func(const std::string &name);
static Database *_create_database(const std::string &name);
2020-12-01 14:00:49 +01:00
DatabaseManager();
~DatabaseManager();
private:
static DatabaseManager * _instance;
static std::map<std::string, std::function<Database *()> > _db_creation_func_map;
2020-12-01 14:00:49 +01:00
};
#endif