mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 02:35:33 +08:00
Ref T298, move matcher setup into BlackMisc::Simulation
This commit is contained in:
@@ -30,7 +30,6 @@ using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackCore::Settings;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
@@ -1075,70 +1074,4 @@ namespace BlackCore
|
||||
if (!sApp || sApp->isShuttingDown() || !sApp->hasWebDataServices()) { return true; }
|
||||
return (sApp->getWebDataServices()->containsAirlineIcaoDesignator(designator));
|
||||
}
|
||||
|
||||
const QString &CAircraftMatcherSetup::modeFlagToString(MatchingModeFlag modeFlag)
|
||||
{
|
||||
static const QString ms("by model string");
|
||||
static const QString icao("by ICAO");
|
||||
static const QString family("by family");
|
||||
static const QString livery("by livery");
|
||||
static const QString combined("by combined combined");
|
||||
|
||||
switch (modeFlag)
|
||||
{
|
||||
case ByModelString: return ms;
|
||||
case ByIcaoData: return icao;
|
||||
case ByFamily: return family;
|
||||
case ByLivery: return livery;
|
||||
case ByCombinedType: return combined;
|
||||
default: break;
|
||||
}
|
||||
|
||||
static const QString unknown("unknown");
|
||||
return unknown;
|
||||
}
|
||||
|
||||
QString CAircraftMatcherSetup::modeToString(MatchingMode mode)
|
||||
{
|
||||
if (mode == ModeAll) { return "all"; }
|
||||
|
||||
QStringList modes;
|
||||
if (mode.testFlag(ByModelString)) { modes << modeFlagToString(ByModelString); }
|
||||
if (mode.testFlag(ByIcaoData)) { modes << modeFlagToString(ByIcaoData); }
|
||||
if (mode.testFlag(ByFamily)) { modes << modeFlagToString(ByFamily); }
|
||||
if (mode.testFlag(ByLivery)) { modes << modeFlagToString(ByLivery); }
|
||||
if (mode.testFlag(ByCombinedType)) { modes << modeFlagToString(ByCombinedType); }
|
||||
return modes.join(", ");
|
||||
}
|
||||
|
||||
QString CAircraftMatcherSetup::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
return modeToString(this->getMatchingMode());
|
||||
}
|
||||
|
||||
CVariant CAircraftMatcherSetup::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexMatchingMode: return CVariant::fromValue(m_mode);
|
||||
default: break;
|
||||
}
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
|
||||
void CAircraftMatcherSetup::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CAircraftMatcherSetup>(); return; }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexMatchingMode: m_mode = variant.toInt(); break;
|
||||
default: break;
|
||||
}
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define BLACKCORE_AIRCRAFTMATCHER_H
|
||||
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackmisc/simulation/aircraftmatchersetup.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/matchingstatistics.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
@@ -33,64 +34,6 @@ namespace BlackMisc
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
//! Matcher settings
|
||||
class BLACKCORE_EXPORT CAircraftMatcherSetup : public BlackMisc::CValueObject<CAircraftMatcherSetup>
|
||||
{
|
||||
public:
|
||||
//! Enabled matching mode flags
|
||||
enum MatchingModeFlag
|
||||
{
|
||||
ByModelString = 1 << 0,
|
||||
ByIcaoData = 1 << 1,
|
||||
ByFamily = 1 << 2,
|
||||
ByLivery = 1 << 3,
|
||||
ByCombinedType = 1 << 4,
|
||||
ModeAll = ByModelString | ByIcaoData | ByFamily | ByLivery | ByCombinedType
|
||||
};
|
||||
Q_DECLARE_FLAGS(MatchingMode, MatchingModeFlag)
|
||||
|
||||
//! Enumeration as string
|
||||
static const QString &modeFlagToString(MatchingModeFlag modeFlag);
|
||||
|
||||
//! Enumeration as string
|
||||
static QString modeToString(MatchingMode mode);
|
||||
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexMatchingMode = BlackMisc::CPropertyIndex::GlobalIndexCAircraftMatcherSetup
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
CAircraftMatcherSetup() {}
|
||||
|
||||
//! Matching mode
|
||||
MatchingMode getMatchingMode() const { return static_cast<MatchingMode>(m_mode); }
|
||||
|
||||
//! Dynamic offset values?
|
||||
void setMatchingMode(MatchingMode mode) { m_mode = static_cast<int>(mode); }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
BlackMisc::CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const BlackMisc::CVariant &variant);
|
||||
|
||||
private:
|
||||
int m_mode = static_cast<int>(ModeAll);
|
||||
|
||||
BLACK_METACLASS(
|
||||
CAircraftMatcherSetup,
|
||||
BLACK_METAMEMBER(mode)
|
||||
);
|
||||
};
|
||||
} // ns
|
||||
|
||||
//! Matcher for all models.
|
||||
//! \details Reads the model set (ie the models the user wants to use).
|
||||
//! Also Allows to reverse lookup a model (from network to DB data).
|
||||
@@ -103,7 +46,7 @@ namespace BlackCore
|
||||
static const BlackMisc::CLogCategoryList &getLogCategories();
|
||||
|
||||
//! Constructor
|
||||
CAircraftMatcher(const Settings::CAircraftMatcherSetup &setup, QObject *parent = nullptr);
|
||||
CAircraftMatcher(const BlackMisc::Simulation::CAircraftMatcherSetup &setup, QObject *parent = nullptr);
|
||||
|
||||
//! Constructor
|
||||
CAircraftMatcher(QObject *parent = nullptr);
|
||||
@@ -111,8 +54,8 @@ namespace BlackCore
|
||||
//! Destructor
|
||||
virtual ~CAircraftMatcher();
|
||||
|
||||
//! Set the enabled matching modes
|
||||
void setSetup(const Settings::CAircraftMatcherSetup matchingModes);
|
||||
//! Set the setup
|
||||
void setSetup(const BlackMisc::Simulation::CAircraftMatcherSetup &setup) { m_setup = setup; }
|
||||
|
||||
//! Get the closest matching aircraft model from set.
|
||||
//! Result depends on enabled modes.
|
||||
@@ -228,11 +171,11 @@ namespace BlackCore
|
||||
private:
|
||||
//! The search based implementation
|
||||
//! \threadsafe
|
||||
BlackMisc::Simulation::CAircraftModel getClosestMatchSearchImplementation(Settings::CAircraftMatcherSetup::MatchingMode mode, const BlackMisc::Simulation::CAircraftModelList &modelSet, const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, BlackMisc::CStatusMessageList *log = nullptr) const;
|
||||
BlackMisc::Simulation::CAircraftModel getClosestMatchSearchImplementation(BlackMisc::Simulation::CAircraftMatcherSetup::MatchingMode mode, const BlackMisc::Simulation::CAircraftModelList &modelSet, const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, BlackMisc::CStatusMessageList *log = nullptr) const;
|
||||
|
||||
//! The score based implementation
|
||||
//! \threadsafe
|
||||
BlackMisc::Simulation::CAircraftModel getClosestMatchScoreImplementation(Settings::CAircraftMatcherSetup::MatchingMode mode, const BlackMisc::Simulation::CAircraftModelList &modelSet, const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, BlackMisc::CStatusMessageList *log = nullptr) const;
|
||||
BlackMisc::Simulation::CAircraftModel getClosestMatchScoreImplementation(BlackMisc::Simulation::CAircraftMatcherSetup::MatchingMode mode, const BlackMisc::Simulation::CAircraftModelList &modelSet, const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, BlackMisc::CStatusMessageList *log = nullptr) const;
|
||||
|
||||
//! Get combined type default model, i.e. get a default model under consideration of the combined code such as "L2J"
|
||||
//! \see BlackMisc::Simulation::CSimulatedAircraft::getAircraftIcaoCombinedType
|
||||
@@ -288,18 +231,13 @@ namespace BlackCore
|
||||
//! \threadsafe
|
||||
static bool isValidAirlineIcaoDesignator(const QString &designator, bool checkAgainstSwiftDb);
|
||||
|
||||
Settings::CAircraftMatcherSetup m_setup; //!< setup
|
||||
BlackMisc::Simulation::CAircraftModel m_defaultModel; //!< model to be used as default model
|
||||
BlackMisc::Simulation::CAircraftModelList m_modelSet; //!< models used for model matching
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulator; //!< simulator (optional)
|
||||
BlackMisc::Simulation::CMatchingStatistics m_statistics; //!< matching statistics
|
||||
QString m_modelSetInfo; //!< info string
|
||||
BlackMisc::Simulation::CAircraftMatcherSetup m_setup; //!< setup
|
||||
BlackMisc::Simulation::CAircraftModel m_defaultModel; //!< model to be used as default model
|
||||
BlackMisc::Simulation::CAircraftModelList m_modelSet; //!< models used for model matching
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulator; //!< simulator (optional)
|
||||
BlackMisc::Simulation::CMatchingStatistics m_statistics; //!< matching statistics
|
||||
QString m_modelSetInfo; //!< info string
|
||||
};
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackCore::Settings::CAircraftMatcherSetup)
|
||||
Q_DECLARE_METATYPE(BlackCore::Settings::CAircraftMatcherSetup::MatchingMode)
|
||||
Q_DECLARE_METATYPE(BlackCore::Settings::CAircraftMatcherSetup::MatchingModeFlag)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(BlackCore::Settings::CAircraftMatcherSetup::MatchingMode)
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -36,8 +36,6 @@ namespace BlackCore
|
||||
qRegisterMetaType<IVoiceChannel::ConnectionStatus>();
|
||||
qRegisterMetaType<CWebReaderFlags::WebReader>();
|
||||
qRegisterMetaType<CWebReaderFlags::WebReaderFlag>();
|
||||
qRegisterMetaType<Settings::CAircraftMatcherSetup::MatchingMode>();
|
||||
qRegisterMetaType<Settings::CAircraftMatcherSetup::MatchingModeFlag>();
|
||||
|
||||
qDBusRegisterMetaType<Context::CLogSubscriptionHash>();
|
||||
qDBusRegisterMetaType<Context::CLogSubscriptionPair>();
|
||||
@@ -45,15 +43,12 @@ namespace BlackCore
|
||||
qDBusRegisterMetaType<INetwork::ConnectionStatus>();
|
||||
qDBusRegisterMetaType<INetwork::LoginMode>();
|
||||
qDBusRegisterMetaType<IVoiceChannel::ConnectionStatus>();
|
||||
// qDBusRegisterMetaType<Settings::CAircraftMatcherSetup::MatchingMode>();
|
||||
qDBusRegisterMetaType<Settings::CAircraftMatcherSetup::MatchingModeFlag>();
|
||||
|
||||
Db::CDatabaseReaderConfig::registerMetadata();
|
||||
Db::CDatabaseReaderConfigList::registerMetadata();
|
||||
Data::CGlobalSetup::registerMetadata();
|
||||
Data::CVatsimSetup::registerMetadata();
|
||||
Data::CLauncherSetup::registerMetadata();
|
||||
Settings::CAircraftMatcherSetup::registerMetadata();
|
||||
Vatsim::CReaderSettings::registerMetadata();
|
||||
Vatsim::CRawFsdMessageSettings::registerMetadata();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user