swift
Loading...
Searching...
No Matches
aircraftmatchersetup.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_MISC_SIMULATION_AIRCRAFTMATCHERSETUP_H
7#define SWIFT_MISC_SIMULATION_AIRCRAFTMATCHERSETUP_H
8
10#include "misc/valueobject.h"
11
12SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::Simulation, CAircraftMatcherSetup)
13
14namespace swift::misc::simulation
15{
17 class SWIFT_MISC_EXPORT CAircraftMatcherSetup : public CValueObject<CAircraftMatcherSetup>
18 {
19 public:
22 {
23 MatchingScoreBased,
24 MatchingStepwiseReducePlusScoreBased,
25 MatchingStepwiseReduce,
26 };
27
30 {
31 ByModelString = 1 << 0,
32 ByIcaoData = 1 << 1,
33 ByFamily = 1 << 2,
34 ByLivery = 1 << 3,
35 ByCombinedType = 1 << 4,
36 ByManufacturer = 1 << 5,
37 ByMilitary = 1 << 6,
38 ByCivilian = 1 << 7,
39 ByMilOrCivilian = ByCivilian | ByMilitary,
40 ByVtol = 1 << 8,
41 ByIcaoOrderAircraftFirst = (1 << 9) | ByIcaoData,
42 ByIcaoOrderAirlineFirst = (1 << 10) | ByIcaoData,
43 ByAirlineGroupSameAsAirline = (1 << 11) | ByIcaoData,
44 ByAirlineGroupIfNoAirline = (1 << 12) | ByIcaoData,
45
46 // --- exclusion ---
47 ExcludeNoDbData = 1 << 13,
48 ExcludeNoExcluded = 1 << 14,
49 ExcludeDefault = ExcludeNoExcluded | ExcludeNoDbData,
50
51 // --- model set ---
52 ModelSetRemoveFailedModel = 1 << 15,
53 ModelVerificationAtStartup = 1 << 16,
54 ModelFailoverIfNoModelCanBeAdded = 1 << 17,
55 ModelVerificationOnlyWarnError = 1 << 18, // later added, hence 18
56
57 // --- categories ---
58 ByCategoryGlider = 1 << 20,
59 ByCategoryMilitary = 1 << 21,
60 ByCategorySmallAircraft = 1 << 22,
61
62 // --- reverse lookup ---
63 ReverseLookupModelString = 1 << 25,
64 ReverseLookupSwiftLiveryIds = 1 << 26,
65 ReverseLookupDefault = ReverseLookupModelString | ReverseLookupSwiftLiveryIds,
66
67 // --- score based matching ---
68 ScoreIgnoreZeros = 1 << 28,
70
71 // --- others ---
72 ModeNone = 0,
73 ModeByFLags = ByMilOrCivilian | ByVtol,
74
75 // default mode for set handling
76 ModeDefaultSet = ModelSetRemoveFailedModel | ModelVerificationAtStartup | ModelFailoverIfNoModelCanBeAdded,
77
78 // default depending on algorithm
79 ModeDefaultScore = ScoreIgnoreZeros | ScorePreferColorLiveries | ExcludeDefault | ReverseLookupDefault,
80 ModeDefaultReduce = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType |
81 ByIcaoOrderAircraftFirst | ByAirlineGroupIfNoAirline | ReverseLookupDefault |
82 ExcludeDefault | ByLivery,
83 ModeDefaultReducePlusScore = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType |
84 ByIcaoOrderAircraftFirst | ByAirlineGroupIfNoAirline | ReverseLookupDefault |
85 ExcludeDefault | ModeDefaultScore,
86 };
87 Q_DECLARE_FLAGS(MatchingMode, MatchingModeFlag)
88
89
91 {
92 ForceNothing = 0,
93 ForceType = 1 << 0,
94 ForceEnginecount = 1 << 1,
95 ForceEngine = 1 << 2
96 };
97 Q_DECLARE_FLAGS(ForceMode, ForceModeFlag)
98
99
101 {
102 PickFirst,
103 PickRandom,
104 PickByOrder
105 };
106
109 {
110 IndexMatchingAlgorithm = CPropertyIndexRef::GlobalIndexCAircraftMatcherSetup,
111 IndexMatchingMode,
112 IndexForceMode,
113 IndexPickStrategy,
114 IndexMsNetworkEntryFile,
115 IndexMsMatchingStageFile,
116 IndexMsNetworkEnabled,
117 IndexMsMatchingStageEnabled
118 };
119
122
124 CAircraftMatcherSetup(MatchingAlgorithm algorithm);
125
127 CAircraftMatcherSetup(MatchingAlgorithm algorithm, MatchingMode mode, PickSimilarStrategy pickStrategy);
128
130 MatchingAlgorithm getMatchingAlgorithm() const { return static_cast<MatchingAlgorithm>(m_algorithm); }
131
134
136 bool setMatchingAlgorithm(MatchingAlgorithm algorithm, bool reset = true);
137
139 MatchingMode getMatchingMode() const { return static_cast<MatchingMode>(m_mode); }
140
142 ForceMode getForceMode() const { return static_cast<ForceMode>(m_force); }
143
145 void setForceMode(ForceMode fm) { m_force = static_cast<int>(fm); }
146
149
152 bool isReverseLookupModelString() const;
153 bool isReverseLookupSwiftLiveryIds() const;
154 void resetReverseLookup();
156
158 bool isDbDataOnly() const { return this->getMatchingMode().testFlag(ExcludeNoDbData); }
159
162 const QString &getMsReverseLookupFile() const { return m_msReverseLookupFile; }
163 const QString &getMsMatchingStageFile() const { return m_msMatchingStageFile; }
165
168 void setMsReverseLookupFile(const QString &file) { m_msReverseLookupFile = file; }
169 void setMsMatchingStageFile(const QString &file) { m_msMatchingStageFile = file; }
171
174 bool isMsReverseLookupEnabled() const { return m_msReverseEnabled; }
175 bool isMsMatchingStageEnabled() const { return m_msMatchingEnabled; }
177
180 bool doRunMsReverseLookupScript() const;
181 bool doRunMsMatchingStageScript() const;
183
186 void setMsReverseLookupEnabled(bool enabled) { m_msReverseEnabled = enabled; }
187 void setMsMatchingStageEnabled(bool enabled) { m_msMatchingEnabled = enabled; }
189
192 bool doVerificationAtStartup() const { return this->getMatchingMode().testFlag(ModelVerificationAtStartup); }
193
197 {
198 return this->getMatchingMode().testFlag(ModelVerificationOnlyWarnError);
199 }
200
203 bool doModelAddFailover() const { return this->getMatchingMode().testFlag(ModelFailoverIfNoModelCanBeAdded); }
204
206 void setVerificationAtStartup(bool verify);
207
209 void setOnlyShowVerificationWarningsAndErrors(bool only);
210
213
215 void setMatchingMode(MatchingMode mode) { m_mode = static_cast<int>(mode); }
216
218 bool removeFromSetIfFailed() const { return this->getMatchingMode().testFlag(ModelSetRemoveFailedModel); }
219
221 PickSimilarStrategy getPickStrategy() const { return static_cast<PickSimilarStrategy>(m_strategy); }
222
225
227 void setPickStrategy(PickSimilarStrategy strategy) { m_strategy = static_cast<int>(strategy); }
228
230 void setAirlineGroupBehaviour(bool ifNoAirline, bool sameAsAirline);
231
233 QString convertToQString(bool i18n = false) const;
234
236 QVariant propertyByIndex(CPropertyIndexRef index) const;
237
239 void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
240
242 void reset();
243
245 void reset(MatchingAlgorithm algorithm);
246
248 bool useCategoryMatching() const;
249
251 static const QString &algorithmToString(MatchingAlgorithm algorithm);
252
254 static const QString &modeFlagToString(MatchingModeFlag modeFlag);
255
257 static QString modeToString(MatchingMode mode);
258
260 static const QString &forceFlagToString(ForceModeFlag forceFlag);
261
263 static QString forceToString(ForceMode force);
264
266 static const QString &strategyToString(PickSimilarStrategy strategy);
267
269 static MatchingMode matchingMode(bool revModelString, bool revLiveryIds, bool byModelString,
270 bool byIcaoDataAircraft1st, bool byIcaoDataAirline1st, bool byFamily,
271 bool byLivery, bool byCombinedType, bool byForceMilitary, bool byForceCivilian,
272 bool byVtol, bool byGliderCategory, bool byMilitaryCategory,
273 bool bySmallAircraftCategory, bool scoreIgnoreZeros,
274 bool scorePreferColorLiveries, bool excludeNoDbData, bool excludeNoExcluded,
275 bool modelVerification, bool modelVerificationWarnError,
276 bool modelSetRemoveFailedModel, bool modelFailover);
277
278 private:
279 int m_algorithm = static_cast<int>(MatchingStepwiseReducePlusScoreBased);
280 int m_mode = static_cast<int>(ModeDefaultReducePlusScore);
281 int m_strategy = static_cast<int>(PickByOrder);
282 int m_force = static_cast<int>(ForceNothing);
283 QString m_msReverseLookupFile;
284 QString m_msMatchingStageFile;
285 bool m_msReverseEnabled = false;
286 bool m_msMatchingEnabled = false;
287
290 SWIFT_METAMEMBER(algorithm),
291 SWIFT_METAMEMBER(mode),
292 SWIFT_METAMEMBER(strategy),
293 SWIFT_METAMEMBER(force),
294 SWIFT_METAMEMBER(msReverseLookupFile),
295 SWIFT_METAMEMBER(msMatchingStageFile),
296 SWIFT_METAMEMBER(msReverseEnabled),
297 SWIFT_METAMEMBER(msMatchingEnabled));
298 };
299} // namespace swift::misc::simulation
300
303Q_DECLARE_METATYPE(swift::misc::simulation::CAircraftMatcherSetup::MatchingMode)
305Q_DECLARE_METATYPE(swift::misc::simulation::CAircraftMatcherSetup::ForceMode)
308Q_DECLARE_OPERATORS_FOR_FLAGS(swift::misc::simulation::CAircraftMatcherSetup::MatchingMode)
309
310#endif // SWIFT_MISC_SIMULATION_AIRCRAFTMATCHERSETUP_H
Non-owning reference to a CPropertyIndex with a subset of its features.
void setMsMatchingStageEnabled(bool enabled)
Is matching script enabled.
bool onlyShowVerificationWarningsAndErrors() const
Verification only shown for warning/errors?
const QString & getPickStrategyAsString() const
Strategy as string.
static const QString & algorithmToString(MatchingAlgorithm algorithm)
Algorithm to string.
void setMsReverseLookupFile(const QString &file)
Set matching files.
QString getForceModeAsString() const
Force mode as string.
bool doVerificationAtStartup() const
Verification at startup?
MatchingMode getMatchingMode() const
Matching mode.
void setMsReverseLookupEnabled(bool enabled)
Is matching script enabled.
static QString forceToString(ForceMode force)
Force to string.
static QString modeToString(MatchingMode mode)
Enumeration as string.
PickSimilarStrategy
How to pick among similar candiates.
@ ByMilitary
military (in) will only search in military
@ ByCivilian
civilian (in) will only search in civilian
const QString & getMsReverseLookupFile() const
Get matching files.
const QString & getMsMatchingStageFile() const
Get matching files.
void setPickStrategy(PickSimilarStrategy strategy)
Set the strategy.
bool doModelAddFailover() const
Failover if model cannot be loaded.
QString getMatchingModeAsString() const
Matching mode as string.
void setMsMatchingStageFile(const QString &file)
Set matching files.
void setMatchingMode(MatchingMode mode)
Dynamic offset values?
bool isMsMatchingStageEnabled() const
Is matching script enabled.
const QString & getMatchingAlgorithmAsString() const
Algorithm as string.
MatchingAlgorithm getMatchingAlgorithm() const
Algorithm.
static const QString & strategyToString(PickSimilarStrategy strategy)
Strategy to string.
PickSimilarStrategy getPickStrategy() const
Strategy among equally suitable models.
bool isMsReverseLookupEnabled() const
Is matching script enabled.
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition metaclass.h:72
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition metaclass.h:52
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...
Definition valueobject.h:65