From 7ed2cc649b8d66061c5875a0d98e712a2c82fe1d Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 4 Apr 2016 12:48:14 +0200 Subject: [PATCH] refs #614, removed IModelMappingsProvider + adjustments --- samples/blackmiscsim/samplesmodelmapping.cpp | 15 ++--- .../fscommon/modelmappingsprovidervpilot.cpp | 43 ------------ .../fscommon/modelmappingsprovidervpilot.h | 51 -------------- .../simulation/modelmappingsprovider.cpp | 37 ----------- .../simulation/modelmappingsprovider.h | 66 ------------------- 5 files changed, 7 insertions(+), 205 deletions(-) delete mode 100644 src/blackmisc/simulation/fscommon/modelmappingsprovidervpilot.cpp delete mode 100644 src/blackmisc/simulation/fscommon/modelmappingsprovidervpilot.h delete mode 100644 src/blackmisc/simulation/modelmappingsprovider.cpp delete mode 100644 src/blackmisc/simulation/modelmappingsprovider.h diff --git a/samples/blackmiscsim/samplesmodelmapping.cpp b/samples/blackmiscsim/samplesmodelmapping.cpp index 5b828e45f..b5bd6d32f 100644 --- a/samples/blackmiscsim/samplesmodelmapping.cpp +++ b/samples/blackmiscsim/samplesmodelmapping.cpp @@ -15,7 +15,7 @@ #include "blackmisc/stringutils.h" #include "blackmisc/sampleutils.h" #include "blackmisc/simulation/fscommon/aircraftcfgparser.h" -#include "blackmisc/simulation/fscommon/modelmappingsprovidervpilot.h" +#include "blackmisc/simulation/fscommon/vpilotrulesreader.h" #include "blackmisc/simulation/aircraftmatcher.h" #include @@ -32,11 +32,10 @@ namespace BlackSample void CSamplesModelMapping::samples(QTextStream &streamOut, QTextStream &streamIn) { BlackMisc::registerMetadata(); - - std::unique_ptr cvm(new CModelMappingsProviderVPilot(true)); - bool s = cvm->read(); + CVPilotRulesReader vpRulesReader; + bool s = vpRulesReader.read(true); streamOut << "directory: " << CVPilotRulesReader::standardMappingsDirectory() << endl; - streamOut << "loaded: " << BlackMisc::boolToYesNo(s) << " size: " << cvm->getMatchingModels().size() << endl; + streamOut << "loaded: " << BlackMisc::boolToYesNo(s) << " size: " << vpRulesReader.getAsModelsFromCache().size() << endl; // mapper with rule set, handing over ownership QString fsxDir = CSampleUtils::selectDirectory( @@ -59,11 +58,11 @@ namespace BlackSample streamOut << "Ambigious models: " << cfgParser.getAircraftCfgEntriesList().detectAmbiguousTitles().join(", ") << endl; // sync definitions, remove redundant ones - CAircraftMatcher matcher(CAircraftMatcher::AllModes); - matcher.setModelMappingProvider(std::move(cvm)); + CAircraftMatcher matcher(CAircraftMatcher::All); + matcher.setModelSet(vpRulesReader.getAsModelsFromCache()); CAircraftIcaoCode icao("C172"); streamOut << "Searching for " << icao << endl; - streamOut << matcher.getMatchingModels().findByIcaoDesignators(icao, CAirlineIcaoCode()) << endl; + streamOut << matcher.getModelSet().findByIcaoDesignators(icao, CAirlineIcaoCode()) << endl; } } // namespace diff --git a/src/blackmisc/simulation/fscommon/modelmappingsprovidervpilot.cpp b/src/blackmisc/simulation/fscommon/modelmappingsprovidervpilot.cpp deleted file mode 100644 index e0952881f..000000000 --- a/src/blackmisc/simulation/fscommon/modelmappingsprovidervpilot.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2013 - * swift Project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#include "modelmappingsprovidervpilot.h" - -#include -#include -#include - -using namespace BlackMisc::Network; - -namespace BlackMisc -{ - namespace Simulation - { - namespace FsCommon - { - CModelMappingsProviderVPilot::CModelMappingsProviderVPilot(bool standardDirectory, QObject *parent) : - IModelMappingsProvider(parent), - m_vPilotReader(new CVPilotRulesReader(standardDirectory, this)) - { - // void - } - - bool CModelMappingsProviderVPilot::read() - { - Q_ASSERT_X(this->m_vPilotReader, Q_FUNC_INFO, "missing reader"); - bool success = this->m_vPilotReader->read(false); - if (success) - { - this->m_mappingModels = this->m_vPilotReader->getAsModels(); - } - return success; - } - } // namespace - } // namespace -} // namespace diff --git a/src/blackmisc/simulation/fscommon/modelmappingsprovidervpilot.h b/src/blackmisc/simulation/fscommon/modelmappingsprovidervpilot.h deleted file mode 100644 index 87e144810..000000000 --- a/src/blackmisc/simulation/fscommon/modelmappingsprovidervpilot.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \file - -#ifndef BLACKMISC_SIMULATION_FSCOMMON_VPILOTMODELMAPPINGS_H -#define BLACKMISC_SIMULATION_FSCOMMON_VPILOTMODELMAPPINGS_H - -#include "blackmisc/blackmiscexport.h" -#include "blackmisc/simulation/modelmappingsprovider.h" -#include "blackmisc/simulation/fscommon/vpilotrulesreader.h" -#include -#include - -namespace BlackMisc -{ - namespace Simulation - { - namespace FsCommon - { - //! Model mappings - class BLACKMISC_EXPORT CModelMappingsProviderVPilot : public IModelMappingsProvider - { - public: - //! Constructor - CModelMappingsProviderVPilot(bool standardDirectory, QObject *parent = nullptr); - - //! Destructor - virtual ~CModelMappingsProviderVPilot() {} - - //! \copydoc IModelMappingsProvider::getMatchingModels - virtual CAircraftModelList getMatchingModels() const override { return this->m_mappingModels; } - - public slots: - //! Load data - virtual bool read() override; - - private: - QScopedPointer m_vPilotReader; //!< used vPilot model reader - BlackMisc::Simulation::CAircraftModelList m_mappingModels; //!< models - }; - } // namespace - } // namespace -} // namespace -#endif // guard diff --git a/src/blackmisc/simulation/modelmappingsprovider.cpp b/src/blackmisc/simulation/modelmappingsprovider.cpp deleted file mode 100644 index f0e6cadab..000000000 --- a/src/blackmisc/simulation/modelmappingsprovider.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#include "modelmappingsprovider.h" - -using namespace BlackMisc; -using namespace BlackMisc::Simulation; - -namespace BlackMisc -{ - namespace Simulation - { - IModelMappingsProvider::IModelMappingsProvider(QObject *parent) : QObject(parent) {} - - CachedModelSetProvider::CachedModelSetProvider(const CSimulatorInfo &simulator, QObject *parent) : - IModelMappingsProvider(parent), m_simulator(simulator) - { } - - CAircraftModelList CachedModelSetProvider::getMatchingModels() const - { - return this->m_modelSets.getModels(this->m_simulator); - } - - bool CachedModelSetProvider::read() - { - this->m_modelSets.syncronize(this->m_simulator); - return true; - } - - } // namespace -} // namespace diff --git a/src/blackmisc/simulation/modelmappingsprovider.h b/src/blackmisc/simulation/modelmappingsprovider.h deleted file mode 100644 index 12163d793..000000000 --- a/src/blackmisc/simulation/modelmappingsprovider.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (C) 2013 - * swift Project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \file - -#ifndef BLACKMISC_SIMULATION_MODELMAPPINGS_H -#define BLACKMISC_SIMULATION_MODELMAPPINGS_H - -#include "blackmisc/blackmiscexport.h" -#include "blackmisc/simulation/data/modelcaches.h" -#include - -namespace BlackMisc -{ - namespace Simulation - { - //! Model mappings interface, different mapping readers (e.g. from database, from vPilot data files) - //! can implement this, but provide the same mapping list. - class BLACKMISC_EXPORT IModelMappingsProvider : public QObject - { - Q_OBJECT - - public: - //! Constructor - IModelMappingsProvider(QObject *parent = nullptr); - - //! Destructor - virtual ~IModelMappingsProvider() {} - - //! Load data - virtual bool read() = 0; - - //! Get list of models used - virtual CAircraftModelList getMatchingModels() const = 0; - - protected: - BlackMisc::Simulation::CAircraftModelList m_mappingModels; //!< models - }; - - //! Implementation of a provider based on the model set cache - class BLACKMISC_EXPORT CachedModelSetProvider : public IModelMappingsProvider - { - public: - //! Constructor - CachedModelSetProvider(const BlackMisc::Simulation::CSimulatorInfo &simulator, QObject *parent = nullptr); - - //! \copydoc IModelMappingsProvider::getMatchingModels - virtual CAircraftModelList getMatchingModels() const override; - - //! \copydoc IModelMappingsProvider::read - virtual bool read() override; - - private: - BlackMisc::Simulation::Data::CModelSetCaches m_modelSets { this }; - BlackMisc::Simulation::CSimulatorInfo m_simulator; - }; - } // ns -} // ns - -#endif // guard