swift
Loading...
Searching...
No Matches
aircraftmatcher.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_CORE_AIRCRAFTMATCHER_H
7#define SWIFT_CORE_AIRCRAFTMATCHER_H
8
9#include <QObject>
10#include <QString>
11
20
21namespace swift::misc
22{
23 class CLogCategoryList;
25 namespace aviation
26 {
27 class CCallsign;
28 }
29 namespace simulation
30 {
31 class CSimulatedAircraft;
32 }
33} // namespace swift::misc
34
35namespace swift::core
36{
41 {
44
45 public:
47 static const QStringList &getLogCategories();
48
51
54
57 ~CAircraftMatcher() override;
58
61
64
67
70
76 getClosestMatch(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft,
77 swift::misc::simulation::MatchingLog whatToLog, swift::misc::CStatusMessageList *log,
78 bool useMatchingScript) const;
79
83 failoverValidAirlineIcaoDesignator(const swift::misc::aviation::CCallsign &callsign, const QString &primaryIcao,
84 const QString &secondaryIcao, bool airlineFromCallsign,
85 const QString &airlineName, const QString &airlineTelephony,
86 bool useWebServices, swift::misc::CStatusMessageList *log = nullptr);
87
91 static swift::misc::aviation::CAirlineIcaoCode failoverValidAirlineIcaoDesignator(
92 const swift::misc::aviation::CCallsign &callsign, const QString &primaryIcao, const QString &secondaryIcao,
93 bool airlineFromCallsign, const QString &airlineName, const QString &airlineTelephony,
95
99 static swift::misc::aviation::CAirlineIcaoCode failoverValidAirlineIcaoDesignatorModelsFirst(
100 const swift::misc::aviation::CCallsign &callsign, const QString &primaryIcao, const QString &secondaryIcao,
101 bool airlineFromCallsign, const QString &airlineName, const QString &airlineTelephony,
103
108 reverseLookupScript(const swift::misc::simulation::CAircraftModel &inModel,
112
116 matchingStageScript(const swift::misc::simulation::CAircraftModel &inModel,
117 const swift::misc::simulation::CAircraftModel &matchedModel,
121
125 matchingScript(const QString &js, const swift::misc::simulation::CAircraftModel &inModel,
126 const swift::misc::simulation::CAircraftModel &matchedModel,
130
135 static swift::misc::simulation::CAircraftModel reverseLookupModel(
136 const swift::misc::aviation::CCallsign &callsign,
137 const swift::misc::aviation::CAircraftIcaoCode &networkAircraftIcao,
138 const swift::misc::aviation::CAirlineIcaoCode &networkAirlineIcao, const QString &networkLiveryInfo,
139 const QString &networkModelString, const swift::misc::simulation::CAircraftMatcherSetup &setup,
142
147 static swift::misc::simulation::CAircraftModel reverseLookupModel(
148 const swift::misc::simulation::CAircraftModel &modelToLookup, const QString &networkLiveryInfo,
151
156 static swift::misc::simulation::CAircraftModel reverseLookupModelMs(
157 const swift::misc::simulation::CAircraftModel &modelToLookup, const QString &networkLiveryInfo,
160
165 reverseLookupModelStringInDB(const QString &modelString, const swift::misc::aviation::CCallsign &callsign,
166 bool doLookupString, swift::misc::CStatusMessageList *log);
167
173 reverseLookupModelStringInSet(const QString &modelString, const swift::misc::aviation::CCallsign &callsign,
174 const swift::misc::simulation::CAircraftModelList &modelSet, bool useNonDbEntries,
176
181 reverseLookupModelId(int id, const swift::misc::aviation::CCallsign &callsign,
183
188 reverseLookupAircraftIcao(const swift::misc::aviation::CAircraftIcaoCode &icaoDesignator,
189 const swift::misc::aviation::CCallsign &logCallsign = {},
190 swift::misc::CStatusMessageList *log = nullptr);
191
196 reverseLookupAircraftIcaoId(int id, const swift::misc::aviation::CCallsign &logCallsign,
197 swift::misc::CStatusMessageList *log = nullptr);
198
203 reverseLookupAirlineIcao(const swift::misc::aviation::CAirlineIcaoCode &icaoPattern,
204 const swift::misc::aviation::CCallsign &callsign = {},
205 swift::misc::CStatusMessageList *log = nullptr);
206
211 reverseLookupStandardLivery(const swift::misc::aviation::CAirlineIcaoCode &airline,
212 const swift::misc::aviation::CCallsign &callsign,
213 swift::misc::CStatusMessageList *log = nullptr);
214
218 static swift::misc::aviation::CLivery reverseLookupLiveryId(int id,
219 const swift::misc::aviation::CCallsign &logCallsign,
220 swift::misc::CStatusMessageList *log = nullptr);
221
225 static int reverseLookupByIds(const swift::misc::simulation::DBTripleIds &ids,
228 const swift::misc::aviation::CCallsign &logCallsign,
229 swift::misc::CStatusMessageList *log = nullptr);
230
234 static QString reverseLookupAirlineName(const QString &candidate,
235 const swift::misc::aviation::CCallsign &callsign = {},
236 swift::misc::CStatusMessageList *log = nullptr);
237
241 static QString reverseLookupTelephonyDesignator(const QString &candidate,
242 const swift::misc::aviation::CCallsign &callsign = {},
243 swift::misc::CStatusMessageList *log = nullptr);
244
247 static bool isKnownAircraftDesignator(const QString &candidate,
248 const swift::misc::aviation::CCallsign &callsign = {},
249 swift::misc::CStatusMessageList *log = nullptr);
250
253 static bool isKnownModelString(const QString &candidate, const swift::misc::aviation::CCallsign &callsign = {},
254 swift::misc::CStatusMessageList *log = nullptr);
255
259 static swift::misc::aviation::CAircraftIcaoCode
260 searchAmongAirlineAircraft(const QString &icaoString, const swift::misc::aviation::CAirlineIcaoCode &airline,
261 const swift::misc::aviation::CCallsign &callsign = {},
262 swift::misc::CStatusMessageList *log = nullptr);
263
266 static swift::misc::aviation::CAirlineIcaoCode
267 callsignToAirline(const swift::misc::aviation::CCallsign &callsign,
268 swift::misc::CStatusMessageList *log = nullptr);
269
271 swift::misc::simulation::CAircraftModelList getModelSet() const override { return m_modelSet; }
272
274 virtual const swift::misc::simulation::CAircraftModelList &getModelSetRef() const { return m_modelSet; }
275
277 int getModelSetCount() const override { return m_modelSet.sizeInt(); }
278
280 bool hasModels() const { return !m_modelSet.isEmpty(); }
281
284 int setModelSet(const swift::misc::simulation::CAircraftModelList &models,
285 const swift::misc::simulation::CSimulatorInfo &simulator, bool forced);
286
289 void disableModelsForMatching(const swift::misc::simulation::CAircraftModelList &removedModels,
290 bool incremental);
291
294
296 void restoreDisabledModels();
297
299 const swift::misc::simulation::CAircraftModel &getDefaultModel() const { return m_defaultModel; }
300
302 void setDefaultModel(const swift::misc::simulation::CAircraftModel &defaultModel);
303
306
308 void clearMatchingStatistics() { m_statistics.clear(); }
309
311 void evaluateStatisticsEntry(const QString &sessionId, const swift::misc::aviation::CCallsign &callsign,
312 const QString &aircraftIcao, const QString &airlineIcao, const QString &livery);
313
315 void addingRemoteModelFailed(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft);
316
317 signals:
320
321 private:
323 bool saveDisabledForMatchingModels();
324
327 getClosestMatchStepwiseReduceImplementation(const swift::misc::simulation::CAircraftModelList &modelSet,
329 const swift::misc::simulation::CCategoryMatcher &categoryMatcher,
331 swift::misc::simulation::MatchingLog whatToLog,
332 swift::misc::CStatusMessageList *log = nullptr);
333
336 getClosestMatchScoreImplementation(const swift::misc::simulation::CAircraftModelList &modelSet,
339 int &maxScore, swift::misc::simulation::MatchingLog whatToLog,
340 swift::misc::CStatusMessageList *log = nullptr);
341
346 getCombinedTypeDefaultModel(const swift::misc::simulation::CAircraftModelList &modelSet,
348 const swift::misc::simulation::CAircraftModel &defaultModel,
349 swift::misc::simulation::MatchingLog whatToLog,
350 swift::misc::CStatusMessageList *log = nullptr);
351
355 matchByExactModelString(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft,
357 swift::misc::simulation::MatchingLog whatToLog, swift::misc::CStatusMessageList *log);
358
362 ifPossibleReduceByIcaoData(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft,
364 const swift::misc::simulation::CAircraftMatcherSetup &setup, bool &reduced,
366
370 ifPossibleReduceByFamily(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft,
371 bool allowPseudoFamily, const swift::misc::simulation::CAircraftModelList &inList,
372 bool &reduced, QString &usedFamily, swift::misc::CStatusMessageList *log);
373
378 ifPossibleReduceByFamily(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft,
379 const QString &family, bool allowPseudoFamily,
380 const swift::misc::simulation::CAircraftModelList &inList, const QString &hint,
381 bool &reduced, swift::misc::CStatusMessageList *log);
382
386 ifPossibleReduceByLiveryAndAircraftIcaoCode(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft,
388 bool &reduced, swift::misc::CStatusMessageList *log);
389
393 ifPossibleReduceByManufacturer(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft,
394 const swift::misc::simulation::CAircraftModelList &inList, const QString &info,
395 bool &reduced, swift::misc::CStatusMessageList *log);
396
399 static swift::misc::aviation::CAircraftIcaoCodeList ifPossibleReduceAircraftIcaoByManufacturer(
401 const swift::misc::aviation::CAircraftIcaoCodeList &inList, const QString &info, bool &reduced,
403
407 ifPossibleReduceByAircraft(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft,
408 const swift::misc::simulation::CAircraftModelList &inList, const QString &info,
409 bool &reduced, swift::misc::CStatusMessageList *log);
410
414 ifPossibleReduceByAircraftOrFamily(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft,
415 bool allowPseudoFamily,
418 const QString &info, bool &reduced, swift::misc::CStatusMessageList *log);
419
423 ifPossibleReduceByAirline(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft,
426 bool &reduced, swift::misc::CStatusMessageList *log);
427
430 static swift::misc::simulation::CAircraftModelList ifPossibleReduceModelsByAirlineNameTelephonyDesignator(
431 const swift::misc::aviation::CCallsign &cs, const QString &airlineName, const QString &telephony,
432 const swift::misc::simulation::CAircraftModelList &inList, const QString &info, bool &reduced,
434
438 ifPossibleReduceByCombinedType(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft,
440 const swift::misc::simulation::CAircraftMatcherSetup &setup, bool &reduced,
442
446 ifPossibleReduceByMilitaryFlag(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft,
447 const swift::misc::simulation::CAircraftModelList &inList, bool &reduced,
449
453 ifPossibleReduceByVTOLFlag(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft,
454 const swift::misc::simulation::CAircraftModelList &inList, bool &reduced,
456
459 static QString scoresToString(const swift::misc::simulation::ScoredModels &scores, int lastElements = 5);
460
464 stringToAirlineIcaoObject(const swift::misc::aviation::CCallsign &cs, const QString &designator,
465 const QString &airlineName, const QString &airlineTelephony, bool useSwiftDbData,
467
470 static bool isValidAirlineIcaoDesignator(const QString &designator, bool checkAgainstSwiftDb);
471
473 static bool constexpr UsePseudoFamily = true;
474
482 QString m_modelSetInfo;
483 };
484} // namespace swift::core
485
486#endif // SWIFT_CORE_AIRCRAFTMATCHER_H
QMultiMap< int, CAircraftModel > ScoredModels
Individual (matching) score for each model.
void setupChanged()
Setup changed.
const swift::misc::simulation::CMatchingStatistics & getCurrentStatistics() const
The current statistics.
int getModelSetCount() const
Model set count.
void clearMatchingStatistics()
Clear the statistics.
swift::misc::simulation::CAircraftModelList getModelSet() const
Get the model set models.
swift::misc::simulation::CAircraftMatcherSetup getSetup() const
Get the setup.
CAircraftMatcher & operator=(const CAircraftMatcher &)=delete
Copy assignment operator.
const swift::misc::simulation::CAircraftModel & getDefaultModel() const
Default model.
virtual const swift::misc::simulation::CAircraftModelList & getModelSetRef() const
Model set as reference.
CAircraftMatcher(const CAircraftMatcher &)=delete
Copy constructor.
swift::misc::simulation::CAircraftModelList getDisabledModelsForMatching() const
The disabled models for matching.
CAircraftMatcher(const swift::misc::simulation::CAircraftMatcherSetup &setup, QObject *parent=nullptr)
Constructor.
bool setSetup(const swift::misc::simulation::CAircraftMatcherSetup &setup)
Set the setup.
static const QStringList & getLogCategories()
Log categories.
A sequence of log categories.
Status messages, e.g. from Core -> GUI.
Value object for ICAO classification.
Value object encapsulating a list of ICAO codes.
Value object for ICAO classification.
Value object encapsulating information of a callsign.
Definition callsign.h:30
Value object encapsulating information about an airpot.
Definition livery.h:29
Aircraft model (used by another pilot, my models on disk).
Value object encapsulating a list of aircraft models.
Category matcher, uses the DB categories.
Value object for matching statistics.
Comprehensive information of an aircraft.
Simple hardcoded info about the corresponding simulator.
Value object encapsulating a list of aircraft models.
MatchingScript
Matching script type.
Backend services of the swift project, like dealing with the network or the simulators.
Definition actionbind.cpp:7
Free functions in swift::misc.
QObject(QObject *parent)
Q_INTERFACES(...)
Q_OBJECTQ_OBJECT
QObject * parent() const const
#define SWIFT_CORE_EXPORT
Export a class or function from the library.