Now the RCPPFramework singleton will allocate the DatabaseManager if databases are enabled by default.

This commit is contained in:
Relintai 2022-02-05 18:26:32 +01:00
parent 20739e4aa0
commit cf7458caaf
2 changed files with 37 additions and 21 deletions

View File

@ -3,6 +3,7 @@
#include "core/error_macros.h"
#if DATABASES_ENABLED
#include "database/database_manager.h"
#include "database_backends/db_init.h"
#endif
@ -64,6 +65,10 @@ RCPPFramework::RCPPFramework() {
_instance = this;
_initialized = false;
#if DATABASES_ENABLED
allocate_database_manager_singleton = true;
#endif
}
RCPPFramework::~RCPPFramework() {
@ -91,6 +96,13 @@ void RCPPFramework::_do_initialize() {
backend_hash_hashlib_install_providers();
PlatformInitializer::allocate_all();
#if DATABASES_ENABLED
if (allocate_database_manager_singleton) {
DatabaseManager *dbm = new DatabaseManager();
manage_object(dbm);
}
#endif
}
void RCPPFramework::_do_uninitialize() {

View File

@ -1,8 +1,8 @@
#ifndef RCPP_FRAMEWORK_H
#define RCPP_FRAMEWORK_H
#include "core/string.h"
#include "core/containers/vector.h"
#include "core/string.h"
#include "core/object.h"
@ -30,6 +30,10 @@ public:
static RCPPFramework *get_singleton();
#if DATABASES_ENABLED
bool allocate_database_manager_singleton;
#endif
protected:
virtual void _do_initialize();
virtual void _do_uninitialize();