diff --git a/src/blackmisc/simulation/matchinglog.cpp b/src/blackmisc/simulation/matchinglog.cpp new file mode 100644 index 000000000..67b4a0b99 --- /dev/null +++ b/src/blackmisc/simulation/matchinglog.cpp @@ -0,0 +1,55 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +#include "matchinglog.h" +#include + +namespace BlackMisc +{ + namespace Simulation + { + //! Log flag to string + const QString &matchingLogFlagToString(MatchingLogFlag logFlag) + { + static const QString logNothing("nothing"); + static const QString logModelstring("model string"); + static const QString logStepwiseReduce("step wise reduce"); + static const QString logScoring("scoring"); + static const QString logCombinedDefaultType("combined default type"); + static const QString logSimplified("simplified"); + static const QString logAll("all"); + + switch (logFlag) + { + case MatchingLogCombinedDefaultType: return logCombinedDefaultType; + case MatchingLogNothing: return logNothing; + case MatchingLogModelstring: return logModelstring; + case MatchingLogStepwiseReduce: return logStepwiseReduce; + case MatchingLogScoring: return logScoring; + case MatchingLogSimplified: return logSimplified; + case MatchingLogAll: return logAll; + default: break; + } + + static const QString unknown("unknown"); + return unknown; + } + + //! Log flag to string + const QString matchingLogToString(MatchingLog log) + { + if (log == MatchingLogNothing) { return matchingLogFlagToString(MatchingLogNothing); } + QStringList l; + if (log.testFlag(MatchingLogCombinedDefaultType)) { l << matchingLogFlagToString(MatchingLogCombinedDefaultType); } + if (log.testFlag(MatchingLogModelstring)) { l << matchingLogFlagToString(MatchingLogModelstring); } + if (log.testFlag(MatchingLogStepwiseReduce)) { l << matchingLogFlagToString(MatchingLogStepwiseReduce); } + if (log.testFlag(MatchingLogScoring)) { l << matchingLogFlagToString(MatchingLogScoring); } + return l.join(", "); + } + } // ns +} // ns diff --git a/src/blackmisc/simulation/matchinglog.h b/src/blackmisc/simulation/matchinglog.h new file mode 100644 index 000000000..638103826 --- /dev/null +++ b/src/blackmisc/simulation/matchinglog.h @@ -0,0 +1,48 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKMISC_SIMULATION_MATCHINGLOG_H +#define BLACKMISC_SIMULATION_MATCHINGLOG_H + +#include "blackmisc/blackmiscexport.h" +#include +#include + +namespace BlackMisc +{ + namespace Simulation + { + //! What to log + enum MatchingLogFlag + { + MatchingLogNothing = 0, + MatchingLogIntro = 1 << 0, + MatchingLogModelstring = 1 << 1, + MatchingLogStepwiseReduce = 1 << 2, + MatchingLogScoring = 1 << 3, + MatchingLogCombinedDefaultType = 1 << 4, + MatchingLogSimplified = MatchingLogIntro, + MatchingLogAll = MatchingLogModelstring | MatchingLogStepwiseReduce | MatchingLogScoring | MatchingLogCombinedDefaultType + }; + Q_DECLARE_FLAGS(MatchingLog, MatchingLogFlag) + + //! Log flag to string + BLACKMISC_EXPORT const QString matchingLogToString(MatchingLog log); + + //! Log flag to string + BLACKMISC_EXPORT const QString &matchingLogFlagToString(MatchingLogFlag logFlag); + } // ns +} // ns + +Q_DECLARE_METATYPE(BlackMisc::Simulation::MatchingLog) +Q_DECLARE_METATYPE(BlackMisc::Simulation::MatchingLogFlag) +Q_DECLARE_OPERATORS_FOR_FLAGS(BlackMisc::Simulation::MatchingLog) + +#endif // guard diff --git a/src/blackmisc/simulation/registermetadatasimulation.cpp b/src/blackmisc/simulation/registermetadatasimulation.cpp index d856a5c99..b8104b07d 100644 --- a/src/blackmisc/simulation/registermetadatasimulation.cpp +++ b/src/blackmisc/simulation/registermetadatasimulation.cpp @@ -28,7 +28,6 @@ namespace BlackMisc CDistributor::registerMetadata(); CDistributorList::registerMetadata(); CDistributorListPreferences::registerMetadata(); - qDBusRegisterMetaType(); CInterpolationAndRenderingSetupPerCallsign::registerMetadata(); CInterpolationAndRenderingSetupGlobal::registerMetadata(); CInterpolationSetupList::registerMetadata(); @@ -48,14 +47,24 @@ namespace BlackMisc CSwiftPluginSettings::registerMetadata(); CVPilotModelRule::registerMetadata(); CVPilotModelRuleSet::registerMetadata(); + CAircraftMatcherSetup::registerMetadata(); + qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); + + // the ones generate with Q_DECLARE_FLAGS fail here + qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); + qDBusRegisterMetaType(); qDBusRegisterMetaType(); - CAircraftMatcherSetup::registerMetadata(); + qDBusRegisterMetaType(); } } // ns } // ns diff --git a/src/blackmisc/simulation/reverselookup.h b/src/blackmisc/simulation/reverselookup.h new file mode 100644 index 000000000..a3292bb0f --- /dev/null +++ b/src/blackmisc/simulation/reverselookup.h @@ -0,0 +1,36 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKMISC_SIMULATION_REVERSELOOKUP_H +#define BLACKMISC_SIMULATION_REVERSELOOKUP_H + +#include + +namespace BlackMisc +{ + namespace Simulation + { + //! Lookup log.messages + enum ReverseLookupLoggingFlag + { + RevLogDisabled = 0, + RevLogEnabled = 1 << 0, + RevLogSimplifiedInfo = 1 << 1, + RevLogEnabledSimplified = RevLogEnabled | RevLogSimplifiedInfo + }; + Q_DECLARE_FLAGS(ReverseLookupLogging, ReverseLookupLoggingFlag) + } // ns +} // ns + +Q_DECLARE_METATYPE(BlackMisc::Simulation::ReverseLookupLogging) +Q_DECLARE_METATYPE(BlackMisc::Simulation::ReverseLookupLoggingFlag) +Q_DECLARE_OPERATORS_FOR_FLAGS(BlackMisc::Simulation::ReverseLookupLogging) + +#endif // guard diff --git a/src/blackmisc/simulation/simulation.h b/src/blackmisc/simulation/simulation.h index ab6be142c..3eecd206b 100644 --- a/src/blackmisc/simulation/simulation.h +++ b/src/blackmisc/simulation/simulation.h @@ -22,6 +22,8 @@ #include "blackmisc/simulation/interpolationrenderingsetup.h" #include "blackmisc/simulation/interpolationsetuplist.h" #include "blackmisc/simulation/matchingstatistics.h" +#include "blackmisc/simulation/matchinglog.h" +#include "blackmisc/simulation/reverselookup.h" #include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/simulation/simulatorinfolist.h"