mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
refs #358, interface for mapping readers
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
|
||||
#include "simulatormodelmappings.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackSim
|
||||
{
|
||||
|
||||
@@ -24,19 +27,26 @@ namespace BlackSim
|
||||
return this->m_mappings.isEmpty();
|
||||
}
|
||||
|
||||
const BlackMisc::Network::CAircraftMappingList &ISimulatorModelMappings::getMappingList() const
|
||||
const CAircraftMappingList &ISimulatorModelMappings::getMappingList() const
|
||||
{
|
||||
return this->m_mappings;
|
||||
}
|
||||
|
||||
BlackMisc::Network::CAircraftMappingList ISimulatorModelMappings::findByIcaoWildcard(const BlackMisc::Aviation::CAircraftIcao &icao) const
|
||||
int ISimulatorModelMappings::synchronizeWithExistingModels(const QStringList &modelNames, Qt::CaseSensitivity cs)
|
||||
{
|
||||
return this->m_mappings.findByIcaoCodeWildcard(icao);
|
||||
}
|
||||
|
||||
BlackMisc::Network::CAircraftMappingList ISimulatorModelMappings::findByIcaoExact(const BlackMisc::Aviation::CAircraftIcao &icao) const
|
||||
{
|
||||
return this->m_mappings.findByIcaoCodeExact(icao);
|
||||
if (modelNames.isEmpty() || this->m_mappings.isEmpty()) { return this->m_mappings.size(); }
|
||||
CAircraftMappingList newList;
|
||||
foreach(CAircraftMapping mapping, this->m_mappings)
|
||||
{
|
||||
QString modelString = mapping.getModel().getModelString();
|
||||
if (modelString.isEmpty()) { continue; }
|
||||
if (modelNames.contains(modelString, cs))
|
||||
{
|
||||
newList.push_back(mapping);
|
||||
}
|
||||
}
|
||||
this->m_mappings = newList;
|
||||
return this->m_mappings.size();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
|
||||
namespace BlackSim
|
||||
{
|
||||
//! Model mappings
|
||||
//! Model mappings interface, different mapping readers (e.g. from database, from vPilot data files)
|
||||
//! can implement this, but provide the same mapping list.
|
||||
class ISimulatorModelMappings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -30,7 +31,7 @@ namespace BlackSim
|
||||
virtual ~ISimulatorModelMappings() {}
|
||||
|
||||
//! Load data
|
||||
virtual bool load() = 0;
|
||||
virtual bool read() = 0;
|
||||
|
||||
//! Empty
|
||||
bool isEmpty() const;
|
||||
@@ -41,11 +42,8 @@ namespace BlackSim
|
||||
//! Get list
|
||||
const BlackMisc::Network::CAircraftMappingList &getMappingList() const;
|
||||
|
||||
//! Find by ICAO code, empty fields are treated as wildcards
|
||||
BlackMisc::Network::CAircraftMappingList findByIcaoWildcard(const BlackMisc::Aviation::CAircraftIcao &icao) const;
|
||||
|
||||
//! Find by ICAO code, empty fields are treated literally
|
||||
BlackMisc::Network::CAircraftMappingList findByIcaoExact(const BlackMisc::Aviation::CAircraftIcao &icao) const;
|
||||
//! Synchronize with existing model names, remove unneeded models
|
||||
int synchronizeWithExistingModels(const QStringList &modelNames, Qt::CaseSensitivity cs = Qt::CaseInsensitive);
|
||||
|
||||
protected:
|
||||
BlackMisc::Network::CAircraftMappingList m_mappings; //!< Mappings
|
||||
|
||||
Reference in New Issue
Block a user