From 8372f086c156276579b0395ca3c3411832a93713 Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Fri, 10 Mar 2017 23:04:39 +0100 Subject: [PATCH] Add the lists of fix.dat and nav.dat files to the output of --json-report - Declare 'datTypeStr' and 'defaultDatFile' as public member variables of NavDataCache ('defaultDatFile' is not *required* for this commit, it just seems to make sense to treat both members the same way/keep them together in the source code). - New keys under "navigation data" in the JSON report: "fix.dat files" and "nav.dat files". --- src/Main/options.cxx | 23 ++++++++++++++--------- src/Navaids/NavDataCache.hxx | 17 +++++++++-------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 01691f07a..b285f495f 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -2696,22 +2696,27 @@ void Options::printJSONReport() const cJSON_AddStringToObject(configNode, "autosave file", globals->autosaveFilePath().utf8Str().c_str()); - // Get the ordered list of apt.dat files used by the NavCache + // Get the ordered lists of apt.dat, fix.dat and nav.dat files used by the + // NavCache NavDataCache* cache = NavDataCache::instance(); if (!cache) { cache = NavDataCache::createInstance(); } - // For this method, it doesn't matter if the cache is out-of-date - NavDataCache::DatFilesGroupInfo aptDatFilesInfo = - cache->getDatFilesInfo(NavDataCache::DATFILETYPE_APT); - - // Write the list to the JSON tree cJSON *navDataNode = cJSON_CreateObject(); cJSON_AddItemToObject(rootNode, "navigation data", navDataNode); - cJSON *aptDatPathsNode = p->createJSONArrayFromPathList( - aptDatFilesInfo.paths); - cJSON_AddItemToObject(navDataNode, "apt.dat files", aptDatPathsNode); + + // Write each list to the JSON tree + for (const auto& datType: {NavDataCache::DATFILETYPE_APT, + NavDataCache::DATFILETYPE_FIX, + NavDataCache::DATFILETYPE_NAV}) { + // For this method, it doesn't matter if the cache is out-of-date + const NavDataCache::DatFilesGroupInfo& datFilesInfo = + cache->getDatFilesInfo(datType); + cJSON *datPathsNode = p->createJSONArrayFromPathList(datFilesInfo.paths); + string key = NavDataCache::datTypeStr[datType] + ".dat files"; + cJSON_AddItemToObject(navDataNode, key.c_str(), datPathsNode); + } // Print the JSON tree to the standard output char *report = cJSON_Print(rootNode); diff --git a/src/Navaids/NavDataCache.hxx b/src/Navaids/NavDataCache.hxx index 67ee1f4bd..f2f5a9083 100644 --- a/src/Navaids/NavDataCache.hxx +++ b/src/Navaids/NavDataCache.hxx @@ -84,6 +84,15 @@ public: std::size_t totalSize; // total size of all these files, in bytes }; + // datTypeStr[DATFILETYPE_APT] = std::string("apt"), etc. This gives, + // among other things, the subdirectory of $scenery_path/NavData where + // each type of dat file is looked for. + static const std::string datTypeStr[]; + // defaultDatFile[DATFILETYPE_APT] = std::string("Airports/apt.dat.gz"), + // etc. This tells where to find the historical dat files: those under + // $FG_ROOT. + static const std::string defaultDatFile[]; + // Update d->datFilesInfo and legacy d->metarDatPath, d->poiDatPath, // etc. by looking into $scenery_path/NavData for each scenery path. void updateListsOfDatFiles(); @@ -328,14 +337,6 @@ private: void commitTransaction(); void abortTransaction(); - // datTypeStr[DATFILETYPE_APT] = std::string("apt"), etc. This gives, among - // other things, the subdirectory of $scenery_path/NavData where each type - // of dat file is looked for. - static const std::string datTypeStr[]; - // defaultDatFile[DATFILETYPE_APT] = std::string("Airports/apt.dat.gz"), etc. - // This tells where to find the historical dat files: those under $FG_ROOT. - static const std::string defaultDatFile[]; - class NavDataCachePrivate; std::unique_ptr d;