mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
Ref T472, matching settings/setup for categories
This commit is contained in:
committed by
Mat Sutcliffe
parent
6ca6d12851
commit
530bd38f00
@@ -15,7 +15,7 @@ namespace BlackMisc
|
||||
{
|
||||
CAircraftMatcherSetup::CAircraftMatcherSetup()
|
||||
{
|
||||
this->reset(MatchingStepwiseReducePlusScoreBased);
|
||||
this->reset();
|
||||
}
|
||||
|
||||
CAircraftMatcherSetup::CAircraftMatcherSetup(CAircraftMatcherSetup::MatchingAlgorithm algorithm)
|
||||
@@ -88,6 +88,11 @@ namespace BlackMisc
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
}
|
||||
|
||||
void CAircraftMatcherSetup::reset()
|
||||
{
|
||||
this->reset(MatchingStepwiseReducePlusScoreBased);
|
||||
}
|
||||
|
||||
void CAircraftMatcherSetup::reset(CAircraftMatcherSetup::MatchingAlgorithm algorithm)
|
||||
{
|
||||
m_algorithm = static_cast<int>(algorithm);
|
||||
@@ -101,6 +106,8 @@ namespace BlackMisc
|
||||
mode = ModeDefaultReducePlusScore;
|
||||
break;
|
||||
}
|
||||
mode |= ModeDefaultSet; // add set default
|
||||
|
||||
this->setMatchingMode(mode);
|
||||
this->setPickStrategy(PickByOrder);
|
||||
}
|
||||
@@ -139,6 +146,8 @@ namespace BlackMisc
|
||||
static const QString removeFromModelSet("rem.from model set");
|
||||
static const QString verification("Verify models at startup");
|
||||
static const QString modelFailedAdded("Replace models failed to be added");
|
||||
static const QString categoryGlider("glider categories");
|
||||
static const QString categoryMilitary("military categories");
|
||||
|
||||
switch (modeFlag)
|
||||
{
|
||||
@@ -152,6 +161,8 @@ namespace BlackMisc
|
||||
case ByForceCivilian: return forceCiv;
|
||||
case ByForceMilitary: return forceMil;
|
||||
case ByVtol: return vtol;
|
||||
case ByCategoryGlider: return categoryGlider;
|
||||
case ByCategoryMilitary: return categoryMilitary;
|
||||
case ScoreIgnoreZeros: return noZeros;
|
||||
case ScorePreferColorLiveries: return preferColorLiveries;
|
||||
case ExcludeNoDbData: return exNoDb;
|
||||
@@ -178,6 +189,8 @@ namespace BlackMisc
|
||||
if (mode.testFlag(ByCombinedType)) { modes << modeFlagToString(ByCombinedType); }
|
||||
if (mode.testFlag(ByForceCivilian)) { modes << modeFlagToString(ByForceCivilian); }
|
||||
if (mode.testFlag(ByForceMilitary)) { modes << modeFlagToString(ByForceMilitary); }
|
||||
if (mode.testFlag(ByCategoryGlider)) { modes << modeFlagToString(ByCategoryGlider); }
|
||||
if (mode.testFlag(ByCategoryMilitary)) { modes << modeFlagToString(ByCategoryMilitary); }
|
||||
if (mode.testFlag(ByVtol)) { modes << modeFlagToString(ByVtol); }
|
||||
if (mode.testFlag(ScoreIgnoreZeros)) { modes << modeFlagToString(ScoreIgnoreZeros); }
|
||||
if (mode.testFlag(ScorePreferColorLiveries)) { modes << modeFlagToString(ScorePreferColorLiveries); }
|
||||
@@ -206,12 +219,13 @@ namespace BlackMisc
|
||||
return unknown;
|
||||
}
|
||||
|
||||
CAircraftMatcherSetup::MatchingMode CAircraftMatcherSetup::matchingMode(bool byModelString, bool byIcaoDataAircraft1st, bool byIcaoDataAirline1st, bool byFamily, bool byLivery, bool byCombinedType,
|
||||
bool byForceMilitary, bool byForceCivilian,
|
||||
bool byVtol,
|
||||
bool scoreIgnoreZeros, bool scorePreferColorLiveries,
|
||||
bool excludeNoDbData, bool excludeNoExcluded,
|
||||
bool modelVerification, bool modelSetRemoveFailedModel, bool modelFailover)
|
||||
CAircraftMatcherSetup::MatchingMode CAircraftMatcherSetup::matchingMode(
|
||||
bool byModelString, bool byIcaoDataAircraft1st, bool byIcaoDataAirline1st, bool byFamily, bool byLivery, bool byCombinedType,
|
||||
bool byForceMilitary, bool byForceCivilian, bool byVtol,
|
||||
bool byGliderCategory, bool byMilitaryCategory,
|
||||
bool scoreIgnoreZeros, bool scorePreferColorLiveries,
|
||||
bool excludeNoDbData, bool excludeNoExcluded,
|
||||
bool modelVerification, bool modelSetRemoveFailedModel, bool modelFailover)
|
||||
{
|
||||
if (modelFailover) { modelSetRemoveFailedModel = true; } // otherwise this does not make sense
|
||||
|
||||
@@ -224,6 +238,8 @@ namespace BlackMisc
|
||||
if (byForceMilitary) { mode |= ByForceMilitary; }
|
||||
if (byForceCivilian) { mode |= ByForceCivilian; }
|
||||
if (byVtol) { mode |= ByVtol; }
|
||||
if (byGliderCategory) { mode |= ByCategoryGlider; }
|
||||
if (byMilitaryCategory) { mode |= ByCategoryMilitary; }
|
||||
if (scoreIgnoreZeros) { mode |= ScoreIgnoreZeros; }
|
||||
if (scorePreferColorLiveries) { mode |= ScorePreferColorLiveries; }
|
||||
if (excludeNoDbData) { mode |= ExcludeNoDbData; }
|
||||
|
||||
@@ -28,14 +28,14 @@ namespace BlackMisc
|
||||
{
|
||||
MatchingScoreBased,
|
||||
MatchingStepwiseReducePlusScoreBased,
|
||||
MatchingStepwiseReduce
|
||||
MatchingStepwiseReduce,
|
||||
};
|
||||
|
||||
//! Enabled matching mode flags
|
||||
enum MatchingModeFlag
|
||||
{
|
||||
ByModelString = 1 << 0, //!< allow exact model string match
|
||||
ByIcaoData = 1 << 1,
|
||||
ByIcaoData = 1 << 1, //!< ICAO airline and aircraft codes
|
||||
ByFamily = 1 << 2,
|
||||
ByLivery = 1 << 3,
|
||||
ByCombinedType = 1 << 4,
|
||||
@@ -46,6 +46,9 @@ namespace BlackMisc
|
||||
ByVtol = 1 << 8,
|
||||
ByIcaoOrderAircraftFirst = (1 << 9) | ByIcaoData,
|
||||
ByIcaoOrderAirlineFirst = (1 << 10) | ByIcaoData,
|
||||
ByCategoryGlider = 1 << 20,
|
||||
ByCategoryMilitary = 1 << 21,
|
||||
|
||||
// --- score based matching ---
|
||||
ScoreIgnoreZeros = 1 << 11, //!< zero scores are ignored
|
||||
ScorePreferColorLiveries = 1 << 12, //!< prefer color liveries
|
||||
@@ -57,15 +60,18 @@ namespace BlackMisc
|
||||
ModelSetRemoveFailedModel = 1 << 15,
|
||||
ModelVerificationAtStartup = 1 << 16,
|
||||
ModelFailoverIfNoModelCanBeAdded = 1 << 17,
|
||||
|
||||
// --- others ---
|
||||
ModeNone = 0,
|
||||
ModeByFLags = ByMilitary | ByVtol,
|
||||
|
||||
// default mode for set handling
|
||||
ModeDefaultSet = ModelSetRemoveFailedModel | ModelVerificationAtStartup | ModelFailoverIfNoModelCanBeAdded,
|
||||
// ModeDefaultSet = ModelSetRemoveFailedModel | ModelFailoverIfNoModelCanBeAdded,
|
||||
|
||||
// default depending on algorithm
|
||||
ModeDefaultScore = ScoreIgnoreZeros | ScorePreferColorLiveries | ExcludeDefault,
|
||||
ModeDefaultReduce = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ByLivery | ExcludeDefault,
|
||||
ModeDefaultReducePlusScore = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ModeDefaultScore | ExcludeDefault,
|
||||
ModeDefault = ModeDefaultReducePlusScore | ModeDefaultSet
|
||||
};
|
||||
Q_DECLARE_FLAGS(MatchingMode, MatchingModeFlag)
|
||||
|
||||
@@ -144,6 +150,9 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const BlackMisc::CVariant &variant);
|
||||
|
||||
//! Reset
|
||||
void reset();
|
||||
|
||||
//! Reset
|
||||
void reset(MatchingAlgorithm algorithm);
|
||||
|
||||
@@ -163,12 +172,12 @@ namespace BlackMisc
|
||||
static MatchingMode matchingMode(bool byModelString, bool byIcaoDataAircraft1st, bool byIcaoDataAirline1st,
|
||||
bool byFamily, bool byLivery, bool byCombinedType,
|
||||
bool byForceMilitary, bool byForceCivilian,
|
||||
bool byVtol,
|
||||
bool byVtol, bool byGliderCategory, bool byMilitaryCategory,
|
||||
bool scoreIgnoreZeros, bool scorePreferColorLiveries, bool excludeNoDbData, bool excludeNoExcluded,
|
||||
bool modelVerification, bool modelSetRemoveFailedModel, bool modelFailover);
|
||||
|
||||
private:
|
||||
int m_algorithm = static_cast<int>(ModeDefault);
|
||||
int m_algorithm = static_cast<int>(MatchingStepwiseReducePlusScoreBased);
|
||||
int m_mode = static_cast<int>(ModeDefaultReducePlusScore);
|
||||
int m_strategy = static_cast<int>(PickByOrder);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user