mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
Ref T566, log flags/enum in own files and DBus/meta registration
I do not want to have to include the complex matcher and network classes just for the enums/flags
This commit is contained in:
committed by
Mat Sutcliffe
parent
b2065b5da3
commit
002f9e6a9b
55
src/blackmisc/simulation/matchinglog.cpp
Normal file
55
src/blackmisc/simulation/matchinglog.cpp
Normal file
@@ -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 <QStringList>
|
||||
|
||||
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
|
||||
48
src/blackmisc/simulation/matchinglog.h
Normal file
48
src/blackmisc/simulation/matchinglog.h
Normal file
@@ -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 <QStringList>
|
||||
#include <QMetaType>
|
||||
|
||||
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
|
||||
@@ -28,7 +28,6 @@ namespace BlackMisc
|
||||
CDistributor::registerMetadata();
|
||||
CDistributorList::registerMetadata();
|
||||
CDistributorListPreferences::registerMetadata();
|
||||
qDBusRegisterMetaType<CInterpolationAndRenderingSetupBase::InterpolatorMode>();
|
||||
CInterpolationAndRenderingSetupPerCallsign::registerMetadata();
|
||||
CInterpolationAndRenderingSetupGlobal::registerMetadata();
|
||||
CInterpolationSetupList::registerMetadata();
|
||||
@@ -48,14 +47,24 @@ namespace BlackMisc
|
||||
CSwiftPluginSettings::registerMetadata();
|
||||
CVPilotModelRule::registerMetadata();
|
||||
CVPilotModelRuleSet::registerMetadata();
|
||||
CAircraftMatcherSetup::registerMetadata();
|
||||
|
||||
qRegisterMetaType<CAircraftMatcherSetup::MatchingAlgorithm>();
|
||||
qRegisterMetaType<CAircraftMatcherSetup::MatchingMode>();
|
||||
qRegisterMetaType<CAircraftMatcherSetup::MatchingModeFlag>();
|
||||
qRegisterMetaType<MatchingLog>();
|
||||
qRegisterMetaType<MatchingLogFlag>();
|
||||
qRegisterMetaType<CAircraftMatcherSetup::PickSimilarStrategy>();
|
||||
qRegisterMetaType<ReverseLookupLoggingFlag>();
|
||||
qRegisterMetaType<ReverseLookupLogging>();
|
||||
|
||||
// the ones generate with Q_DECLARE_FLAGS fail here
|
||||
qDBusRegisterMetaType<CInterpolationAndRenderingSetupBase::InterpolatorMode>();
|
||||
qDBusRegisterMetaType<CAircraftMatcherSetup::MatchingAlgorithm>();
|
||||
qDBusRegisterMetaType<CAircraftMatcherSetup::MatchingModeFlag>();
|
||||
qDBusRegisterMetaType<MatchingLogFlag>();
|
||||
qDBusRegisterMetaType<CAircraftMatcherSetup::PickSimilarStrategy>();
|
||||
CAircraftMatcherSetup::registerMetadata();
|
||||
qDBusRegisterMetaType<ReverseLookupLoggingFlag>();
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
36
src/blackmisc/simulation/reverselookup.h
Normal file
36
src/blackmisc/simulation/reverselookup.h
Normal file
@@ -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 <QMetaType>
|
||||
|
||||
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
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user