mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Now the RCPPFramework singleton will allocate the DatabaseManager if databases are enabled by default.
This commit is contained in:
parent
20739e4aa0
commit
cf7458caaf
@ -3,6 +3,7 @@
|
|||||||
#include "core/error_macros.h"
|
#include "core/error_macros.h"
|
||||||
|
|
||||||
#if DATABASES_ENABLED
|
#if DATABASES_ENABLED
|
||||||
|
#include "database/database_manager.h"
|
||||||
#include "database_backends/db_init.h"
|
#include "database_backends/db_init.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -64,6 +65,10 @@ RCPPFramework::RCPPFramework() {
|
|||||||
_instance = this;
|
_instance = this;
|
||||||
|
|
||||||
_initialized = false;
|
_initialized = false;
|
||||||
|
|
||||||
|
#if DATABASES_ENABLED
|
||||||
|
allocate_database_manager_singleton = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
RCPPFramework::~RCPPFramework() {
|
RCPPFramework::~RCPPFramework() {
|
||||||
@ -91,6 +96,13 @@ void RCPPFramework::_do_initialize() {
|
|||||||
backend_hash_hashlib_install_providers();
|
backend_hash_hashlib_install_providers();
|
||||||
|
|
||||||
PlatformInitializer::allocate_all();
|
PlatformInitializer::allocate_all();
|
||||||
|
|
||||||
|
#if DATABASES_ENABLED
|
||||||
|
if (allocate_database_manager_singleton) {
|
||||||
|
DatabaseManager *dbm = new DatabaseManager();
|
||||||
|
manage_object(dbm);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void RCPPFramework::_do_uninitialize() {
|
void RCPPFramework::_do_uninitialize() {
|
||||||
|
@ -1,44 +1,48 @@
|
|||||||
#ifndef RCPP_FRAMEWORK_H
|
#ifndef RCPP_FRAMEWORK_H
|
||||||
#define RCPP_FRAMEWORK_H
|
#define RCPP_FRAMEWORK_H
|
||||||
|
|
||||||
#include "core/string.h"
|
|
||||||
#include "core/containers/vector.h"
|
#include "core/containers/vector.h"
|
||||||
|
#include "core/string.h"
|
||||||
|
|
||||||
#include "core/object.h"
|
#include "core/object.h"
|
||||||
|
|
||||||
class RCPPFramework : Object {
|
class RCPPFramework : Object {
|
||||||
RCPP_OBJECT(RCPPFramework, Object);
|
RCPP_OBJECT(RCPPFramework, Object);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Helper methods to allocate and destroy the singleton.
|
// Helper methods to allocate and destroy the singleton.
|
||||||
// Note that creating / deleting an instance manually in your app will also work.
|
// Note that creating / deleting an instance manually in your app will also work.
|
||||||
static void create();
|
static void create();
|
||||||
static void destroy();
|
static void destroy();
|
||||||
//Usie these if you don't want to mess with the default settings.
|
// Usie these if you don't want to mess with the default settings.
|
||||||
static void create_and_init();
|
static void create_and_init();
|
||||||
static void create_and_init(int argc, char **argv, char **envp);
|
static void create_and_init(int argc, char **argv, char **envp);
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
void uninitialize();
|
void uninitialize();
|
||||||
|
|
||||||
void setup_args(int argc, char **argv, char **envp);
|
void setup_args(int argc, char **argv, char **envp);
|
||||||
|
|
||||||
void manage_object(Object* obj);
|
void manage_object(Object *obj);
|
||||||
|
|
||||||
RCPPFramework();
|
RCPPFramework();
|
||||||
~RCPPFramework();
|
~RCPPFramework();
|
||||||
|
|
||||||
static RCPPFramework *get_singleton();
|
static RCPPFramework *get_singleton();
|
||||||
|
|
||||||
|
#if DATABASES_ENABLED
|
||||||
|
bool allocate_database_manager_singleton;
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void _do_initialize();
|
virtual void _do_initialize();
|
||||||
virtual void _do_uninitialize();
|
virtual void _do_uninitialize();
|
||||||
|
|
||||||
bool _initialized;
|
bool _initialized;
|
||||||
|
|
||||||
Vector<Object *> _managed_objects;
|
Vector<Object *> _managed_objects;
|
||||||
|
|
||||||
static RCPPFramework *_instance;
|
static RCPPFramework *_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user