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:
Relintai 2022-02-05 19:29:20 +01:00
parent ea6ae6ad41
commit aad59b53c3
2 changed files with 45 additions and 14 deletions

View File

@ -67,9 +67,42 @@ void RCPPFramework::uninitialize() {
delete _instance; 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) { void RCPPFramework::manage_object(Object *obj) {
ERR_FAIL_COND(!_initialized); ERR_FAIL_COND(!_initialized);
ERR_FAIL_COND(obj); ERR_FAIL_COND(!obj);
_managed_objects.push_back(obj); _managed_objects.push_back(obj);
} }
@ -152,11 +185,6 @@ void RCPPFramework::_do_initialize() {
if (allocate_file_cache_singleton) { if (allocate_file_cache_singleton) {
FileCache *file_cache = new FileCache(true); FileCache *file_cache = new FileCache(true);
manage_object(file_cache); manage_object(file_cache);
if (www_root != "") {
file_cache->wwwroot = www_root;
file_cache->wwwroot_refresh_cache();
}
} }
#endif #endif
} }

View File

@ -24,6 +24,9 @@ public:
void setup_args(int argc, char **argv, char **envp); void setup_args(int argc, char **argv, char **envp);
virtual void load();
virtual void migrate();
void manage_object(Object *obj); void manage_object(Object *obj);
RCPPFramework(); RCPPFramework();