From 3acb88de959f7b88f6dd883144e936f0c4dedc25 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Tue, 31 Mar 2015 10:31:48 +0300 Subject: core: moved on_modules_loaded call to later stage so modules actually can call other modules without race condition and exceptions implemented default metadata_storage basic settings //TODO: per module metadata storage modules: finished flat metadata module base implementation set,get,remove now working and tested via core, via modules --- server/src/main.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'server/src/main.cpp') diff --git a/server/src/main.cpp b/server/src/main.cpp index 8cf9efc..13b291b 100644 --- a/server/src/main.cpp +++ b/server/src/main.cpp @@ -116,11 +116,47 @@ int main(int argc, char *argv[]) } if(run) { + if(!module_api) + module_api = new core_api; + if(!modules) + { + modules = new modules_handler; + modules->load_modules(); + } + + std::string default_metadata_module_name = runtime_config.config_file.get("default_metadata_module", ""); + if(default_metadata_module_name == "") + { + if(!modules->get_metadata_modules().empty()) + runtime_config.default_metadata_storage = static_cast(*(modules->get_metadata_modules().begin())); + else + std::cerr<<"Error: Metadata storage modules not installed'n"; + } + else + { + for(auto i = modules->get_metadata_modules().begin(), end = modules->get_metadata_modules().end(); i != end; ++i) + { + if((*i)->get_module_info().name == default_metadata_module_name) + runtime_config.default_metadata_storage = static_cast(*i); + } + if(!runtime_config.default_metadata_storage) + { + std::cerr<<"Error: Failed to load metadata storage module named \""<on_modules_loaded(); //call second initialization stage in modules + if(daemon) { //TODO: fork here } //TODO: run here + return 0; //stub for now } std::cerr<<"error: no command specified"<