mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
Added load anf migrate methods to RCPPFramework, so it can call it's managed singleton's related methods easily. Also Moved www root evaluation to load().
This commit is contained in:
parent
ea6ae6ad41
commit
aad59b53c3
@ -67,9 +67,42 @@ void RCPPFramework::uninitialize() {
|
||||
delete _instance;
|
||||
}
|
||||
|
||||
void RCPPFramework::load() {
|
||||
#if DATABASES_ENABLED
|
||||
if (allocate_settings_singleton && allocate_db_settings_singleton) {
|
||||
DBSettings::get_singleton()->load();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WEB_ENABLED
|
||||
if (allocate_session_manager_singleton) {
|
||||
::SessionManager::get_singleton()->load_sessions();
|
||||
}
|
||||
|
||||
if (allocate_file_cache_singleton && www_root != "") {
|
||||
FileCache::get_singleton()->wwwroot = www_root;
|
||||
FileCache::get_singleton()->wwwroot_refresh_cache();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RCPPFramework::migrate() {
|
||||
#if DATABASES_ENABLED
|
||||
if (allocate_settings_singleton && allocate_db_settings_singleton) {
|
||||
DBSettings::get_singleton()->migrate();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WEB_ENABLED
|
||||
if (allocate_session_manager_singleton) {
|
||||
::SessionManager::get_singleton()->migrate();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RCPPFramework::manage_object(Object *obj) {
|
||||
ERR_FAIL_COND(!_initialized);
|
||||
ERR_FAIL_COND(obj);
|
||||
ERR_FAIL_COND(!obj);
|
||||
|
||||
_managed_objects.push_back(obj);
|
||||
}
|
||||
@ -152,11 +185,6 @@ void RCPPFramework::_do_initialize() {
|
||||
if (allocate_file_cache_singleton) {
|
||||
FileCache *file_cache = new FileCache(true);
|
||||
manage_object(file_cache);
|
||||
|
||||
if (www_root != "") {
|
||||
file_cache->wwwroot = www_root;
|
||||
file_cache->wwwroot_refresh_cache();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -19,11 +19,14 @@ public:
|
||||
static void create_and_init(int argc, char **argv, char **envp);
|
||||
|
||||
void initialize();
|
||||
void initialize(int argc, char **argv, char **envp);
|
||||
void initialize(int argc, char **argv, char **envp);
|
||||
void uninitialize();
|
||||
|
||||
void setup_args(int argc, char **argv, char **envp);
|
||||
|
||||
virtual void load();
|
||||
virtual void migrate();
|
||||
|
||||
void manage_object(Object *obj);
|
||||
|
||||
RCPPFramework();
|
||||
@ -31,22 +34,22 @@ public:
|
||||
|
||||
static RCPPFramework *get_singleton();
|
||||
|
||||
bool allocate_settings_singleton;
|
||||
bool allocate_settings_singleton;
|
||||
|
||||
#if DATABASES_ENABLED
|
||||
bool allocate_database_manager_singleton;
|
||||
|
||||
// TODO Need a define for this
|
||||
bool allocate_db_settings_singleton;
|
||||
// TODO Need a define for this
|
||||
bool allocate_db_settings_singleton;
|
||||
#endif
|
||||
|
||||
#if WEB_ENABLED
|
||||
bool allocate_session_manager_singleton;
|
||||
bool allocate_file_cache_singleton;
|
||||
bool allocate_file_cache_singleton;
|
||||
|
||||
// By default it's set to "".
|
||||
// It will be ignored if you leave it.
|
||||
String www_root;
|
||||
// By default it's set to "".
|
||||
// It will be ignored if you leave it.
|
||||
String www_root;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user