refactor: clang-tidy

This commit is contained in:
Lars Toenning
2025-06-09 21:22:28 +02:00
parent 5004db1885
commit 71c868866c
12 changed files with 195 additions and 169 deletions

View File

@@ -19,6 +19,7 @@ Checks:
- '-readability-math-missing-parentheses' - '-readability-math-missing-parentheses'
- '-readability-avoid-unconditional-preprocessor-if' - '-readability-avoid-unconditional-preprocessor-if'
- '-readability-magic-numbers' - '-readability-magic-numbers'
- '-readability-container-size-empty'
- 'cppcoreguidelines-*' - 'cppcoreguidelines-*'
- '-cppcoreguidelines-avoid-magic-numbers' - '-cppcoreguidelines-avoid-magic-numbers'
- '-cppcoreguidelines-non-private-member-variables-in-classes' - '-cppcoreguidelines-non-private-member-variables-in-classes'

View File

@@ -97,7 +97,7 @@ namespace swift::core::afv::clients
if (!hasContexts()) { return; } if (!hasContexts()) { return; }
// Disconnect all previously connect signals between the AfvClient and the required contexts // Disconnect all previously connect signals between the AfvClient and the required contexts
for (auto context : QVector<QObject *> { sApp->getIContextOwnAircraft(), sApp->getIContextNetwork() }) for (auto *context : QVector<QObject *> { sApp->getIContextOwnAircraft(), sApp->getIContextNetwork() })
{ {
this->disconnect(context); this->disconnect(context);
context->disconnect(this); context->disconnect(this);
@@ -465,11 +465,8 @@ namespace swift::core::afv::clients
if (!enabledTransceivers.contains(id)) { return false; } if (!enabledTransceivers.contains(id)) { return false; }
const auto transceivers = this->getTransceivers(); // threadsafe const auto transceivers = this->getTransceivers(); // threadsafe
for (const TransceiverDto &dto : transceivers) return std::any_of(transceivers.cbegin(), transceivers.cend(),
{ [&id](const TransceiverDto &dto) { return dto.id == id; });
if (dto.id == id) { return true; }
}
return false;
} }
bool CAfvClient::isEnabledComUnit(CComSystem::ComUnit comUnit) const bool CAfvClient::isEnabledComUnit(CComSystem::ComUnit comUnit) const
@@ -507,7 +504,7 @@ namespace swift::core::afv::clients
void CAfvClient::updateComFrequency(CComSystem::ComUnit comUnit, const CFrequency &comFrequency) void CAfvClient::updateComFrequency(CComSystem::ComUnit comUnit, const CFrequency &comFrequency)
{ {
const quint32 freqHz = static_cast<quint32>(comFrequency.valueInteger(CFrequencyUnit::Hz())); const auto freqHz = static_cast<quint32>(comFrequency.valueInteger(CFrequencyUnit::Hz()));
this->updateComFrequency(comUnitToTransceiverId(comUnit), freqHz); this->updateComFrequency(comUnitToTransceiverId(comUnit), freqHz);
} }
@@ -592,11 +589,8 @@ namespace swift::core::afv::clients
bool CAfvClient::isTransmittingTransceiver(quint16 id) const bool CAfvClient::isTransmittingTransceiver(quint16 id) const
{ {
QMutexLocker lock(&m_mutexTransceivers); QMutexLocker lock(&m_mutexTransceivers);
for (const TxTransceiverDto &dto : m_transmittingTransceivers) return std::any_of(m_transmittingTransceivers.cbegin(), m_transmittingTransceivers.cend(),
{ [&id](const TxTransceiverDto &dto) { return dto.id == id; });
if (dto.id == id) { return true; }
}
return false;
} }
bool CAfvClient::isTransmittingComUnit(CComSystem::ComUnit comUnit) const bool CAfvClient::isTransmittingComUnit(CComSystem::ComUnit comUnit) const
@@ -747,10 +741,8 @@ namespace swift::core::afv::clients
double CAfvClient::getComOutputVolumeDb(CComSystem::ComUnit comUnit) const double CAfvClient::getComOutputVolumeDb(CComSystem::ComUnit comUnit) const
{ {
QMutexLocker lock(&m_mutexVolume); QMutexLocker lock(&m_mutexVolume);
if (comUnit == CComSystem::Com1) if (comUnit == CComSystem::Com1) return m_outputVolumeDbCom1;
return m_outputVolumeDbCom1; if (comUnit == CComSystem::Com2) return m_outputVolumeDbCom2;
else if (comUnit == CComSystem::Com2)
return m_outputVolumeDbCom2;
qFatal("Invalid COM unit"); qFatal("Invalid COM unit");
return 0; return 0;
} }
@@ -758,10 +750,8 @@ namespace swift::core::afv::clients
double CAfvClient::getOutputGainRatio(CComSystem::ComUnit comUnit) const double CAfvClient::getOutputGainRatio(CComSystem::ComUnit comUnit) const
{ {
QMutexLocker lock(&m_mutexVolume); QMutexLocker lock(&m_mutexVolume);
if (comUnit == CComSystem::Com1) if (comUnit == CComSystem::Com1) return m_outputGainRatioCom1;
return m_outputGainRatioCom1; if (comUnit == CComSystem::Com2) return m_outputGainRatioCom2;
else if (comUnit == CComSystem::Com2)
return m_outputGainRatioCom2;
qFatal("Invalid COM unit"); qFatal("Invalid COM unit");
return 0; return 0;
} }
@@ -784,7 +774,7 @@ namespace swift::core::afv::clients
{ {
QMutexLocker lock(&m_mutexVolume); QMutexLocker lock(&m_mutexVolume);
if (comUnit == CComSystem::Com1) { return m_outputVolumeCom1Normalized; } if (comUnit == CComSystem::Com1) { return m_outputVolumeCom1Normalized; }
else if (comUnit == CComSystem::Com2) { return m_outputVolumeCom2Normalized; } if (comUnit == CComSystem::Com2) { return m_outputVolumeCom2Normalized; }
qFatal("Invalid ComUnit"); qFatal("Invalid ComUnit");
return 0; return 0;
} }
@@ -1069,7 +1059,10 @@ namespace swift::core::afv::clients
const int failures = ++m_heartBeatFailures; const int failures = ++m_heartBeatFailures;
if (failures < 2) { return; } if (failures < 2) { return; }
QString un, pw, cs, client; QString un;
QString pw;
QString cs;
QString client;
{ {
QMutexLocker lock(&m_mutexConnection); QMutexLocker lock(&m_mutexConnection);
un = m_connection->getUserName(); un = m_connection->getUserName();
@@ -1331,17 +1324,17 @@ namespace swift::core::afv::clients
{ {
QMutexLocker lock(&m_mutex); QMutexLocker lock(&m_mutex);
CFrequency roundedFrequency(static_cast<int>(roundedFrequencyHz), CFrequencyUnit::Hz()); CFrequency roundedFrequency(static_cast<int>(roundedFrequencyHz), CFrequencyUnit::Hz());
const auto it = std::find_if( const auto it = std::find_if(m_aliasedStations.constBegin(), m_aliasedStations.constEnd(),
m_aliasedStations.constBegin(), m_aliasedStations.constEnd(), [roundedFrequency](const StationDto &d) { [roundedFrequency](const StationDto &d) {
if (d.frequencyAliasHz > 100000000 && if (d.frequencyAliasHz > 100000000 &&
roundedFrequency.value(CFrequencyUnit::Hz()) > 100000000) // both VHF roundedFrequency.value(CFrequencyUnit::Hz()) > 100000000) // both VHF
{ {
const int aliasedFreqHz = static_cast<int>(qRound(d.frequencyAliasHz / 1000.0)) * 1000; const int aliasedFreqHz = qRound(d.frequencyAliasHz / 1000.0) * 1000;
return CComSystem::isSameFrequency(CFrequency(aliasedFreqHz, CFrequencyUnit::Hz()), return CComSystem::isSameFrequency(
roundedFrequency); CFrequency(aliasedFreqHz, CFrequencyUnit::Hz()), roundedFrequency);
} }
return d.frequencyAliasHz == roundedFrequency.value(CFrequencyUnit::Hz()); return d.frequencyAliasHz == roundedFrequency.value(CFrequencyUnit::Hz());
}); });
if (it != m_aliasedStations.constEnd()) if (it != m_aliasedStations.constEnd())
{ {

View File

@@ -99,8 +99,6 @@ namespace swift::core
m_simulatorMaxRenderedDistance = maxRenderedDistance; m_simulatorMaxRenderedDistance = maxRenderedDistance;
} }
CAirspaceAnalyzer::~CAirspaceAnalyzer() {}
void CAirspaceAnalyzer::onNetworkPositionUpdate(const CAircraftSituation &situation, void CAirspaceAnalyzer::onNetworkPositionUpdate(const CAircraftSituation &situation,
const CTransponder &transponder) const CTransponder &transponder)
{ {
@@ -172,7 +170,7 @@ namespace swift::core
// this is a trick to not remove everything while debugging // this is a trick to not remove everything while debugging
const qint64 currentTimeMsEpoch = QDateTime::currentMSecsSinceEpoch(); const qint64 currentTimeMsEpoch = QDateTime::currentMSecsSinceEpoch();
const qint64 callDiffMs = currentTimeMsEpoch - m_lastWatchdogCallMsSinceEpoch; const qint64 callDiffMs = currentTimeMsEpoch - m_lastWatchdogCallMsSinceEpoch;
const qint64 callThresholdMs = static_cast<qint64>(updateInterval.count() * 1.5); constexpr auto callThresholdMs = static_cast<qint64>(updateInterval.count() * 1.5);
m_lastWatchdogCallMsSinceEpoch = currentTimeMsEpoch; m_lastWatchdogCallMsSinceEpoch = currentTimeMsEpoch;
if (callDiffMs > callThresholdMs) if (callDiffMs > callThresholdMs)
{ {
@@ -228,8 +226,9 @@ namespace swift::core
Q_ASSERT_X(!CThreadUtils::thisIsMainThread(), Q_FUNC_INFO, "Expect to run in background thread"); Q_ASSERT_X(!CThreadUtils::thisIsMainThread(), Q_FUNC_INFO, "Expect to run in background thread");
Q_ASSERT_X(thread() != qApp->thread(), Q_FUNC_INFO, "Expect to run in background thread affinity"); Q_ASSERT_X(thread() != qApp->thread(), Q_FUNC_INFO, "Expect to run in background thread affinity");
bool restricted, enabled; bool restricted {};
int maxAircraft; bool enabled {};
int maxAircraft {};
CLength maxRenderedDistance; CLength maxRenderedDistance;
{ {
QReadLocker l(&m_lockRestrictions); QReadLocker l(&m_lockRestrictions);

View File

@@ -63,7 +63,19 @@ namespace swift::core
fsd::CFSDClient *fsdClient, CAirspaceMonitor *airspaceMonitorParent); fsd::CFSDClient *fsdClient, CAirspaceMonitor *airspaceMonitorParent);
//! Destructor //! Destructor
virtual ~CAirspaceAnalyzer() override; ~CAirspaceAnalyzer() override = default;
//! Copy constructor
CAirspaceAnalyzer(const CAirspaceAnalyzer &) = delete;
//! Copy assignment
CAirspaceAnalyzer &operator=(const CAirspaceAnalyzer &) = delete;
//! Move constructor
CAirspaceAnalyzer(CAirspaceAnalyzer &&) = delete;
//! Move assignment
CAirspaceAnalyzer &operator=(CAirspaceAnalyzer &&) = delete;
//! Get the latest snapshot //! Get the latest snapshot
//! \threadsafe //! \threadsafe

View File

@@ -176,7 +176,7 @@ namespace swift::core
{ {
if (!myself || !sApp || sApp->isShuttingDown()) // cppcheck-suppress knownConditionTrueFalse if (!myself || !sApp || sApp->isShuttingDown()) // cppcheck-suppress knownConditionTrueFalse
{ {
return CFlightPlan(); return {};
} }
if (m_flightPlanCache.contains(callsign)) { plan = m_flightPlanCache[callsign]; } if (m_flightPlanCache.contains(callsign)) { plan = m_flightPlanCache[callsign]; }
} }
@@ -186,7 +186,7 @@ namespace swift::core
CFlightPlanRemarks CAirspaceMonitor::tryToGetFlightPlanRemarks(const CCallsign &callsign) const CFlightPlanRemarks CAirspaceMonitor::tryToGetFlightPlanRemarks(const CCallsign &callsign) const
{ {
if (callsign.isEmpty()) { return CFlightPlanRemarks(); } if (callsign.isEmpty()) { return {}; }
// full flight plan's remarks // full flight plan's remarks
if (m_flightPlanCache.contains(callsign)) { return m_flightPlanCache[callsign].getFlightPlanRemarks(); } if (m_flightPlanCache.contains(callsign)) { return m_flightPlanCache[callsign].getFlightPlanRemarks(); }
@@ -198,7 +198,7 @@ namespace swift::core
} }
// unsupported // unsupported
return CFlightPlanRemarks(); return {};
} }
CAtcStationList CAirspaceMonitor::getAtcStationsOnlineRecalculated() CAtcStationList CAirspaceMonitor::getAtcStationsOnlineRecalculated()
@@ -524,14 +524,14 @@ namespace swift::core
if (!sApp || sApp->isShuttingDown() || !sApp->getWebDataServices()) { return; } if (!sApp || sApp->isShuttingDown() || !sApp->getWebDataServices()) { return; }
CClientList clients(this->getClients()); // copy CClientList clients(this->getClients()); // copy
bool changed = false; bool changed = false;
for (auto client = clients.begin(); client != clients.end(); ++client) for (auto &client : clients)
{ {
if (client->hasSpecifiedVoiceCapabilities()) { continue; } // we already have voice caps if (client.hasSpecifiedVoiceCapabilities()) { continue; } // we already have voice caps
const CVoiceCapabilities vc = const CVoiceCapabilities vc =
sApp->getWebDataServices()->getVoiceCapabilityForCallsign(client->getCallsign()); sApp->getWebDataServices()->getVoiceCapabilityForCallsign(client.getCallsign());
if (vc.isUnknown()) { continue; } if (vc.isUnknown()) { continue; }
changed = true; changed = true;
client->setVoiceCapabilities(vc); client.setVoiceCapabilities(vc);
} }
if (!changed) { return; } if (!changed) { return; }
this->setClients(clients); this->setClients(clients);
@@ -756,7 +756,7 @@ namespace swift::core
// TODO Replace with Qt 6.0 QStringView::slice() // TODO Replace with Qt 6.0 QStringView::slice()
zuluTimeView.chop(1); // Remove z zuluTimeView.chop(1); // Remove z
bool ok; bool ok {};
const int h = zuluTimeView.left(2).toInt(&ok); const int h = zuluTimeView.left(2).toInt(&ok);
if (!ok) { return; } if (!ok) { return; }
const int m = zuluTimeView.right(2).toInt(&ok); const int m = zuluTimeView.right(2).toInt(&ok);
@@ -1063,13 +1063,10 @@ namespace swift::core
callsign, rv.model.getAircraftIcaoCodeDesignator(), rv.model.getAirlineIcaoCodeVDesignator(), callsign, rv.model.getAircraftIcaoCodeDesignator(), rv.model.getAirlineIcaoCodeVDesignator(),
rv.model.getLivery().getCombinedCode(), modelString, type, log, false); rv.model.getLivery().getCombinedCode(), modelString, type, log, false);
} }
else lookupModel = rv.model;
{ CCallsign::addLogDetailsToList(log, callsign,
lookupModel = rv.model; QStringLiteral("Matching script: Using model from matching script"),
CCallsign::addLogDetailsToList(log, callsign, CAirspaceMonitor::getLogCategories());
QStringLiteral("Matching script: Using model from matching script"),
CAirspaceMonitor::getLogCategories());
}
} }
} }
else { CCallsign::addLogDetailsToList(log, callsign, QStringLiteral("No reverse lookup script used")); } else { CCallsign::addLogDetailsToList(log, callsign, QStringLiteral("No reverse lookup script used")); }
@@ -1451,19 +1448,19 @@ namespace swift::core
if (callsign.isEmpty()) { return; } if (callsign.isEmpty()) { return; }
unsigned long pp = 0; unsigned long pp = 0;
bool ok; bool ok {};
pp = config.toULong(&ok, 10); pp = config.toULong(&ok, 10);
bool gear = (pp & 1u); bool gear = (pp & 1U);
bool landLight = (pp & 2u); bool landLight = (pp & 2U);
bool navLight = (pp & 4u); bool navLight = (pp & 4U);
bool strobeLight = (pp & 8u); bool strobeLight = (pp & 8U);
bool beaconLight = (pp & 16u); bool beaconLight = (pp & 16U);
bool taxiLight = (pp & 32u); bool taxiLight = (pp & 32U);
bool engine1Running = (pp & 64u); bool engine1Running = (pp & 64U);
bool engine2Running = (pp & 128u); bool engine2Running = (pp & 128U);
bool engine3Running = (pp & 256u); bool engine3Running = (pp & 256U);
bool engine4Running = (pp & 512u); bool engine4Running = (pp & 512U);
// CLogMessage(this).info(u"taxiLight %1 landLight %2 beaconLight %3 strobeLight %4 gear %5") << taxiLight << // CLogMessage(this).info(u"taxiLight %1 landLight %2 beaconLight %3 strobeLight %4 gear %5") << taxiLight <<
// landLight << beaconLight << strobeLight << gear; CLogMessage(this).info(u"engine1Running %1 engine2Running %2 // landLight << beaconLight << strobeLight << gear; CLogMessage(this).info(u"engine1Running %1 engine2Running %2

View File

@@ -53,7 +53,7 @@ namespace swift::core
//! Keeps track of other entities in the airspace: aircraft, ATC stations, etc. //! Keeps track of other entities in the airspace: aircraft, ATC stations, etc.
//! Central instance of data for \sa IRemoteAircraftProvider. //! Central instance of data for \sa IRemoteAircraftProvider.
class SWIFT_CORE_EXPORT CAirspaceMonitor : class SWIFT_CORE_EXPORT CAirspaceMonitor final :
public swift::misc::simulation::CRemoteAircraftProvider, // those data will be provided from the class public swift::misc::simulation::CRemoteAircraftProvider, // those data will be provided from the class
// CAirspaceMonitor // CAirspaceMonitor
public swift::misc::network::CClientProvider, // those data will be provided from the class CAirspaceMonitor public swift::misc::network::CClientProvider, // those data will be provided from the class CAirspaceMonitor
@@ -198,7 +198,7 @@ namespace swift::core
FsInnPacket() {} FsInnPacket() {}
//! Constructor //! Constructor
FsInnPacket(const QString &aircraftIcaoDesignator, const QString &airlineDesignator, FsInnPacket(const QString &aircraftIcaoDesignator, const QString &airlineIcaoDesignator,
const QString &combinedCode, const QString &modelString); const QString &combinedCode, const QString &modelString);
QString aircraftIcaoDesignator; QString aircraftIcaoDesignator;
@@ -444,7 +444,7 @@ namespace swift::core
//! Receive FSInn packet //! Receive FSInn packet
//! \remark This can happen even without a query before //! \remark This can happen even without a query before
void onCustomFSInnPacketReceived(const swift::misc::aviation::CCallsign &callsign, void onCustomFSInnPacketReceived(const swift::misc::aviation::CCallsign &callsign,
const QString &airlineIcaoDesignator, const QString &aircraftDesignator, const QString &airlineIcaoDesignator, const QString &aircraftIcaoDesignator,
const QString &combinedAircraftType, const QString &modelString); const QString &combinedAircraftType, const QString &modelString);
void onRealNameReplyReceived(const swift::misc::aviation::CCallsign &callsign, const QString &realname); void onRealNameReplyReceived(const swift::misc::aviation::CCallsign &callsign, const QString &realname);

View File

@@ -141,7 +141,7 @@ namespace swift::core::db
if (c > 0) if (c > 0)
{ {
const CStatusMessage m = modelCaches.setCachedModels(simulatorModels, singleSimulator); const CStatusMessage m = modelCaches.setCachedModels(simulatorModels, singleSimulator);
const int msElapsed = time.elapsed(); const qint64 msElapsed = time.elapsed();
this->addHistory(CLogMessage(this).info(u"Consolidated %1 models (%2) for '%3' in %4ms") this->addHistory(CLogMessage(this).info(u"Consolidated %1 models (%2) for '%3' in %4ms")
<< c << description << singleSimulator.convertToQString() << msElapsed); << c << description << singleSimulator.convertToQString() << msElapsed);
CLogMessage::preformatted(m); CLogMessage::preformatted(m);

View File

@@ -17,7 +17,6 @@
#include "core/swiftcoreexport.h" #include "core/swiftcoreexport.h"
#include "core/vatsim/vatsimsettings.h" #include "core/vatsim/vatsimsettings.h"
#include "misc/logcategories.h"
#include "misc/network/urlloglist.h" #include "misc/network/urlloglist.h"
#include "misc/worker.h" #include "misc/worker.h"
@@ -39,7 +38,19 @@ namespace swift::core
static const QStringList &getLogCategories(); static const QStringList &getLogCategories();
//! Destructor //! Destructor
virtual ~CThreadedReader() = default; ~CThreadedReader() override = default;
//! Copy constructor
CThreadedReader(const CThreadedReader &) = delete;
//! Copy assignment
CThreadedReader &operator=(const CThreadedReader &) = delete;
//! Move constructor
CThreadedReader(CThreadedReader &&) = delete;
//! Move assignment
CThreadedReader &operator=(CThreadedReader &&) = delete;
//! Thread safe, get update timestamp //! Thread safe, get update timestamp
//! \threadsafe //! \threadsafe

View File

@@ -47,7 +47,7 @@ using namespace swift::misc::weather;
namespace swift::core namespace swift::core
{ {
CWebDataServices::CWebDataServices(CWebReaderFlags::WebReader readers, CWebDataServices::CWebDataServices(CWebReaderFlags::WebReader readerFlags,
const CDatabaseReaderConfigList &dbReaderConfig, QObject *parent) const CDatabaseReaderConfigList &dbReaderConfig, QObject *parent)
: QObject(parent), m_dbReaderConfig(dbReaderConfig) : QObject(parent), m_dbReaderConfig(dbReaderConfig)
{ {
@@ -65,22 +65,23 @@ namespace swift::core
// check if I need info objects // check if I need info objects
const bool readFromSwiftDb = dbReaderConfig.possiblyReadsFromSwiftDb(); // DB read access const bool readFromSwiftDb = dbReaderConfig.possiblyReadsFromSwiftDb(); // DB read access
const bool writeToSwiftDb = dbReaderConfig.possiblyWritesToSwiftDb(); // DB write access const bool writeToSwiftDb = dbReaderConfig.possiblyWritesToSwiftDb(); // DB write access
if (!readFromSwiftDb && readers.testFlag(CWebReaderFlags::DbInfoDataReader)) if (!readFromSwiftDb && readerFlags.testFlag(CWebReaderFlags::DbInfoDataReader))
{ {
// will remove info reader because not needed // will remove info reader because not needed
readers &= ~CWebReaderFlags::DbInfoDataReader; readerFlags &= ~CWebReaderFlags::DbInfoDataReader;
CLogMessage(this).info(u"Remove info object reader because not needed"); CLogMessage(this).info(u"Remove info object reader because not needed");
} }
// get entities to be read // get entities to be read
CEntityFlags::Entity entities = CWebReaderFlags::allEntitiesForReaders(readers); CEntityFlags::Entity entities = CWebReaderFlags::allEntitiesForReaders(readerFlags);
if (entities.testFlag(CEntityFlags::DbInfoObjectEntity)) if (entities.testFlag(CEntityFlags::DbInfoObjectEntity))
{ {
Q_ASSERT_X(readers.testFlag(CWebReaderFlags::DbInfoDataReader), Q_FUNC_INFO, "info object but no reader"); Q_ASSERT_X(readerFlags.testFlag(CWebReaderFlags::DbInfoDataReader), Q_FUNC_INFO,
"info object but no reader");
CLogMessage(this).info(u"Using info objects for swift DB entities"); CLogMessage(this).info(u"Using info objects for swift DB entities");
} }
this->initReaders(readers, entities); // reads info objects if required this->initReaders(readerFlags, entities); // reads info objects if required
if (writeToSwiftDb) { this->initWriters(); } if (writeToSwiftDb) { this->initWriters(); }
// make sure this is called in event queue, so pending tasks cam be performed // make sure this is called in event queue, so pending tasks cam be performed
@@ -98,7 +99,7 @@ namespace swift::core
CServerList CWebDataServices::getVatsimFsdServers() const CServerList CWebDataServices::getVatsimFsdServers() const
{ {
if (m_vatsimServerFileReader) { return m_vatsimServerFileReader->getFsdServers(); } if (m_vatsimServerFileReader) { return m_vatsimServerFileReader->getFsdServers(); }
return CServerList(); return {};
} }
CUrl CWebDataServices::getVatsimMetarUrl() const CUrl CWebDataServices::getVatsimMetarUrl() const
@@ -116,19 +117,19 @@ namespace swift::core
CUserList CWebDataServices::getUsersForCallsign(const CCallsign &callsign) const CUserList CWebDataServices::getUsersForCallsign(const CCallsign &callsign) const
{ {
if (m_vatsimDataFileReader) { return m_vatsimDataFileReader->getUsersForCallsign(callsign); } if (m_vatsimDataFileReader) { return m_vatsimDataFileReader->getUsersForCallsign(callsign); }
return CUserList(); return {};
} }
CAtcStationList CWebDataServices::getAtcStationsForCallsign(const CCallsign &callsign) const CAtcStationList CWebDataServices::getAtcStationsForCallsign(const CCallsign &callsign) const
{ {
if (m_vatsimDataFileReader) { return m_vatsimDataFileReader->getAtcStationsForCallsign(callsign); } if (m_vatsimDataFileReader) { return m_vatsimDataFileReader->getAtcStationsForCallsign(callsign); }
return CAtcStationList(); return {};
} }
CVoiceCapabilities CWebDataServices::getVoiceCapabilityForCallsign(const CCallsign &callsign) const CVoiceCapabilities CWebDataServices::getVoiceCapabilityForCallsign(const CCallsign &callsign) const
{ {
if (m_vatsimDataFileReader) { return m_vatsimDataFileReader->getVoiceCapabilityForCallsign(callsign); } if (m_vatsimDataFileReader) { return m_vatsimDataFileReader->getVoiceCapabilityForCallsign(callsign); }
return CVoiceCapabilities(); return {};
} }
void CWebDataServices::updateWithVatsimDataFileData(CSimulatedAircraft &aircraftToBeUdpated) const void CWebDataServices::updateWithVatsimDataFileData(CSimulatedAircraft &aircraftToBeUdpated) const
@@ -139,13 +140,13 @@ namespace swift::core
CStatusMessageList CWebDataServices::asyncPublishModels(const CAircraftModelList &modelsToBePublished) const CStatusMessageList CWebDataServices::asyncPublishModels(const CAircraftModelList &modelsToBePublished) const
{ {
if (m_databaseWriter) { return m_databaseWriter->asyncPublishModels(modelsToBePublished, ""); } if (m_databaseWriter) { return m_databaseWriter->asyncPublishModels(modelsToBePublished, ""); }
return CStatusMessageList(); return {};
} }
CStatusMessageList CWebDataServices::asyncAutoPublish(const CAutoPublishData &data) const CStatusMessageList CWebDataServices::asyncAutoPublish(const CAutoPublishData &data) const
{ {
if (m_databaseWriter) { return m_databaseWriter->asyncAutoPublish(data); } if (m_databaseWriter) { return m_databaseWriter->asyncAutoPublish(data); }
return CStatusMessageList(); return {};
} }
void CWebDataServices::triggerReadOfDbInfoObjects() { initDbInfoObjectReaderAndTriggerRead(); } void CWebDataServices::triggerReadOfDbInfoObjects() { initDbInfoObjectReaderAndTriggerRead(); }
@@ -340,25 +341,25 @@ namespace swift::core
QDateTime CWebDataServices::getCacheTimestamp(CEntityFlags::Entity entity) const QDateTime CWebDataServices::getCacheTimestamp(CEntityFlags::Entity entity) const
{ {
Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO, "Need single entity"); Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO, "Need single entity");
if (!CEntityFlags::anySwiftDbEntity(entity)) { return QDateTime(); } if (!CEntityFlags::anySwiftDbEntity(entity)) { return {}; }
const CDatabaseReader *dr = this->getDbReader(entity); const CDatabaseReader *dr = this->getDbReader(entity);
if (!dr) { return QDateTime(); } if (!dr) { return {}; }
return dr->getCacheTimestamp(entity); return dr->getCacheTimestamp(entity);
} }
QDateTime CWebDataServices::getLatestDbEntityTimestamp(CEntityFlags::Entity entity) const QDateTime CWebDataServices::getLatestDbEntityTimestamp(CEntityFlags::Entity entity) const
{ {
Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO, "Need single entity"); Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO, "Need single entity");
if (!CEntityFlags::anySwiftDbEntity(entity)) { return QDateTime(); } if (!CEntityFlags::anySwiftDbEntity(entity)) { return {}; }
const CInfoDataReader *ir = this->getDbInfoDataReader(); const CInfoDataReader *ir = this->getDbInfoDataReader();
if (!ir) { return QDateTime(); } if (!ir) { return {}; }
return ir->getLatestEntityTimestampFromDbInfoObjects(entity); return ir->getLatestEntityTimestampFromDbInfoObjects(entity);
} }
QDateTime CWebDataServices::getLatestSharedInfoObjectTimestamp(CEntityFlags::Entity entity) const QDateTime CWebDataServices::getLatestSharedInfoObjectTimestamp(CEntityFlags::Entity entity) const
{ {
const CDatabaseReader *reader = this->getDbReader(entity); const CDatabaseReader *reader = this->getDbReader(entity);
if (!reader) { return QDateTime(); } if (!reader) { return {}; }
Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO, "need single entity"); Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO, "need single entity");
return reader->getLatestEntityTimestampFromSharedInfoObjects(entity); return reader->getLatestEntityTimestampFromSharedInfoObjects(entity);
} }
@@ -427,11 +428,8 @@ namespace swift::core
if (!dr) { return -1; } if (!dr) { return -1; }
return dr->getCacheCount(entity); return dr->getCacheCount(entity);
} }
else // non DB/shared entities would go here
{ return -1;
// non DB/shared entities would go here
return -1;
}
} }
int CWebDataServices::getDbInfoObjectCount(CEntityFlags::Entity entity) const int CWebDataServices::getDbInfoObjectCount(CEntityFlags::Entity entity) const
@@ -510,7 +508,7 @@ namespace swift::core
CDistributorList CWebDataServices::getDistributors() const CDistributorList CWebDataServices::getDistributors() const
{ {
if (m_modelDataReader) { return m_modelDataReader->getDistributors(); } if (m_modelDataReader) { return m_modelDataReader->getDistributors(); }
return CDistributorList(); return {};
} }
int CWebDataServices::getDistributorsCount() const int CWebDataServices::getDistributorsCount() const
@@ -522,26 +520,26 @@ namespace swift::core
CDistributor CWebDataServices::getDistributorForDbKey(const QString &key) const CDistributor CWebDataServices::getDistributorForDbKey(const QString &key) const
{ {
if (m_modelDataReader) { return m_modelDataReader->getDistributorForDbKey(key); } if (m_modelDataReader) { return m_modelDataReader->getDistributorForDbKey(key); }
return CDistributor(); return {};
} }
CDistributor CWebDataServices::smartDistributorSelector(const CDistributor &distributor) const CDistributor CWebDataServices::smartDistributorSelector(const CDistributor &distributor) const
{ {
if (m_modelDataReader) { return m_modelDataReader->smartDistributorSelector(distributor); } if (m_modelDataReader) { return m_modelDataReader->smartDistributorSelector(distributor); }
return CDistributor(); return {};
} }
CDistributor CWebDataServices::smartDistributorSelector(const CDistributor &distributor, CDistributor CWebDataServices::smartDistributorSelector(const CDistributor &distributor,
const CAircraftModel &model) const const CAircraftModel &model) const
{ {
if (m_modelDataReader) { return m_modelDataReader->smartDistributorSelector(distributor, model); } if (m_modelDataReader) { return m_modelDataReader->smartDistributorSelector(distributor, model); }
return CDistributor(); return {};
} }
CLiveryList CWebDataServices::getLiveries() const CLiveryList CWebDataServices::getLiveries() const
{ {
if (m_modelDataReader) { return m_modelDataReader->getLiveries(); } if (m_modelDataReader) { return m_modelDataReader->getLiveries(); }
return CLiveryList(); return {};
} }
int CWebDataServices::getLiveriesCount() const int CWebDataServices::getLiveriesCount() const
@@ -553,25 +551,25 @@ namespace swift::core
CLivery CWebDataServices::getLiveryForCombinedCode(const QString &combinedCode) const CLivery CWebDataServices::getLiveryForCombinedCode(const QString &combinedCode) const
{ {
if (m_modelDataReader) { return m_modelDataReader->getLiveryForCombinedCode(combinedCode); } if (m_modelDataReader) { return m_modelDataReader->getLiveryForCombinedCode(combinedCode); }
return CLivery(); return {};
} }
CLivery CWebDataServices::getTempLiveryOrDefault() const CLivery CWebDataServices::getTempLiveryOrDefault() const
{ {
if (m_modelDataReader) { return m_modelDataReader->getLiveryForCombinedCode(CLivery::tempLiveryCode()); } if (m_modelDataReader) { return m_modelDataReader->getLiveryForCombinedCode(CLivery::tempLiveryCode()); }
return CLivery(); return {};
} }
CLivery CWebDataServices::getStdLiveryForAirlineCode(const CAirlineIcaoCode &icao) const CLivery CWebDataServices::getStdLiveryForAirlineCode(const CAirlineIcaoCode &icao) const
{ {
if (m_modelDataReader) { return m_modelDataReader->getStdLiveryForAirlineVDesignator(icao); } if (m_modelDataReader) { return m_modelDataReader->getStdLiveryForAirlineVDesignator(icao); }
return CLivery(); return {};
} }
CLivery CWebDataServices::getLiveryForDbKey(int id) const CLivery CWebDataServices::getLiveryForDbKey(int id) const
{ {
if (m_modelDataReader) { return m_modelDataReader->getLiveryForDbKey(id); } if (m_modelDataReader) { return m_modelDataReader->getLiveryForDbKey(id); }
return CLivery(); return {};
} }
CLivery CWebDataServices::smartLiverySelector(const CLivery &livery) const CLivery CWebDataServices::smartLiverySelector(const CLivery &livery) const
@@ -583,7 +581,7 @@ namespace swift::core
CAircraftModelList CWebDataServices::getModels() const CAircraftModelList CWebDataServices::getModels() const
{ {
if (m_modelDataReader) { return m_modelDataReader->getModels(); } if (m_modelDataReader) { return m_modelDataReader->getModels(); }
return CAircraftModelList(); return {};
} }
int CWebDataServices::getModelsCount() const int CWebDataServices::getModelsCount() const
@@ -595,19 +593,19 @@ namespace swift::core
QSet<int> CWebDataServices::getModelDbKeys() const QSet<int> CWebDataServices::getModelDbKeys() const
{ {
if (m_modelDataReader) { return m_modelDataReader->getModelDbKeys(); } if (m_modelDataReader) { return m_modelDataReader->getModelDbKeys(); }
return QSet<int>(); return {};
} }
QStringList CWebDataServices::getModelStrings(bool sort) const QStringList CWebDataServices::getModelStrings(bool sort) const
{ {
if (m_modelDataReader) { return m_modelDataReader->getModelStringList(sort); } if (m_modelDataReader) { return m_modelDataReader->getModelStringList(sort); }
return QStringList(); return {};
} }
QStringList CWebDataServices::getModelCompleterStrings(bool sorted, const CSimulatorInfo &simulator) const QStringList CWebDataServices::getModelCompleterStrings(bool sorted, const CSimulatorInfo &simulator) const
{ {
if (m_modelDataReader) { return m_modelDataReader->getModels().toCompleterStrings(sorted, simulator); } if (m_modelDataReader) { return m_modelDataReader->getModels().toCompleterStrings(sorted, simulator); }
return QStringList(); return {};
} }
CAircraftModelList CAircraftModelList
@@ -619,13 +617,13 @@ namespace swift::core
return m_modelDataReader->getModelsForAircraftDesignatorAndLiveryCombinedCode(aircraftDesignator, return m_modelDataReader->getModelsForAircraftDesignatorAndLiveryCombinedCode(aircraftDesignator,
combinedCode); combinedCode);
} }
return CAircraftModelList(); return {};
} }
CAircraftModel CWebDataServices::getModelForModelString(const QString &modelString) const CAircraftModel CWebDataServices::getModelForModelString(const QString &modelString) const
{ {
if (m_modelDataReader) { return m_modelDataReader->getModelForModelString(modelString); } if (m_modelDataReader) { return m_modelDataReader->getModelForModelString(modelString); }
return CAircraftModel(); return {};
} }
bool CWebDataServices::containsModelString(const QString &modelString) const bool CWebDataServices::containsModelString(const QString &modelString) const
@@ -637,13 +635,13 @@ namespace swift::core
CAircraftModel CWebDataServices::getModelForDbKey(int dbKey) const CAircraftModel CWebDataServices::getModelForDbKey(int dbKey) const
{ {
if (m_modelDataReader) { return m_modelDataReader->getModelForDbKey(dbKey); } if (m_modelDataReader) { return m_modelDataReader->getModelForDbKey(dbKey); }
return CAircraftModel(); return {};
} }
CAircraftIcaoCodeList CWebDataServices::getAircraftIcaoCodes() const CAircraftIcaoCodeList CWebDataServices::getAircraftIcaoCodes() const
{ {
if (m_icaoDataReader) { return m_icaoDataReader->getAircraftIcaoCodes(); } if (m_icaoDataReader) { return m_icaoDataReader->getAircraftIcaoCodes(); }
return CAircraftIcaoCodeList(); return {};
} }
int CWebDataServices::getAircraftIcaoCodesCount() const int CWebDataServices::getAircraftIcaoCodesCount() const
@@ -655,7 +653,7 @@ namespace swift::core
CAircraftIcaoCode CWebDataServices::getAircraftIcaoCodeForDesignator(const QString &designator) const CAircraftIcaoCode CWebDataServices::getAircraftIcaoCodeForDesignator(const QString &designator) const
{ {
if (m_icaoDataReader) { return m_icaoDataReader->getAircraftIcaoCodeForDesignator(designator); } if (m_icaoDataReader) { return m_icaoDataReader->getAircraftIcaoCodeForDesignator(designator); }
return CAircraftIcaoCode(); return {};
} }
int CWebDataServices::getAircraftIcaoCodesForDesignatorCount(const QString &designator) const int CWebDataServices::getAircraftIcaoCodesForDesignatorCount(const QString &designator) const
@@ -665,22 +663,22 @@ namespace swift::core
QSet<QString> CWebDataServices::getAircraftDesignatorsForAirline(const CAirlineIcaoCode &airline) const QSet<QString> CWebDataServices::getAircraftDesignatorsForAirline(const CAirlineIcaoCode &airline) const
{ {
if (!airline.hasValidDesignator()) { return QSet<QString>(); } if (!airline.hasValidDesignator()) { return {}; }
if (m_modelDataReader) { return m_modelDataReader->getAircraftDesignatorsForAirline(airline); } if (m_modelDataReader) { return m_modelDataReader->getAircraftDesignatorsForAirline(airline); }
return QSet<QString>(); return {};
} }
CAircraftIcaoCodeList CWebDataServices::getAircraftIcaoCodesForAirline(const CAirlineIcaoCode &airline) const CAircraftIcaoCodeList CWebDataServices::getAircraftIcaoCodesForAirline(const CAirlineIcaoCode &airline) const
{ {
if (!airline.hasValidDesignator()) { return CAircraftIcaoCodeList(); } if (!airline.hasValidDesignator()) { return {}; }
if (m_modelDataReader) { return m_modelDataReader->getAicraftIcaoCodesForAirline(airline); } if (m_modelDataReader) { return m_modelDataReader->getAicraftIcaoCodesForAirline(airline); }
return CAircraftIcaoCodeList(); return {};
} }
CAircraftCategoryList CWebDataServices::getAircraftCategories() const CAircraftCategoryList CWebDataServices::getAircraftCategories() const
{ {
if (m_icaoDataReader) { return m_icaoDataReader->getAircraftCategories(); } if (m_icaoDataReader) { return m_icaoDataReader->getAircraftCategories(); }
return CAircraftCategoryList(); return {};
} }
int CWebDataServices::getAircraftCategoriesCount() const int CWebDataServices::getAircraftCategoriesCount() const
@@ -699,13 +697,13 @@ namespace swift::core
CAircraftIcaoCodeList CWebDataServices::getAircraftIcaoCodesForDesignator(const QString &designator) const CAircraftIcaoCodeList CWebDataServices::getAircraftIcaoCodesForDesignator(const QString &designator) const
{ {
if (m_icaoDataReader) { return m_icaoDataReader->getAircraftIcaoCodesForDesignator(designator); } if (m_icaoDataReader) { return m_icaoDataReader->getAircraftIcaoCodesForDesignator(designator); }
return CAircraftIcaoCodeList(); return {};
} }
CAircraftIcaoCode CWebDataServices::getAircraftIcaoCodeForDbKey(int key) const CAircraftIcaoCode CWebDataServices::getAircraftIcaoCodeForDbKey(int key) const
{ {
if (m_icaoDataReader) { return m_icaoDataReader->getAircraftIcaoCodeForDbKey(key); } if (m_icaoDataReader) { return m_icaoDataReader->getAircraftIcaoCodeForDbKey(key); }
return CAircraftIcaoCode(); return {};
} }
CAircraftIcaoCode CWebDataServices::smartAircraftIcaoSelector(const CAircraftIcaoCode &icao) const CAircraftIcaoCode CWebDataServices::smartAircraftIcaoSelector(const CAircraftIcaoCode &icao) const
@@ -717,7 +715,7 @@ namespace swift::core
CAirlineIcaoCodeList CWebDataServices::getAirlineIcaoCodes() const CAirlineIcaoCodeList CWebDataServices::getAirlineIcaoCodes() const
{ {
if (m_icaoDataReader) { return m_icaoDataReader->getAirlineIcaoCodes(); } if (m_icaoDataReader) { return m_icaoDataReader->getAirlineIcaoCodes(); }
return CAirlineIcaoCodeList(); return {};
} }
bool CWebDataServices::containsAirlineIcaoDesignator(const QString &designator) const bool CWebDataServices::containsAirlineIcaoDesignator(const QString &designator) const
@@ -731,20 +729,20 @@ namespace swift::core
CWebDataServices::getAirlineIcaoCodeForUniqueDesignatorOrDefault(const QString &designator, CWebDataServices::getAirlineIcaoCodeForUniqueDesignatorOrDefault(const QString &designator,
bool preferOperatingAirlines) const bool preferOperatingAirlines) const
{ {
if (designator.isEmpty()) { return CAirlineIcaoCode(); } if (designator.isEmpty()) { return {}; }
if (m_icaoDataReader) if (m_icaoDataReader)
{ {
return m_icaoDataReader->getAirlineIcaoCodeForUniqueDesignatorOrDefault(designator, return m_icaoDataReader->getAirlineIcaoCodeForUniqueDesignatorOrDefault(designator,
preferOperatingAirlines); preferOperatingAirlines);
} }
return CAirlineIcaoCode(); return {};
} }
CAirlineIcaoCode CWebDataServices::getAirlineIcaoCodeForUniqueIataCodeOrDefault(const QString &iataCode) const CAirlineIcaoCode CWebDataServices::getAirlineIcaoCodeForUniqueIataCodeOrDefault(const QString &iataCode) const
{ {
if (iataCode.isEmpty()) { return CAirlineIcaoCode(); } if (iataCode.isEmpty()) { return {}; }
if (m_icaoDataReader) { return m_icaoDataReader->getAirlineIcaoCodeForUniqueIataCodeOrDefault(iataCode); } if (m_icaoDataReader) { return m_icaoDataReader->getAirlineIcaoCodeForUniqueIataCodeOrDefault(iataCode); }
return CAirlineIcaoCode(); return {};
} }
int CWebDataServices::getAirlineIcaoCodesCount() const int CWebDataServices::getAirlineIcaoCodesCount() const
@@ -779,12 +777,12 @@ namespace swift::core
const CCallsign &callsign) const const CCallsign &callsign) const
{ {
if (m_icaoDataReader) { return m_icaoDataReader->smartAirlineIcaoSelector(icaoPattern, callsign); } if (m_icaoDataReader) { return m_icaoDataReader->smartAirlineIcaoSelector(icaoPattern, callsign); }
return CAirlineIcaoCode(); return {};
} }
CAirlineIcaoCode CWebDataServices::findBestMatchByCallsign(const CCallsign &callsign) const CAirlineIcaoCode CWebDataServices::findBestMatchByCallsign(const CCallsign &callsign) const
{ {
if (callsign.isEmpty()) { return CAirlineIcaoCode(); } if (callsign.isEmpty()) { return {}; }
const CAirlineIcaoCodeList icaos(this->getAirlineIcaoCodes()); const CAirlineIcaoCodeList icaos(this->getAirlineIcaoCodes());
return icaos.findBestMatchByCallsign(callsign); return icaos.findBestMatchByCallsign(callsign);
} }
@@ -792,13 +790,13 @@ namespace swift::core
CAirlineIcaoCode CWebDataServices::getAirlineIcaoCodeForDbKey(int key) const CAirlineIcaoCode CWebDataServices::getAirlineIcaoCodeForDbKey(int key) const
{ {
if (m_icaoDataReader) { return m_icaoDataReader->getAirlineIcaoCodeForDbKey(key); } if (m_icaoDataReader) { return m_icaoDataReader->getAirlineIcaoCodeForDbKey(key); }
return CAirlineIcaoCode(); return {};
} }
CCountryList CWebDataServices::getCountries() const CCountryList CWebDataServices::getCountries() const
{ {
if (m_icaoDataReader) { return m_icaoDataReader->getCountries(); } if (m_icaoDataReader) { return m_icaoDataReader->getCountries(); }
return CCountryList(); return {};
} }
int CWebDataServices::getCountriesCount() const int CWebDataServices::getCountriesCount() const
@@ -810,13 +808,13 @@ namespace swift::core
CCountry CWebDataServices::getCountryForName(const QString &name) const CCountry CWebDataServices::getCountryForName(const QString &name) const
{ {
if (m_icaoDataReader) { return m_icaoDataReader->getCountryForName(name); } if (m_icaoDataReader) { return m_icaoDataReader->getCountryForName(name); }
return CCountry(); return {};
} }
CAirportList CWebDataServices::getAirports() const CAirportList CWebDataServices::getAirports() const
{ {
if (m_airportDataReader) { return m_airportDataReader->getAirports(); } if (m_airportDataReader) { return m_airportDataReader->getAirports(); }
return CAirportList(); return {};
} }
int CWebDataServices::getAirportsCount() const int CWebDataServices::getAirportsCount() const
@@ -828,19 +826,19 @@ namespace swift::core
CAirport CWebDataServices::getAirportForIcaoDesignator(const QString &icao) const CAirport CWebDataServices::getAirportForIcaoDesignator(const QString &icao) const
{ {
if (m_airportDataReader) { return m_airportDataReader->getAirportForIcaoDesignator(icao); } if (m_airportDataReader) { return m_airportDataReader->getAirportForIcaoDesignator(icao); }
return CAirport(); return {};
} }
CAirport CWebDataServices::getAirportForNameOrLocation(const QString &nameOrLocation) const CAirport CWebDataServices::getAirportForNameOrLocation(const QString &nameOrLocation) const
{ {
if (m_airportDataReader) { return m_airportDataReader->getAirportForNameOrLocation(nameOrLocation); } if (m_airportDataReader) { return m_airportDataReader->getAirportForNameOrLocation(nameOrLocation); }
return CAirport(); return {};
} }
CCountry CWebDataServices::getCountryForIsoCode(const QString &iso) const CCountry CWebDataServices::getCountryForIsoCode(const QString &iso) const
{ {
if (m_icaoDataReader) { return m_icaoDataReader->getCountryForIsoCode(iso); } if (m_icaoDataReader) { return m_icaoDataReader->getCountryForIsoCode(iso); }
return CCountry(); return {};
} }
CMetarList CWebDataServices::getMetars() const CMetarList CWebDataServices::getMetars() const
@@ -852,7 +850,7 @@ namespace swift::core
CMetar CWebDataServices::getMetarForAirport(const CAirportIcaoCode &icao) const CMetar CWebDataServices::getMetarForAirport(const CAirportIcaoCode &icao) const
{ {
if (m_vatsimMetarReader) { return m_vatsimMetarReader->getMetarForAirport(icao); } if (m_vatsimMetarReader) { return m_vatsimMetarReader->getMetarForAirport(icao); }
return CMetar(); return {};
} }
CStatusMessageList CWebDataServices::validateForPublishing(const CAircraftModelList &modelsToBePublished, CStatusMessageList CWebDataServices::validateForPublishing(const CAircraftModelList &modelsToBePublished,
@@ -913,7 +911,7 @@ namespace swift::core
CAirlineIcaoCodeList CWebDataServices::getAirlineIcaoCodesForDesignator(const QString &designator) const CAirlineIcaoCodeList CWebDataServices::getAirlineIcaoCodesForDesignator(const QString &designator) const
{ {
if (m_icaoDataReader) { return m_icaoDataReader->getAirlineIcaoCodesForDesignator(designator); } if (m_icaoDataReader) { return m_icaoDataReader->getAirlineIcaoCodesForDesignator(designator); }
return CAirlineIcaoCodeList(); return {};
} }
int CWebDataServices::getAirlineIcaoCodesForDesignatorCount(const QString &designator) const int CWebDataServices::getAirlineIcaoCodesForDesignatorCount(const QString &designator) const
@@ -1311,11 +1309,8 @@ namespace swift::core
const CDbInfo info = reader->getInfoObjects().findFirstByEntityOrDefault(entity); const CDbInfo info = reader->getInfoObjects().findFirstByEntityOrDefault(entity);
return info.getEntries(); return info.getEntries();
} }
else // non DB entities would go here
{ return -1;
// non DB entities would go here
return -1;
}
} }
CEntityFlags::Entity CWebDataServices::getDbEntitiesWithCachedData() const CEntityFlags::Entity CWebDataServices::getDbEntitiesWithCachedData() const
@@ -1552,26 +1547,22 @@ namespace swift::core
emit this->databaseReaderMessages(m); emit this->databaseReaderMessages(m);
return false; // wait return false; // wait
} }
else
{ // we have a response, but a failure, means server is alive, but responded with error
// we have a response, but a failure, means server is alive, but responded with error // such an error (access, ...) normally will not go away
// such an error (access, ...) normally will not go away const CStatusMessage m =
const CStatusMessage m = CLogMessage(this).error(u"Info objects (%1) loading for '%2' failed from '%3', '%4'")
CLogMessage(this).error(u"Info objects (%1) loading for '%2' failed from '%3', '%4'") << info << CEntityFlags::entitiesToString(entities) << infoReader->getInfoObjectsUrl().toQString()
<< info << CEntityFlags::entitiesToString(entities) << infoReader->getInfoObjectsUrl().toQString() << infoReader->getStatusMessage();
<< infoReader->getStatusMessage(); infoReader->setMarkedAsFailed(true);
infoReader->setMarkedAsFailed(true); emit this->databaseReaderMessages(m);
emit this->databaseReaderMessages(m); return true; // carry on, regardless of situation
return true; // carry on, regardless of situation
}
}
else
{
// wait for 1st reply
// we call read again in some time
this->readDeferredInBackground(entities);
return false; // wait
} }
// wait for 1st reply
// we call read again in some time
this->readDeferredInBackground(entities);
return false; // wait
} }
bool CWebDataServices::writeDbDataToDisk(const QString &dir) bool CWebDataServices::writeDbDataToDisk(const QString &dir)

View File

@@ -281,7 +281,7 @@ namespace swift::core
//! ICAO code for id //! ICAO code for id
//! \threadsafe //! \threadsafe
swift::misc::aviation::CAircraftIcaoCode getAircraftIcaoCodeForDbKey(int id) const; swift::misc::aviation::CAircraftIcaoCode getAircraftIcaoCodeForDbKey(int key) const;
//! Use an ICAO object to select the best complete ICAO object from DB for it //! Use an ICAO object to select the best complete ICAO object from DB for it
//! \threadsafe //! \threadsafe
@@ -328,12 +328,12 @@ namespace swift::core
//! ICAO code for id //! ICAO code for id
//! \threadsafe //! \threadsafe
swift::misc::aviation::CAirlineIcaoCode getAirlineIcaoCodeForDbKey(int id) const; swift::misc::aviation::CAirlineIcaoCode getAirlineIcaoCodeForDbKey(int key) const;
//! Smart airline selector //! Smart airline selector
//! \threadsafe //! \threadsafe
swift::misc::aviation::CAirlineIcaoCode smartAirlineIcaoSelector( swift::misc::aviation::CAirlineIcaoCode smartAirlineIcaoSelector(
const swift::misc::aviation::CAirlineIcaoCode &code, const swift::misc::aviation::CAirlineIcaoCode &icaoPattern,
const swift::misc::aviation::CCallsign &callsign = swift::misc::aviation::CCallsign()) const; const swift::misc::aviation::CCallsign &callsign = swift::misc::aviation::CCallsign()) const;
//! ICAO code for callsign (e.g. DLH123 -> DLH) //! ICAO code for callsign (e.g. DLH123 -> DLH)

View File

@@ -218,9 +218,7 @@ namespace swift::misc
const unsigned long waitTimeoutMs = this->waitTimeoutMs(); const unsigned long waitTimeoutMs = this->waitTimeoutMs();
const QString name(this->getName()); const QString name(this->getName());
qint64 waitTime = QDateTime::currentMSecsSinceEpoch(); qint64 waitTime = QDateTime::currentMSecsSinceEpoch();
const bool ok = const bool ok = workerThread->wait(waitTimeoutMs);
workerThread->wait(waitTimeoutMs); //! \todo KB 2017-10 temp workaround: in T145 this will be fixed,
//! sometimes (very rarely) hanging here during shutdown
waitTime = QDateTime::currentMSecsSinceEpoch() - waitTime; waitTime = QDateTime::currentMSecsSinceEpoch() - waitTime;
const QString msg = QStringLiteral("Waiting for quitAndWait of '%1' for %2ms").arg(name).arg(waitTime); const QString msg = QStringLiteral("Waiting for quitAndWait of '%1' for %2ms").arg(name).arg(waitTime);
const QByteArray msgBA = msg.toLatin1(); const QByteArray msgBA = msg.toLatin1();

View File

@@ -34,17 +34,29 @@ namespace swift::misc
/*! /*!
* Just a subclass of QThread whose destructor waits for the thread to finish. * Just a subclass of QThread whose destructor waits for the thread to finish.
*/ */
class SWIFT_MISC_EXPORT CRegularThread : public QThread class SWIFT_MISC_EXPORT CRegularThread final : public QThread
{ {
Q_OBJECT Q_OBJECT
public: public:
//! Constructor //! Constructor
CRegularThread(QObject *parent = nullptr) : QThread(parent) {} explicit CRegularThread(QObject *parent = nullptr) : QThread(parent) {}
//! Destructor //! Destructor
~CRegularThread() override; ~CRegularThread() override;
//! Copy constructor
CRegularThread(const CRegularThread &) = delete;
//! Copy assignment
CRegularThread &operator=(const CRegularThread &) = delete;
//! Move constructor
CRegularThread(CRegularThread &&) = delete;
//! Move assignment
CRegularThread &operator=(CRegularThread &&) = delete;
protected: protected:
//! \copydoc QThread::run //! \copydoc QThread::run
void run() override; void run() override;
@@ -61,6 +73,21 @@ namespace swift::misc
Q_OBJECT Q_OBJECT
public: public:
//! Destructor.
~CWorkerBase() override;
//! Copy constructor
CWorkerBase(const CWorkerBase &) = delete;
//! Copy assignment
CWorkerBase &operator=(const CWorkerBase &) = delete;
//! Move constructor
CWorkerBase(CWorkerBase &&) = delete;
//! Move assignment
CWorkerBase &operator=(CWorkerBase &&) = delete;
//! Log categories //! Log categories
static const QStringList &getLogCategories(); static const QStringList &getLogCategories();
@@ -147,9 +174,6 @@ namespace swift::misc
//! Constructor. //! Constructor.
CWorkerBase(); CWorkerBase();
//! Destructor.
~CWorkerBase() override;
//! For the task to check whether it can finish early. //! For the task to check whether it can finish early.
//! \threadsafe //! \threadsafe
bool isAbandoned() const; bool isAbandoned() const;