Files
pilotclient/src/blackmisc/simulation/matchinglog.cpp
Klaus Basan 002f9e6a9b 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
2019-04-11 22:12:12 +01:00

56 lines
2.4 KiB
C++

/* 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