mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
Ref T111, added utility functions used for swift plugin (dummy driver)
* new reader functions * plugin info
This commit is contained in:
committed by
Mathew Sutcliffe
parent
29e1d54e05
commit
b1295cd457
@@ -34,6 +34,11 @@ namespace BlackCore
|
||||
return m_airportCache.get();
|
||||
}
|
||||
|
||||
CAirport CAirportDataReader::getAirportForIcaoDesignator(const QString &designator) const
|
||||
{
|
||||
return getAirports().findByIcao(CAirportIcaoCode(designator)).frontOrDefault();
|
||||
}
|
||||
|
||||
int CAirportDataReader::getAirportsCount() const
|
||||
{
|
||||
return this->getAirports().size();
|
||||
|
||||
@@ -38,6 +38,10 @@ namespace BlackCore
|
||||
//! \threadsafe
|
||||
BlackMisc::Aviation::CAirportList getAirports() const;
|
||||
|
||||
//! Returns airport for designator (or default)
|
||||
//! \threadsafe
|
||||
BlackMisc::Aviation::CAirport getAirportForIcaoDesignator(const QString &designator) const;
|
||||
|
||||
//! Returns a list of all airports in the database.
|
||||
//! \threadsafe
|
||||
int getAirportsCount() const;
|
||||
|
||||
@@ -523,9 +523,9 @@ namespace BlackCore
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
QStringList CWebDataServices::getModelCompleterStrings(bool sorted) const
|
||||
QStringList CWebDataServices::getModelCompleterStrings(bool sorted, const CSimulatorInfo &simulator) const
|
||||
{
|
||||
if (m_modelDataReader) { return m_modelDataReader->getModels().toCompleterStrings(sorted); }
|
||||
if (m_modelDataReader) { return m_modelDataReader->getModels().toCompleterStrings(sorted, simulator); }
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
@@ -666,6 +666,12 @@ namespace BlackCore
|
||||
return 0;
|
||||
}
|
||||
|
||||
CAirport CWebDataServices::getAirportForIcaoDesignator(const QString &icao) const
|
||||
{
|
||||
if (m_airportDataReader) { return m_airportDataReader->getAirportForIcaoDesignator(icao); }
|
||||
return CAirport();
|
||||
}
|
||||
|
||||
CCountry CWebDataServices::getCountryForIsoCode(const QString &iso) const
|
||||
{
|
||||
if (m_icaoDataReader) { return m_icaoDataReader->getCountryForIsoCode(iso); }
|
||||
|
||||
@@ -223,7 +223,7 @@ namespace BlackCore
|
||||
|
||||
//! Model completer string
|
||||
//! \threadsafe
|
||||
QStringList getModelCompleterStrings(bool sorted = true) const;
|
||||
QStringList getModelCompleterStrings(bool sorted = true, const BlackMisc::Simulation::CSimulatorInfo &simulator = { BlackMisc::Simulation::CSimulatorInfo::All }) const;
|
||||
|
||||
//! Models for combined code and aircraft designator
|
||||
//! \threadsafe
|
||||
@@ -313,6 +313,10 @@ namespace BlackCore
|
||||
//! \threadsafe
|
||||
int getAirportsCount() const;
|
||||
|
||||
//! Get airport for ICAO designator
|
||||
//! \threadsafe
|
||||
BlackMisc::Aviation::CAirport getAirportForIcaoDesignator(const QString &icao) const;
|
||||
|
||||
//! Get METARs
|
||||
//! \threadsafe
|
||||
BlackMisc::Weather::CMetarList getMetars() const;
|
||||
|
||||
@@ -693,13 +693,16 @@ namespace BlackMisc
|
||||
return scoreMap;
|
||||
}
|
||||
|
||||
QStringList CAircraftModelList::toCompleterStrings(bool sorted) const
|
||||
QStringList CAircraftModelList::toCompleterStrings(bool sorted, const CSimulatorInfo &simulator) const
|
||||
{
|
||||
QStringList c;
|
||||
c.reserve(size());
|
||||
for (const CAircraftModel &model : *this)
|
||||
{
|
||||
c.append(model.getModelString());
|
||||
if (model.getSimulator().matchesAny(simulator))
|
||||
{
|
||||
c.append(model.getModelString());
|
||||
}
|
||||
}
|
||||
if (sorted) { c.sort(); }
|
||||
return c;
|
||||
|
||||
@@ -259,7 +259,7 @@ namespace BlackMisc
|
||||
ScoredModels scoreFull(const CAircraftModel &remoteModel, bool preferColorLiveries, bool ignoreZeroScores = true, CStatusMessageList *log = nullptr) const;
|
||||
|
||||
//! Completer strings
|
||||
QStringList toCompleterStrings(bool sorted = true) const;
|
||||
QStringList toCompleterStrings(bool sorted = true, const BlackMisc::Simulation::CSimulatorInfo &simulator = { BlackMisc::Simulation::CSimulatorInfo::All }) const;
|
||||
|
||||
//! Validate for publishing
|
||||
CStatusMessageList validateForPublishing() const;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace BlackMisc
|
||||
|
||||
void CSimulatorPluginInfo::convertFromJson(const QJsonObject &json)
|
||||
{
|
||||
if (json.contains("IID")) // comes from the plugin
|
||||
if (json.contains("IID")) // comes from the plugin
|
||||
{
|
||||
if (! json.contains("MetaData")) { throw CJsonException("Missing 'MetaData'"); }
|
||||
|
||||
@@ -45,6 +45,16 @@ namespace BlackMisc
|
||||
return m_identifier.isEmpty();
|
||||
}
|
||||
|
||||
CSimulatorInfo CSimulatorPluginInfo::getSimulatorInfo() const
|
||||
{
|
||||
return CSimulatorInfo(getSimulator());
|
||||
}
|
||||
|
||||
bool CSimulatorPluginInfo::isSwiftPlugin() const
|
||||
{
|
||||
return this->getIdentifier() == swiftPluginIndentifier();
|
||||
}
|
||||
|
||||
QString CSimulatorPluginInfo::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
@@ -75,6 +85,12 @@ namespace BlackMisc
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &CSimulatorPluginInfo::swiftPluginIndentifier()
|
||||
{
|
||||
static const QString s("org.swift-project.plugins.simulator.swift");
|
||||
return s;
|
||||
}
|
||||
|
||||
const QStringList &CSimulatorPluginInfo::allIdentifiers()
|
||||
{
|
||||
static const QStringList identifiers(
|
||||
@@ -82,7 +98,8 @@ namespace BlackMisc
|
||||
fsxPluginIndentifier(),
|
||||
p3dPluginIndentifier(),
|
||||
xplanePluginIndentifier(),
|
||||
fs9PluginIndentifier()
|
||||
fs9PluginIndentifier(),
|
||||
swiftPluginIndentifier()
|
||||
});
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef BLACKMISC_SIMULATION_SIMULATORPLUGININFO_H
|
||||
#define BLACKMISC_SIMULATION_SIMULATORPLUGININFO_H
|
||||
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
@@ -58,6 +59,12 @@ namespace BlackMisc
|
||||
//! Simulator
|
||||
const QString &getSimulator() const { return m_simulator; }
|
||||
|
||||
//! Simulator info object
|
||||
BlackMisc::Simulation::CSimulatorInfo getSimulatorInfo() const;
|
||||
|
||||
//! Is this the pseudo swift driver?
|
||||
bool isSwiftPlugin() const;
|
||||
|
||||
//! Description
|
||||
const QString &getDescription() const { return m_description; }
|
||||
|
||||
@@ -76,6 +83,9 @@ namespace BlackMisc
|
||||
//! Plugin identifier (XPlane)
|
||||
static const QString &xplanePluginIndentifier();
|
||||
|
||||
//! Plugin identifier (swift pseudo driver)
|
||||
static const QString &swiftPluginIndentifier();
|
||||
|
||||
//! All valid identifiers
|
||||
static const QStringList &allIdentifiers();
|
||||
|
||||
|
||||
@@ -38,5 +38,14 @@ namespace BlackMisc
|
||||
{
|
||||
return this->findFirstByOrDefault(&CSimulatorPluginInfo::getIdentifier, identifier);
|
||||
}
|
||||
|
||||
CSimulatorPluginInfo CSimulatorPluginInfoList::findBySimulator(const CSimulatorInfo &simulator) const
|
||||
{
|
||||
for (const CSimulatorPluginInfo &info : *this)
|
||||
{
|
||||
if (info.getSimulatorInfo() == simulator) { return info; }
|
||||
}
|
||||
return CSimulatorPluginInfo();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
#define BLACKMISC_SIMULATION_SIMULATORPLUGININFOLIST_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <QMetaType>
|
||||
@@ -50,6 +51,9 @@ namespace BlackMisc
|
||||
|
||||
//! Find by identifier (unique)
|
||||
CSimulatorPluginInfo findByIdentifier(const QString &identifier) const;
|
||||
|
||||
//! Find by simulator
|
||||
CSimulatorPluginInfo findBySimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -234,10 +234,10 @@ namespace BlackMisc
|
||||
* the derived class uses this macro to disambiguate the inherited members.
|
||||
*/
|
||||
# define BLACKMISC_DECLARE_USING_MIXIN_STRING(DERIVED) \
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::toQString; \
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::toFormattedQString; \
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::toStdString; \
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::stringForStreaming;
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::toQString; \
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::toFormattedQString; \
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::toStdString; \
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::stringForStreaming;
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
|
||||
Reference in New Issue
Block a user