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

@ -19,11 +19,14 @@ public:
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 initialize(int argc, char **argv, char **envp); void initialize(int argc, char **argv, char **envp);
void uninitialize(); void uninitialize();
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();
@ -31,22 +34,22 @@ public:
static RCPPFramework *get_singleton(); static RCPPFramework *get_singleton();
bool allocate_settings_singleton; bool allocate_settings_singleton;
#if DATABASES_ENABLED #if DATABASES_ENABLED
bool allocate_database_manager_singleton; bool allocate_database_manager_singleton;
// TODO Need a define for this // TODO Need a define for this
bool allocate_db_settings_singleton; bool allocate_db_settings_singleton;
#endif #endif
#if WEB_ENABLED #if WEB_ENABLED
bool allocate_session_manager_singleton; bool allocate_session_manager_singleton;
bool allocate_file_cache_singleton; bool allocate_file_cache_singleton;
// By default it's set to "". // By default it's set to "".
// It will be ignored if you leave it. // It will be ignored if you leave it.
String www_root; String www_root;
#endif #endif
protected: protected: