creates systems from information located in a config file
| 300 | |
| 301 | //creates systems from information located in a config file |
| 302 | bool SystemData::loadConfig(Window* window) { |
| 303 | deleteSystems(); |
| 304 | |
| 305 | std::string path = getConfigPath(false); |
| 306 | |
| 307 | NYMPH_LOG_INFORMATION("Loading system config file " + path + "..."); |
| 308 | |
| 309 | if (!Utils::FileSystem::exists(path)) { |
| 310 | //LOG(LogError) << "es_systems.cfg file does not exist!"; |
| 311 | NYMPH_LOG_ERROR("es_systems.cfg file does not exist!"); |
| 312 | writeExampleConfig(getConfigPath(true)); |
| 313 | return false; |
| 314 | } |
| 315 | |
| 316 | pugi::xml_document doc; |
| 317 | pugi::xml_parse_result res = doc.load_file(path.c_str()); |
| 318 | |
| 319 | NYMPH_LOG_DEBUG("Loaded config file."); |
| 320 | |
| 321 | if (!res) { |
| 322 | //LOG(LogError) << "Could not parse es_systems.cfg file!"; |
| 323 | NYMPH_LOG_ERROR("Could not parse es_systems.cfg file!"); |
| 324 | //LOG(LogError) << res.description(); |
| 325 | NYMPH_LOG_ERROR(res.description()); |
| 326 | return false; |
| 327 | } |
| 328 | |
| 329 | NYMPH_LOG_DEBUG("Reading system list..."); |
| 330 | |
| 331 | //actually read the file |
| 332 | pugi::xml_node systemList = doc.child("systemList"); |
| 333 | |
| 334 | NYMPH_LOG_DEBUG("Read system list."); |
| 335 | |
| 336 | if (!systemList) { |
| 337 | //LOG(LogError) << "es_systems.cfg is missing the <systemList> tag!"; |
| 338 | NYMPH_LOG_ERROR("es_systems.cfg is missing the <systemList> tag!"); |
| 339 | return false; |
| 340 | } |
| 341 | |
| 342 | std::vector<std::string> systemsNames; |
| 343 | int systemCount = 0; |
| 344 | for (pugi::xml_node system = systemList.child("system"); system; system = system.next_sibling("system")) |
| 345 | { |
| 346 | systemsNames.push_back(system.child("fullname").text().get()); |
| 347 | systemCount++; |
| 348 | } |
| 349 | |
| 350 | NYMPH_LOG_INFORMATION("Found " + Poco::NumberFormatter::format(systemCount) + " system(s)."); |
| 351 | |
| 352 | |
| 353 | typedef SystemData* SystemDataPtr; |
| 354 | |
| 355 | ThreadPool* pThreadPool = NULL; |
| 356 | SystemDataPtr* systems = NULL; |
| 357 | NYMPH_LOG_DEBUG("Settings value..."); |
| 358 | bool threadedLoading = Settings::getInstance()->getBool("ThreadedLoading"); |
| 359 | NYMPH_LOG_DEBUG("Threaded loading: " + Poco::NumberFormatter::format(threadedLoading)); |
nothing calls this directly
no test coverage detected