mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
refs #702, matching utils (unify log generation)
This commit is contained in:
35
src/blackcore/matchingutils.cpp
Normal file
35
src/blackcore/matchingutils.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2016
|
||||
* 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 and at http://www.swift-project.org/license.html. 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 "blackcore/matchingutils.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackCore;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
void CMatchingUtils::addLogDetailsToList(CStatusMessageList *log, const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, const QString &message, const CLogCategoryList &categories, CStatusMessage::StatusSeverity s)
|
||||
{
|
||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft.getCallsign(), message, categories, s);
|
||||
}
|
||||
|
||||
void CMatchingUtils::addLogDetailsToList(CStatusMessageList *log, const BlackMisc::Aviation::CCallsign &callsign, const QString &message, const CLogCategoryList &categories, CStatusMessage::StatusSeverity s)
|
||||
{
|
||||
if (!log) { return; }
|
||||
if (message.isEmpty()) { return; }
|
||||
log->push_back(CMatchingUtils::logMessage(callsign, message, categories, s));
|
||||
}
|
||||
|
||||
CStatusMessage CMatchingUtils::logMessage(const BlackMisc::Aviation::CCallsign &callsign, const QString &message, const CLogCategoryList &categories, CStatusMessage::StatusSeverity s)
|
||||
{
|
||||
const CStatusMessage m(categories, s, callsign.isEmpty() ? callsign.toQString() + ": " + message.trimmed() : message.trimmed());
|
||||
return m;
|
||||
}
|
||||
} // namespace
|
||||
52
src/blackcore/matchingutils.h
Normal file
52
src/blackcore/matchingutils.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* Copyright (C) 2016
|
||||
* 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 and at http://www.swift-project.org/license.html. 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 BLACKCORE_MATCHINGUTILS_H
|
||||
#define BLACKCORE_MATCHINGUTILS_H
|
||||
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
/*!
|
||||
* Matching utils
|
||||
*/
|
||||
class BLACKCORE_EXPORT CMatchingUtils
|
||||
{
|
||||
public:
|
||||
|
||||
//! Specialized log for matching / reverse lookup
|
||||
//! \threadsafe
|
||||
static void addLogDetailsToList(
|
||||
BlackMisc::CStatusMessageList *log, const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft,
|
||||
const QString &message, const BlackMisc::CLogCategoryList &categories = {},
|
||||
BlackMisc::CStatusMessage::StatusSeverity s = BlackMisc::CStatusMessage::SeverityInfo);
|
||||
|
||||
//! Specialized log for matching / reverse lookup
|
||||
//! \threadsafe
|
||||
static void addLogDetailsToList(
|
||||
BlackMisc::CStatusMessageList *log, const BlackMisc::Aviation::CCallsign &callsign,
|
||||
const QString &message, const BlackMisc::CLogCategoryList &categories = {},
|
||||
BlackMisc::CStatusMessage::StatusSeverity s = BlackMisc::CStatusMessage::SeverityInfo);
|
||||
|
||||
|
||||
//! Specialized log message for matching / reverse lookup
|
||||
//! \threadsafe
|
||||
static BlackMisc::CStatusMessage logMessage(
|
||||
const BlackMisc::Aviation::CCallsign &callsign,
|
||||
const QString &message, const BlackMisc::CLogCategoryList &categories = {},
|
||||
BlackMisc::CStatusMessage::StatusSeverity s = BlackMisc::CStatusMessage::SeverityInfo);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user