From 5651ec0f806950f3326bed97ac18835d71ef386b Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 23 Mar 2016 03:20:50 +0100 Subject: [PATCH] refs #619, removed redundant set method for cache in loader --- src/blackgui/menus/aircraftmodelmenus.cpp | 4 ++-- .../simulation/aircraftmodelloader.cpp | 11 +++------- .../simulation/aircraftmodelloader.h | 22 +++++++++---------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/blackgui/menus/aircraftmodelmenus.cpp b/src/blackgui/menus/aircraftmodelmenus.cpp index 2b6b0a6aa..b6025ac0b 100644 --- a/src/blackgui/menus/aircraftmodelmenus.cpp +++ b/src/blackgui/menus/aircraftmodelmenus.cpp @@ -107,7 +107,7 @@ namespace BlackGui mv->updateContainerMaybeAsync(models); if (this->m_loader) { - this->m_loader->replaceCacheWithModelData(models); + this->m_loader->setModelsInCache(models); } } @@ -126,7 +126,7 @@ namespace BlackGui mv->replaceOrAddModelsWithString(models); if (this->m_loader) { - this->m_loader->replaceCacheWithModelData(models); + this->m_loader->setModelsInCache(models); } } } // ns diff --git a/src/blackmisc/simulation/aircraftmodelloader.cpp b/src/blackmisc/simulation/aircraftmodelloader.cpp index 1b0250a02..e038677df 100644 --- a/src/blackmisc/simulation/aircraftmodelloader.cpp +++ b/src/blackmisc/simulation/aircraftmodelloader.cpp @@ -56,14 +56,14 @@ namespace BlackMisc return true; } - CStatusMessage IAircraftModelLoader::replaceCacheWithModelData(const CAircraftModelList &models, const CSimulatorInfo &simulator) + CStatusMessage IAircraftModelLoader::setModelsInCache(const CAircraftModelList &models, const CSimulatorInfo &simulator) { const CSimulatorInfo sim = simulator.isSingleSimulator() ? simulator : this->m_simulatorInfo; if (!sim.isSingleSimulator()) { return CStatusMessage(this, CStatusMessage::SeverityError, "Invalid simuataor"); } const CStatusMessage m(this->m_caches.setModels(models, sim)); if (m.isSeverityInfoOrLess()) { - // set is asny + // set is asynchronous // emit loadingFinished(true, sim); } return m; @@ -78,7 +78,7 @@ namespace BlackMisc int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive); if (c > 0) { - return this->replaceCacheWithModelData(models, sim); + return this->setModelsInCache(models, sim); } else { @@ -121,11 +121,6 @@ namespace BlackMisc return !this->m_caches.getModels(this->m_simulatorInfo).isEmpty(); } - CStatusMessage IAircraftModelLoader::setModelsInCache(const CAircraftModelList &models) - { - return this->m_caches.setModels(models, this->m_simulatorInfo); - } - CStatusMessage IAircraftModelLoader::clearCache() { return this->setModelsInCache(CAircraftModelList()); diff --git a/src/blackmisc/simulation/aircraftmodelloader.h b/src/blackmisc/simulation/aircraftmodelloader.h index c5be3dec6..3270c849f 100644 --- a/src/blackmisc/simulation/aircraftmodelloader.h +++ b/src/blackmisc/simulation/aircraftmodelloader.h @@ -65,6 +65,7 @@ namespace BlackMisc virtual bool isLoadingFinished() const = 0; //! The loaded models + //! \threadsafe BlackMisc::Simulation::CAircraftModelList getAircraftModels() const; //! Count of loaded models @@ -99,11 +100,11 @@ namespace BlackMisc public slots: //! Set cache from outside, this should only be used in special cases. - //! But it allows to modify data elsewhere nd update the cache with manipulated data. - BlackMisc::CStatusMessage replaceCacheWithModelData(const CAircraftModelList &models, const CSimulatorInfo &simulator = CSimulatorInfo()); + //! But it allows to modify data elsewhere and update the cache with manipulated data. + BlackMisc::CStatusMessage setModelsInCache(const CAircraftModelList &models, const CSimulatorInfo &simulator = CSimulatorInfo()); //! Set cache from outside, this should only be used in special cases. - //! But it allows to modify data elsewhere nd update the cache with manipulated data. + //! But it allows to modify data elsewhere and update the cache with manipulated data. BlackMisc::CStatusMessage replaceOrAddModelsInCache(const CAircraftModelList &models, const CSimulatorInfo &simulator = CSimulatorInfo()); signals: @@ -123,9 +124,6 @@ namespace BlackMisc //! Any cached data? bool hasCachedData() const; - //! Set models in cache - BlackMisc::CStatusMessage setModelsInCache(const BlackMisc::Simulation::CAircraftModelList &models); - //! Clear cache BlackMisc::CStatusMessage clearCache(); @@ -135,12 +133,12 @@ namespace BlackMisc //! Start the loading process from disk virtual void startLoadingFromDisk(LoadMode mode, const BlackMisc::Simulation::CAircraftModelList &dbModels) = 0; - BlackMisc::Simulation::CSimulatorInfo m_simulatorInfo; //!< Corresponding simulator - std::atomic m_cancelLoading { false }; //!< flag - std::atomic m_loadingInProgress { false }; //!< Loading in progress - QString m_rootDirectory; //!< root directory parsing aircraft.cfg files - QStringList m_excludedDirectories; //!< directories not to be parsed - BlackMisc::Simulation::Data::CModelCaches m_caches { this }; //!< caches + BlackMisc::Simulation::CSimulatorInfo m_simulatorInfo; //!< Corresponding simulator + std::atomic m_cancelLoading { false }; //!< flag + std::atomic m_loadingInProgress { false }; //!< Loading in progress + QString m_rootDirectory; //!< root directory parsing aircraft.cfg files + QStringList m_excludedDirectories; //!< directories not to be parsed + BlackMisc::Simulation::Data::CModelCaches m_caches { this }; //!< caches protected slots: //! Loading finished