mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 19:25:49 +08:00
Ref T189, formatting (some slots -> private + this->m_ ->m_)
This commit is contained in:
@@ -86,7 +86,7 @@ namespace BlackCore
|
|||||||
CAirportList airports;
|
CAirportList airports;
|
||||||
airports.convertFromJson(airportsJson);
|
airports.convertFromJson(airportsJson);
|
||||||
c = airports.size();
|
c = airports.size();
|
||||||
this->m_airportCache.set(airports);
|
m_airportCache.set(airports);
|
||||||
|
|
||||||
emit dataRead(CEntityFlags::AirportEntity, CEntityFlags::ReadFinished, c);
|
emit dataRead(CEntityFlags::AirportEntity, CEntityFlags::ReadFinished, c);
|
||||||
reallyRead |= CEntityFlags::AirportEntity;
|
reallyRead |= CEntityFlags::AirportEntity;
|
||||||
@@ -138,23 +138,23 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CAirportDataReader::synchronizeCaches(CEntityFlags::Entity entities)
|
void CAirportDataReader::synchronizeCaches(CEntityFlags::Entity entities)
|
||||||
{
|
{
|
||||||
if (entities.testFlag(CEntityFlags::AirportEntity)) { this->m_airportCache.synchronize(); }
|
if (entities.testFlag(CEntityFlags::AirportEntity)) { m_airportCache.synchronize(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAirportDataReader::admitCaches(CEntityFlags::Entity entities)
|
void CAirportDataReader::admitCaches(CEntityFlags::Entity entities)
|
||||||
{
|
{
|
||||||
if (entities.testFlag(CEntityFlags::AirportEntity)) { this->m_airportCache.admit(); }
|
if (entities.testFlag(CEntityFlags::AirportEntity)) { m_airportCache.admit(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAirportDataReader::invalidateCaches(CEntityFlags::Entity entities)
|
void CAirportDataReader::invalidateCaches(CEntityFlags::Entity entities)
|
||||||
{
|
{
|
||||||
if (entities.testFlag(CEntityFlags::AirportEntity)) { CDataCache::instance()->clearAllValues(this->m_airportCache.getKey()); }
|
if (entities.testFlag(CEntityFlags::AirportEntity)) { CDataCache::instance()->clearAllValues(m_airportCache.getKey()); }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAirportDataReader::hasChangedUrl(CEntityFlags::Entity entity, CUrl &oldUrlInfo, CUrl &newUrlInfo) const
|
bool CAirportDataReader::hasChangedUrl(CEntityFlags::Entity entity, CUrl &oldUrlInfo, CUrl &newUrlInfo) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(entity);
|
Q_UNUSED(entity);
|
||||||
oldUrlInfo = this->m_readerUrlCache.get();
|
oldUrlInfo = m_readerUrlCache.get();
|
||||||
newUrlInfo = this->getBaseUrl(CDbFlags::DbReading);
|
newUrlInfo = this->getBaseUrl(CDbFlags::DbReading);
|
||||||
return CDatabaseReader::isChangedUrl(oldUrlInfo, newUrlInfo);
|
return CDatabaseReader::isChangedUrl(oldUrlInfo, newUrlInfo);
|
||||||
}
|
}
|
||||||
@@ -213,7 +213,7 @@ namespace BlackCore
|
|||||||
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_airportCache.set(airports, latestTimestamp);
|
m_airportCache.set(airports, latestTimestamp);
|
||||||
this->updateReaderUrl(getBaseUrl(CDbFlags::DbReading));
|
this->updateReaderUrl(getBaseUrl(CDbFlags::DbReading));
|
||||||
|
|
||||||
this->emitAndLogDataRead(CEntityFlags::AirportEntity, size, res);
|
this->emitAndLogDataRead(CEntityFlags::AirportEntity, size, res);
|
||||||
@@ -246,21 +246,21 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAirportDataReader::ps_airportCacheChanged()
|
void CAirportDataReader::airportCacheChanged()
|
||||||
{
|
{
|
||||||
this->cacheHasChanged(CEntityFlags::AirportEntity);
|
this->cacheHasChanged(CEntityFlags::AirportEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAirportDataReader::ps_baseUrlCacheChanged()
|
void CAirportDataReader::baseUrlCacheChanged()
|
||||||
{
|
{
|
||||||
// void
|
// void
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAirportDataReader::updateReaderUrl(const CUrl &url)
|
void CAirportDataReader::updateReaderUrl(const CUrl &url)
|
||||||
{
|
{
|
||||||
const CUrl current = this->m_readerUrlCache.get();
|
const CUrl current = m_readerUrlCache.get();
|
||||||
if (current == url) { return; }
|
if (current == url) { return; }
|
||||||
const CStatusMessage m = this->m_readerUrlCache.set(url);
|
const CStatusMessage m = m_readerUrlCache.set(url);
|
||||||
if (m.isFailure())
|
if (m.isFailure())
|
||||||
{
|
{
|
||||||
CLogMessage::preformatted(m);
|
CLogMessage::preformatted(m);
|
||||||
|
|||||||
@@ -80,17 +80,17 @@ namespace BlackCore
|
|||||||
void ps_read(BlackMisc::Network::CEntityFlags::Entity entity = BlackMisc::Network::CEntityFlags::DistributorLiveryModel,
|
void ps_read(BlackMisc::Network::CEntityFlags::Entity entity = BlackMisc::Network::CEntityFlags::DistributorLiveryModel,
|
||||||
BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode = BlackMisc::Db::CDbFlags::DbReading, const QDateTime &newerThan = QDateTime());
|
BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode = BlackMisc::Db::CDbFlags::DbReading, const QDateTime &newerThan = QDateTime());
|
||||||
|
|
||||||
//! Airport cache changed
|
|
||||||
void ps_airportCacheChanged();
|
|
||||||
|
|
||||||
//! Base url cache changed
|
|
||||||
void ps_baseUrlCacheChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BlackMisc::CData<BlackCore::Data::TDbAirportCache> m_airportCache {this, &CAirportDataReader::ps_airportCacheChanged};
|
BlackMisc::CData<BlackCore::Data::TDbAirportCache> m_airportCache {this, &CAirportDataReader::airportCacheChanged};
|
||||||
|
|
||||||
//! Reader URL (we read from where?) used to detect changes of location
|
//! Reader URL (we read from where?) used to detect changes of location
|
||||||
BlackMisc::CData<BlackCore::Data::TDbModelReaderBaseUrl> m_readerUrlCache {this, &CAirportDataReader::ps_baseUrlCacheChanged };
|
BlackMisc::CData<BlackCore::Data::TDbModelReaderBaseUrl> m_readerUrlCache {this, &CAirportDataReader::baseUrlCacheChanged };
|
||||||
|
|
||||||
|
//! Airport cache changed
|
||||||
|
void airportCacheChanged();
|
||||||
|
|
||||||
|
//! Base url cache changed
|
||||||
|
void baseUrlCacheChanged();
|
||||||
|
|
||||||
//! Update reader URL
|
//! Update reader URL
|
||||||
void updateReaderUrl(const BlackMisc::Network::CUrl &url);
|
void updateReaderUrl(const BlackMisc::Network::CUrl &url);
|
||||||
|
|||||||
@@ -462,7 +462,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
CDatabaseReaderConfig CDatabaseReader::getConfigForEntity(CEntityFlags::Entity entity) const
|
CDatabaseReaderConfig CDatabaseReader::getConfigForEntity(CEntityFlags::Entity entity) const
|
||||||
{
|
{
|
||||||
return this->m_config.findFirstOrDefaultForEntity(entity);
|
return m_config.findFirstOrDefaultForEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
CEntityFlags::Entity CDatabaseReader::emitReadSignalPerSingleCachedEntity(CEntityFlags::Entity cachedEntities, bool onlyIfHasData)
|
CEntityFlags::Entity CDatabaseReader::emitReadSignalPerSingleCachedEntity(CEntityFlags::Entity cachedEntities, bool onlyIfHasData)
|
||||||
@@ -476,7 +476,7 @@ namespace BlackCore
|
|||||||
const int c = this->getCacheCount(currentCachedEntity);
|
const int c = this->getCacheCount(currentCachedEntity);
|
||||||
if (!onlyIfHasData || c > 0)
|
if (!onlyIfHasData || c > 0)
|
||||||
{
|
{
|
||||||
emit dataRead(currentCachedEntity, CEntityFlags::ReadFinished, c);
|
emit this->dataRead(currentCachedEntity, CEntityFlags::ReadFinished, c);
|
||||||
emitted |= currentCachedEntity;
|
emitted |= currentCachedEntity;
|
||||||
}
|
}
|
||||||
currentCachedEntity = CEntityFlags::iterateDbEntities(cachedEntitiesToEmit);
|
currentCachedEntity = CEntityFlags::iterateDbEntities(cachedEntitiesToEmit);
|
||||||
@@ -487,7 +487,8 @@ namespace BlackCore
|
|||||||
void CDatabaseReader::emitAndLogDataRead(CEntityFlags::Entity entity, int number, const JsonDatastoreResponse &res)
|
void CDatabaseReader::emitAndLogDataRead(CEntityFlags::Entity entity, int number, const JsonDatastoreResponse &res)
|
||||||
{
|
{
|
||||||
// never emit when lock is held, deadlock
|
// never emit when lock is held, deadlock
|
||||||
emit dataRead(entity, res.isRestricted() ? CEntityFlags::ReadFinishedRestricted : CEntityFlags::ReadFinished, number);
|
Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO, "Expect single entity");
|
||||||
|
emit this->dataRead(entity, res.isRestricted() ? CEntityFlags::ReadFinishedRestricted : CEntityFlags::ReadFinished, number);
|
||||||
CLogMessage(this).info("Read %1 entities of '%2' from '%3' (%4)") << number << CEntityFlags::flagToString(entity) << res.getUrlString() << res.getLoadTimeStringWithStartedHint();
|
CLogMessage(this).info("Read %1 entities of '%2' from '%3' (%4)") << number << CEntityFlags::flagToString(entity) << res.getUrlString() << res.getLoadTimeStringWithStartedHint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,7 +542,7 @@ namespace BlackCore
|
|||||||
const HeaderResponse headerResponse = this->transformReplyIntoHeaderResponse(nwReplyPtr);
|
const HeaderResponse headerResponse = this->transformReplyIntoHeaderResponse(nwReplyPtr);
|
||||||
const QString fileName = nwReplyPtr->url().fileName();
|
const QString fileName = nwReplyPtr->url().fileName();
|
||||||
const CEntityFlags::Entity entity = CEntityFlags::singleEntityByName(fileName);
|
const CEntityFlags::Entity entity = CEntityFlags::singleEntityByName(fileName);
|
||||||
this->m_sharedFileResponses[entity] = headerResponse;
|
m_sharedFileResponses[entity] = headerResponse;
|
||||||
|
|
||||||
CLogMessage(this).info("Received header for shared file of '%1' from '%2'") << fileName << headerResponse.getUrl().toQString();
|
CLogMessage(this).info("Received header for shared file of '%1' from '%2'") << fileName << headerResponse.getUrl().toQString();
|
||||||
emit this->sharedFileHeaderRead(entity, fileName, !headerResponse.hasWarningOrAboveMessage());
|
emit this->sharedFileHeaderRead(entity, fileName, !headerResponse.hasWarningOrAboveMessage());
|
||||||
@@ -549,20 +550,20 @@ namespace BlackCore
|
|||||||
|
|
||||||
bool CDatabaseReader::hasReceivedOkReply() const
|
bool CDatabaseReader::hasReceivedOkReply() const
|
||||||
{
|
{
|
||||||
QReadLocker rl(&this->m_statusLock);
|
QReadLocker rl(&m_statusLock);
|
||||||
return m_1stReplyReceived && m_1stReplyStatus == QNetworkReply::NoError;
|
return m_1stReplyReceived && m_1stReplyStatus == QNetworkReply::NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDatabaseReader::hasReceivedOkReply(QString &message) const
|
bool CDatabaseReader::hasReceivedOkReply(QString &message) const
|
||||||
{
|
{
|
||||||
QReadLocker rl(&this->m_statusLock);
|
QReadLocker rl(&m_statusLock);
|
||||||
message = m_statusMessage;
|
message = m_statusMessage;
|
||||||
return m_1stReplyReceived && m_1stReplyStatus == QNetworkReply::NoError;
|
return m_1stReplyReceived && m_1stReplyStatus == QNetworkReply::NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDatabaseReader::hasReceivedFirstReply() const
|
bool CDatabaseReader::hasReceivedFirstReply() const
|
||||||
{
|
{
|
||||||
QReadLocker rl(&this->m_statusLock);
|
QReadLocker rl(&m_statusLock);
|
||||||
return m_1stReplyReceived;
|
return m_1stReplyReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,15 +586,15 @@ namespace BlackCore
|
|||||||
|
|
||||||
const QString &CDatabaseReader::getStatusMessage() const
|
const QString &CDatabaseReader::getStatusMessage() const
|
||||||
{
|
{
|
||||||
return this->m_statusMessage;
|
return m_statusMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDatabaseReader::setReplyStatus(QNetworkReply::NetworkError status, const QString &message)
|
void CDatabaseReader::setReplyStatus(QNetworkReply::NetworkError status, const QString &message)
|
||||||
{
|
{
|
||||||
QWriteLocker wl(&this->m_statusLock);
|
QWriteLocker wl(&m_statusLock);
|
||||||
this->m_statusMessage = message;
|
m_statusMessage = message;
|
||||||
this->m_1stReplyStatus = status;
|
m_1stReplyStatus = status;
|
||||||
this->m_1stReplyReceived = true;
|
m_1stReplyReceived = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDatabaseReader::setReplyStatus(QNetworkReply *nwReply)
|
void CDatabaseReader::setReplyStatus(QNetworkReply *nwReply)
|
||||||
@@ -744,7 +745,7 @@ namespace BlackCore
|
|||||||
QString CDatabaseReader::HeaderResponse::getLoadTimeStringWithStartedHint() const
|
QString CDatabaseReader::HeaderResponse::getLoadTimeStringWithStartedHint() const
|
||||||
{
|
{
|
||||||
if (m_requestStarted < 0) { return this->getLoadTimeString(); }
|
if (m_requestStarted < 0) { return this->getLoadTimeString(); }
|
||||||
const qint64 diff = QDateTime::currentMSecsSinceEpoch() - this->m_requestStarted;
|
const qint64 diff = QDateTime::currentMSecsSinceEpoch() - m_requestStarted;
|
||||||
static const QString s("%1 load time, started %2ms before now");
|
static const QString s("%1 load time, started %2ms before now");
|
||||||
return s.arg(this->getLoadTimeString()).arg(diff);
|
return s.arg(this->getLoadTimeString()).arg(diff);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace BlackCore
|
|||||||
CDatabaseReader(owner, config, "CIcaoDataReader")
|
CDatabaseReader(owner, config, "CIcaoDataReader")
|
||||||
{
|
{
|
||||||
// init to avoid threading issues
|
// init to avoid threading issues
|
||||||
getBaseUrl(CDbFlags::DbReading);
|
this->getBaseUrl(CDbFlags::DbReading);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftIcaoCodeList CIcaoDataReader::getAircraftIcaoCodes() const
|
CAircraftIcaoCodeList CIcaoDataReader::getAircraftIcaoCodes() const
|
||||||
@@ -217,31 +217,31 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIcaoDataReader::ps_aircraftIcaoCacheChanged()
|
void CIcaoDataReader::aircraftIcaoCacheChanged()
|
||||||
{
|
{
|
||||||
this->cacheHasChanged(CEntityFlags::AircraftIcaoEntity);
|
this->cacheHasChanged(CEntityFlags::AircraftIcaoEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIcaoDataReader::ps_airlineIcaoCacheChanged()
|
void CIcaoDataReader::airlineIcaoCacheChanged()
|
||||||
{
|
{
|
||||||
this->cacheHasChanged(CEntityFlags::AirlineIcaoEntity);
|
this->cacheHasChanged(CEntityFlags::AirlineIcaoEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIcaoDataReader::ps_countryCacheChanged()
|
void CIcaoDataReader::countryCacheChanged()
|
||||||
{
|
{
|
||||||
this->cacheHasChanged(CEntityFlags::CountryEntity);
|
this->cacheHasChanged(CEntityFlags::CountryEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIcaoDataReader::ps_baseUrlCacheChanged()
|
void CIcaoDataReader::baseUrlCacheChanged()
|
||||||
{
|
{
|
||||||
// void
|
// void
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIcaoDataReader::updateReaderUrl(const CUrl &url)
|
void CIcaoDataReader::updateReaderUrl(const CUrl &url)
|
||||||
{
|
{
|
||||||
const CUrl current = this->m_readerUrlCache.get();
|
const CUrl current = m_readerUrlCache.get();
|
||||||
if (current == url) { return; }
|
if (current == url) { return; }
|
||||||
const CStatusMessage m = this->m_readerUrlCache.set(url);
|
const CStatusMessage m = m_readerUrlCache.set(url);
|
||||||
if (m.isFailure())
|
if (m.isFailure())
|
||||||
{
|
{
|
||||||
CLogMessage::preformatted(m);
|
CLogMessage::preformatted(m);
|
||||||
@@ -259,7 +259,7 @@ namespace BlackCore
|
|||||||
if (res.hasErrorMessage())
|
if (res.hasErrorMessage())
|
||||||
{
|
{
|
||||||
CLogMessage::preformatted(res.lastWarningOrAbove());
|
CLogMessage::preformatted(res.lastWarningOrAbove());
|
||||||
emit dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFailed, 0);
|
emit this->dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFailed, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,15 +287,15 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int n = codes.size();
|
const int n = codes.size();
|
||||||
qint64 latestTimestamp = codes.latestTimestampMsecsSinceEpoch();
|
qint64 latestTimestamp = codes.latestTimestampMsecsSinceEpoch(); // ignores duplicates
|
||||||
if (n > 0 && latestTimestamp < 0)
|
if (n > 0 && latestTimestamp < 0)
|
||||||
{
|
{
|
||||||
CLogMessage(this).error("No timestamp in aircraft ICAO list, setting to last modified value");
|
CLogMessage(this).error("No timestamp in aircraft ICAO list, setting to last modified value");
|
||||||
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
latestTimestamp = this->lastModifiedMsSinceEpoch(nwReply.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_aircraftIcaoCache.set(codes, latestTimestamp);
|
m_aircraftIcaoCache.set(codes, latestTimestamp);
|
||||||
this->updateReaderUrl(getBaseUrl(CDbFlags::DbReading));
|
this->updateReaderUrl(this->getBaseUrl(CDbFlags::DbReading));
|
||||||
|
|
||||||
this->emitAndLogDataRead(CEntityFlags::AircraftIcaoEntity, n, res);
|
this->emitAndLogDataRead(CEntityFlags::AircraftIcaoEntity, n, res);
|
||||||
}
|
}
|
||||||
@@ -309,7 +309,7 @@ namespace BlackCore
|
|||||||
if (res.hasErrorMessage())
|
if (res.hasErrorMessage())
|
||||||
{
|
{
|
||||||
CLogMessage::preformatted(res.lastWarningOrAbove());
|
CLogMessage::preformatted(res.lastWarningOrAbove());
|
||||||
emit dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFailed, 0);
|
emit this->dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFailed, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,11 +341,11 @@ namespace BlackCore
|
|||||||
if (n > 0 && latestTimestamp < 0)
|
if (n > 0 && latestTimestamp < 0)
|
||||||
{
|
{
|
||||||
CLogMessage(this).error("No timestamp in airline ICAO list, setting to last modified value");
|
CLogMessage(this).error("No timestamp in airline ICAO list, setting to last modified value");
|
||||||
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
latestTimestamp = this->lastModifiedMsSinceEpoch(nwReply.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_airlineIcaoCache.set(codes, latestTimestamp);
|
m_airlineIcaoCache.set(codes, latestTimestamp);
|
||||||
this->updateReaderUrl(getBaseUrl(CDbFlags::DbReading));
|
this->updateReaderUrl(this->getBaseUrl(CDbFlags::DbReading));
|
||||||
|
|
||||||
this->emitAndLogDataRead(CEntityFlags::AirlineIcaoEntity, n, res);
|
this->emitAndLogDataRead(CEntityFlags::AirlineIcaoEntity, n, res);
|
||||||
}
|
}
|
||||||
@@ -357,7 +357,7 @@ namespace BlackCore
|
|||||||
if (res.hasErrorMessage())
|
if (res.hasErrorMessage())
|
||||||
{
|
{
|
||||||
CLogMessage::preformatted(res.lastWarningOrAbove());
|
CLogMessage::preformatted(res.lastWarningOrAbove());
|
||||||
emit dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadFailed, 0);
|
emit this->dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadFailed, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,11 +381,11 @@ namespace BlackCore
|
|||||||
if (n > 0 && latestTimestamp < 0)
|
if (n > 0 && latestTimestamp < 0)
|
||||||
{
|
{
|
||||||
CLogMessage(this).error("No timestamp in country list, setting to last modified value");
|
CLogMessage(this).error("No timestamp in country list, setting to last modified value");
|
||||||
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
latestTimestamp = this->lastModifiedMsSinceEpoch(nwReply.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_countryCache.set(countries, latestTimestamp);
|
m_countryCache.set(countries, latestTimestamp);
|
||||||
this->updateReaderUrl(getBaseUrl(CDbFlags::DbReading));
|
this->updateReaderUrl(this->getBaseUrl(CDbFlags::DbReading));
|
||||||
|
|
||||||
this->emitAndLogDataRead(CEntityFlags::CountryEntity, n, res);
|
this->emitAndLogDataRead(CEntityFlags::CountryEntity, n, res);
|
||||||
}
|
}
|
||||||
@@ -417,13 +417,13 @@ namespace BlackCore
|
|||||||
CCountryList countries;
|
CCountryList countries;
|
||||||
countries.convertFromJson(countriesJson);
|
countries.convertFromJson(countriesJson);
|
||||||
const int c = countries.size();
|
const int c = countries.size();
|
||||||
this->m_countryCache.set(countries);
|
m_countryCache.set(countries);
|
||||||
reallyRead |= CEntityFlags::CountryEntity;
|
reallyRead |= CEntityFlags::CountryEntity;
|
||||||
emit dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadFinished, c);
|
emit this->dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadFinished, c);
|
||||||
}
|
}
|
||||||
catch (const CJsonException &ex)
|
catch (const CJsonException &ex)
|
||||||
{
|
{
|
||||||
emit dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadFailed, 0);
|
emit this->dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadFailed, 0);
|
||||||
msgs.push_back(ex.toStatusMessage(this, QString("Reading countries from '%1'").arg(fileName)));
|
msgs.push_back(ex.toStatusMessage(this, QString("Reading countries from '%1'").arg(fileName)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -444,13 +444,13 @@ namespace BlackCore
|
|||||||
CAircraftIcaoCodeList aircraftIcaos;
|
CAircraftIcaoCodeList aircraftIcaos;
|
||||||
aircraftIcaos.convertFromJson(aircraftJson);
|
aircraftIcaos.convertFromJson(aircraftJson);
|
||||||
const int c = aircraftIcaos.size();
|
const int c = aircraftIcaos.size();
|
||||||
this->m_aircraftIcaoCache.set(aircraftIcaos);
|
m_aircraftIcaoCache.set(aircraftIcaos);
|
||||||
reallyRead |= CEntityFlags::AircraftIcaoEntity;
|
reallyRead |= CEntityFlags::AircraftIcaoEntity;
|
||||||
emit dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFinished, c);
|
emit this->dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFinished, c);
|
||||||
}
|
}
|
||||||
catch (const CJsonException &ex)
|
catch (const CJsonException &ex)
|
||||||
{
|
{
|
||||||
emit dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFailed, 0);
|
emit this->dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFailed, 0);
|
||||||
msgs.push_back(ex.toStatusMessage(this, QString("Reading aircraft ICAOs from '%1'").arg(fileName)));
|
msgs.push_back(ex.toStatusMessage(this, QString("Reading aircraft ICAOs from '%1'").arg(fileName)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -471,13 +471,13 @@ namespace BlackCore
|
|||||||
CAirlineIcaoCodeList airlineIcaos;
|
CAirlineIcaoCodeList airlineIcaos;
|
||||||
airlineIcaos.convertFromJson(airlineJson);
|
airlineIcaos.convertFromJson(airlineJson);
|
||||||
const int c = airlineIcaos.size();
|
const int c = airlineIcaos.size();
|
||||||
this->m_airlineIcaoCache.set(airlineIcaos);
|
m_airlineIcaoCache.set(airlineIcaos);
|
||||||
reallyRead |= CEntityFlags::AirlineIcaoEntity;
|
reallyRead |= CEntityFlags::AirlineIcaoEntity;
|
||||||
emit dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFinished, c);
|
emit this->dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFinished, c);
|
||||||
}
|
}
|
||||||
catch (const CJsonException &ex)
|
catch (const CJsonException &ex)
|
||||||
{
|
{
|
||||||
emit dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFailed, 0);
|
emit this->dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFailed, 0);
|
||||||
msgs.push_back(ex.toStatusMessage(this, QString("Reading airline ICAOs from '%1'").arg(fileName)));
|
msgs.push_back(ex.toStatusMessage(this, QString("Reading airline ICAOs from '%1'").arg(fileName)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -541,32 +541,32 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CIcaoDataReader::synchronizeCaches(CEntityFlags::Entity entities)
|
void CIcaoDataReader::synchronizeCaches(CEntityFlags::Entity entities)
|
||||||
{
|
{
|
||||||
if (entities.testFlag(CEntityFlags::AircraftIcaoEntity)) { this->m_aircraftIcaoCache.synchronize(); }
|
if (entities.testFlag(CEntityFlags::AircraftIcaoEntity)) { m_aircraftIcaoCache.synchronize(); }
|
||||||
if (entities.testFlag(CEntityFlags::AirlineIcaoEntity)) { this->m_airlineIcaoCache.synchronize(); }
|
if (entities.testFlag(CEntityFlags::AirlineIcaoEntity)) { m_airlineIcaoCache.synchronize(); }
|
||||||
if (entities.testFlag(CEntityFlags::CountryEntity)) { this->m_countryCache.synchronize(); }
|
if (entities.testFlag(CEntityFlags::CountryEntity)) { m_countryCache.synchronize(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIcaoDataReader::admitCaches(CEntityFlags::Entity entities)
|
void CIcaoDataReader::admitCaches(CEntityFlags::Entity entities)
|
||||||
{
|
{
|
||||||
if (entities.testFlag(CEntityFlags::AircraftIcaoEntity)) { this->m_aircraftIcaoCache.admit(); }
|
if (entities.testFlag(CEntityFlags::AircraftIcaoEntity)) { m_aircraftIcaoCache.admit(); }
|
||||||
if (entities.testFlag(CEntityFlags::AirlineIcaoEntity)) { this->m_airlineIcaoCache.admit(); }
|
if (entities.testFlag(CEntityFlags::AirlineIcaoEntity)) { m_airlineIcaoCache.admit(); }
|
||||||
if (entities.testFlag(CEntityFlags::CountryEntity)) { this->m_countryCache.admit(); }
|
if (entities.testFlag(CEntityFlags::CountryEntity)) { m_countryCache.admit(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIcaoDataReader::invalidateCaches(CEntityFlags::Entity entities)
|
void CIcaoDataReader::invalidateCaches(CEntityFlags::Entity entities)
|
||||||
{
|
{
|
||||||
if (entities.testFlag(CEntityFlags::AircraftIcaoEntity)) { CDataCache::instance()->clearAllValues(this->m_aircraftIcaoCache.getKey()); }
|
if (entities.testFlag(CEntityFlags::AircraftIcaoEntity)) { CDataCache::instance()->clearAllValues(m_aircraftIcaoCache.getKey()); }
|
||||||
if (entities.testFlag(CEntityFlags::AirlineIcaoEntity)) {CDataCache::instance()->clearAllValues(this->m_airlineIcaoCache.getKey()); }
|
if (entities.testFlag(CEntityFlags::AirlineIcaoEntity)) {CDataCache::instance()->clearAllValues(m_airlineIcaoCache.getKey()); }
|
||||||
if (entities.testFlag(CEntityFlags::CountryEntity)) {CDataCache::instance()->clearAllValues(this->m_countryCache.getKey()); }
|
if (entities.testFlag(CEntityFlags::CountryEntity)) {CDataCache::instance()->clearAllValues(m_countryCache.getKey()); }
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime CIcaoDataReader::getCacheTimestamp(CEntityFlags::Entity entity) const
|
QDateTime CIcaoDataReader::getCacheTimestamp(CEntityFlags::Entity entity) const
|
||||||
{
|
{
|
||||||
switch (entity)
|
switch (entity)
|
||||||
{
|
{
|
||||||
case CEntityFlags::AircraftIcaoEntity: return this->m_aircraftIcaoCache.getAvailableTimestamp();
|
case CEntityFlags::AircraftIcaoEntity: return m_aircraftIcaoCache.getAvailableTimestamp();
|
||||||
case CEntityFlags::AirlineIcaoEntity: return this->m_airlineIcaoCache.getAvailableTimestamp();
|
case CEntityFlags::AirlineIcaoEntity: return m_airlineIcaoCache.getAvailableTimestamp();
|
||||||
case CEntityFlags::CountryEntity: return this->m_countryCache.getAvailableTimestamp();
|
case CEntityFlags::CountryEntity: return m_countryCache.getAvailableTimestamp();
|
||||||
default: return QDateTime();
|
default: return QDateTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -575,9 +575,9 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
switch (entity)
|
switch (entity)
|
||||||
{
|
{
|
||||||
case CEntityFlags::AircraftIcaoEntity: return this->m_aircraftIcaoCache.get().size();
|
case CEntityFlags::AircraftIcaoEntity: return m_aircraftIcaoCache.get().size();
|
||||||
case CEntityFlags::AirlineIcaoEntity: return this->m_airlineIcaoCache.get().size();
|
case CEntityFlags::AirlineIcaoEntity: return m_airlineIcaoCache.get().size();
|
||||||
case CEntityFlags::CountryEntity: return this->m_countryCache.get().size();
|
case CEntityFlags::CountryEntity: return m_countryCache.get().size();
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -603,7 +603,7 @@ namespace BlackCore
|
|||||||
bool CIcaoDataReader::hasChangedUrl(CEntityFlags::Entity entity, CUrl &oldUrlInfo, CUrl &newUrlInfo) const
|
bool CIcaoDataReader::hasChangedUrl(CEntityFlags::Entity entity, CUrl &oldUrlInfo, CUrl &newUrlInfo) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(entity);
|
Q_UNUSED(entity);
|
||||||
oldUrlInfo = this->m_readerUrlCache.get();
|
oldUrlInfo = m_readerUrlCache.get();
|
||||||
newUrlInfo = this->getBaseUrl(CDbFlags::DbReading);
|
newUrlInfo = this->getBaseUrl(CDbFlags::DbReading);
|
||||||
return CDatabaseReader::isChangedUrl(oldUrlInfo, newUrlInfo);
|
return CDatabaseReader::isChangedUrl(oldUrlInfo, newUrlInfo);
|
||||||
}
|
}
|
||||||
@@ -615,17 +615,17 @@ namespace BlackCore
|
|||||||
|
|
||||||
CUrl CIcaoDataReader::getAircraftIcaoUrl(CDbFlags::DataRetrievalModeFlag mode) const
|
CUrl CIcaoDataReader::getAircraftIcaoUrl(CDbFlags::DataRetrievalModeFlag mode) const
|
||||||
{
|
{
|
||||||
return getBaseUrl(mode).withAppendedPath(fileNameForMode(CEntityFlags::AircraftIcaoEntity, mode));
|
return this->getBaseUrl(mode).withAppendedPath(fileNameForMode(CEntityFlags::AircraftIcaoEntity, mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
CUrl CIcaoDataReader::getAirlineIcaoUrl(CDbFlags::DataRetrievalModeFlag mode) const
|
CUrl CIcaoDataReader::getAirlineIcaoUrl(CDbFlags::DataRetrievalModeFlag mode) const
|
||||||
{
|
{
|
||||||
return getBaseUrl(mode).withAppendedPath(fileNameForMode(CEntityFlags::AirlineIcaoEntity, mode));
|
return this->getBaseUrl(mode).withAppendedPath(fileNameForMode(CEntityFlags::AirlineIcaoEntity, mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
CUrl CIcaoDataReader::getCountryUrl(CDbFlags::DataRetrievalModeFlag mode) const
|
CUrl CIcaoDataReader::getCountryUrl(CDbFlags::DataRetrievalModeFlag mode) const
|
||||||
{
|
{
|
||||||
return getBaseUrl(mode).withAppendedPath(fileNameForMode(CEntityFlags::CountryEntity, mode));
|
return this->getBaseUrl(mode).withAppendedPath(fileNameForMode(CEntityFlags::CountryEntity, mode));
|
||||||
}
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -167,18 +167,18 @@ namespace BlackCore
|
|||||||
void ps_read(BlackMisc::Network::CEntityFlags::Entity entities,
|
void ps_read(BlackMisc::Network::CEntityFlags::Entity entities,
|
||||||
BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan);
|
BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan);
|
||||||
|
|
||||||
void ps_aircraftIcaoCacheChanged();
|
|
||||||
void ps_airlineIcaoCacheChanged();
|
|
||||||
void ps_countryCacheChanged();
|
|
||||||
void ps_baseUrlCacheChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BlackMisc::CData<BlackCore::Data::TDbAircraftIcaoCache> m_aircraftIcaoCache {this, &CIcaoDataReader::ps_aircraftIcaoCacheChanged };
|
BlackMisc::CData<BlackCore::Data::TDbAircraftIcaoCache> m_aircraftIcaoCache {this, &CIcaoDataReader::aircraftIcaoCacheChanged };
|
||||||
BlackMisc::CData<BlackCore::Data::TDbAirlineIcaoCache> m_airlineIcaoCache {this, &CIcaoDataReader::ps_airlineIcaoCacheChanged };
|
BlackMisc::CData<BlackCore::Data::TDbAirlineIcaoCache> m_airlineIcaoCache {this, &CIcaoDataReader::airlineIcaoCacheChanged };
|
||||||
BlackMisc::CData<BlackCore::Data::TDbCountryCache> m_countryCache {this, &CIcaoDataReader::ps_countryCacheChanged };
|
BlackMisc::CData<BlackCore::Data::TDbCountryCache> m_countryCache {this, &CIcaoDataReader::countryCacheChanged };
|
||||||
|
|
||||||
//! Reader URL (we read from where?) used to detect changes of location
|
//! Reader URL (we read from where?) used to detect changes of location
|
||||||
BlackMisc::CData<BlackCore::Data::TDbIcaoReaderBaseUrl> m_readerUrlCache {this, &CIcaoDataReader::ps_baseUrlCacheChanged };
|
BlackMisc::CData<BlackCore::Data::TDbIcaoReaderBaseUrl> m_readerUrlCache {this, &CIcaoDataReader::baseUrlCacheChanged };
|
||||||
|
|
||||||
|
void aircraftIcaoCacheChanged();
|
||||||
|
void airlineIcaoCacheChanged();
|
||||||
|
void countryCacheChanged();
|
||||||
|
void baseUrlCacheChanged();
|
||||||
|
|
||||||
//! Update reader URL
|
//! Update reader URL
|
||||||
void updateReaderUrl(const BlackMisc::Network::CUrl &url);
|
void updateReaderUrl(const BlackMisc::Network::CUrl &url);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
CLiveryList CModelDataReader::getLiveries() const
|
CLiveryList CModelDataReader::getLiveries() const
|
||||||
{
|
{
|
||||||
return this->m_liveryCache.get();
|
return m_liveryCache.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
CLivery CModelDataReader::getLiveryForCombinedCode(const QString &combinedCode) const
|
CLivery CModelDataReader::getLiveryForCombinedCode(const QString &combinedCode) const
|
||||||
@@ -226,31 +226,31 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModelDataReader::ps_liveryCacheChanged()
|
void CModelDataReader::liveryCacheChanged()
|
||||||
{
|
{
|
||||||
this->cacheHasChanged(CEntityFlags::LiveryEntity);
|
this->cacheHasChanged(CEntityFlags::LiveryEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModelDataReader::ps_modelCacheChanged()
|
void CModelDataReader::modelCacheChanged()
|
||||||
{
|
{
|
||||||
this->cacheHasChanged(CEntityFlags::ModelEntity);
|
this->cacheHasChanged(CEntityFlags::ModelEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModelDataReader::ps_distributorCacheChanged()
|
void CModelDataReader::distributorCacheChanged()
|
||||||
{
|
{
|
||||||
this->cacheHasChanged(CEntityFlags::DistributorEntity);
|
this->cacheHasChanged(CEntityFlags::DistributorEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModelDataReader::ps_baseUrlCacheChanged()
|
void CModelDataReader::baseUrlCacheChanged()
|
||||||
{
|
{
|
||||||
// void
|
// void
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModelDataReader::updateReaderUrl(const CUrl &url)
|
void CModelDataReader::updateReaderUrl(const CUrl &url)
|
||||||
{
|
{
|
||||||
const CUrl current = this->m_readerUrlCache.get();
|
const CUrl current = m_readerUrlCache.get();
|
||||||
if (current == url) { return; }
|
if (current == url) { return; }
|
||||||
const CStatusMessage m = this->m_readerUrlCache.set(url);
|
const CStatusMessage m = m_readerUrlCache.set(url);
|
||||||
if (m.isFailure())
|
if (m.isFailure())
|
||||||
{
|
{
|
||||||
CLogMessage::preformatted(m);
|
CLogMessage::preformatted(m);
|
||||||
@@ -293,7 +293,7 @@ namespace BlackCore
|
|||||||
CLogMessage(this).error("No timestamp in livery list, setting to last modified value");
|
CLogMessage(this).error("No timestamp in livery list, setting to last modified value");
|
||||||
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
||||||
}
|
}
|
||||||
this->m_liveryCache.set(liveries, latestTimestamp);
|
m_liveryCache.set(liveries, latestTimestamp);
|
||||||
this->updateReaderUrl(getBaseUrl(CDbFlags::DbReading));
|
this->updateReaderUrl(getBaseUrl(CDbFlags::DbReading));
|
||||||
|
|
||||||
this->emitAndLogDataRead(CEntityFlags::LiveryEntity, n, res);
|
this->emitAndLogDataRead(CEntityFlags::LiveryEntity, n, res);
|
||||||
@@ -335,7 +335,7 @@ namespace BlackCore
|
|||||||
CLogMessage(this).error("No timestamp in distributor list, setting to last modified value");
|
CLogMessage(this).error("No timestamp in distributor list, setting to last modified value");
|
||||||
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
||||||
}
|
}
|
||||||
this->m_distributorCache.set(distributors, latestTimestamp);
|
m_distributorCache.set(distributors, latestTimestamp);
|
||||||
this->updateReaderUrl(getBaseUrl(CDbFlags::DbReading));
|
this->updateReaderUrl(getBaseUrl(CDbFlags::DbReading));
|
||||||
|
|
||||||
this->emitAndLogDataRead(CEntityFlags::DistributorEntity, n, res);
|
this->emitAndLogDataRead(CEntityFlags::DistributorEntity, n, res);
|
||||||
@@ -378,7 +378,7 @@ namespace BlackCore
|
|||||||
CLogMessage(this).error("No timestamp in model list, setting to last modified value");
|
CLogMessage(this).error("No timestamp in model list, setting to last modified value");
|
||||||
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
latestTimestamp = lastModifiedMsSinceEpoch(nwReply.data());
|
||||||
}
|
}
|
||||||
this->m_modelCache.set(models, latestTimestamp);
|
m_modelCache.set(models, latestTimestamp);
|
||||||
this->updateReaderUrl(getBaseUrl(CDbFlags::DbReading));
|
this->updateReaderUrl(getBaseUrl(CDbFlags::DbReading));
|
||||||
|
|
||||||
this->emitAndLogDataRead(CEntityFlags::ModelEntity, n, res);
|
this->emitAndLogDataRead(CEntityFlags::ModelEntity, n, res);
|
||||||
@@ -411,7 +411,7 @@ namespace BlackCore
|
|||||||
CLiveryList liveries;
|
CLiveryList liveries;
|
||||||
liveries.convertFromJson(liveriesJson);
|
liveries.convertFromJson(liveriesJson);
|
||||||
const int c = liveries.size();
|
const int c = liveries.size();
|
||||||
this->m_liveryCache.set(liveries);
|
m_liveryCache.set(liveries);
|
||||||
emit dataRead(CEntityFlags::LiveryEntity, CEntityFlags::ReadFinished, c);
|
emit dataRead(CEntityFlags::LiveryEntity, CEntityFlags::ReadFinished, c);
|
||||||
reallyRead |= CEntityFlags::LiveryEntity;
|
reallyRead |= CEntityFlags::LiveryEntity;
|
||||||
}
|
}
|
||||||
@@ -438,7 +438,7 @@ namespace BlackCore
|
|||||||
CAircraftModelList models;
|
CAircraftModelList models;
|
||||||
models.convertFromJson(modelsJson);
|
models.convertFromJson(modelsJson);
|
||||||
const int c = models.size();
|
const int c = models.size();
|
||||||
this->m_modelCache.set(models);
|
m_modelCache.set(models);
|
||||||
emit dataRead(CEntityFlags::ModelEntity, CEntityFlags::ReadFinished, c);
|
emit dataRead(CEntityFlags::ModelEntity, CEntityFlags::ReadFinished, c);
|
||||||
reallyRead |= CEntityFlags::ModelEntity;
|
reallyRead |= CEntityFlags::ModelEntity;
|
||||||
}
|
}
|
||||||
@@ -465,7 +465,7 @@ namespace BlackCore
|
|||||||
CDistributorList distributors;
|
CDistributorList distributors;
|
||||||
distributors.convertFromJson(distributorsJson);
|
distributors.convertFromJson(distributorsJson);
|
||||||
const int c = distributors.size();
|
const int c = distributors.size();
|
||||||
this->m_distributorCache.set(distributors);
|
m_distributorCache.set(distributors);
|
||||||
emit dataRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFinished, c);
|
emit dataRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFinished, c);
|
||||||
reallyRead |= CEntityFlags::DistributorEntity;
|
reallyRead |= CEntityFlags::DistributorEntity;
|
||||||
}
|
}
|
||||||
@@ -535,32 +535,32 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CModelDataReader::synchronizeCaches(CEntityFlags::Entity entities)
|
void CModelDataReader::synchronizeCaches(CEntityFlags::Entity entities)
|
||||||
{
|
{
|
||||||
if (entities.testFlag(CEntityFlags::LiveryEntity)) { this->m_liveryCache.synchronize(); }
|
if (entities.testFlag(CEntityFlags::LiveryEntity)) { m_liveryCache.synchronize(); }
|
||||||
if (entities.testFlag(CEntityFlags::ModelEntity)) { this->m_modelCache.synchronize(); }
|
if (entities.testFlag(CEntityFlags::ModelEntity)) { m_modelCache.synchronize(); }
|
||||||
if (entities.testFlag(CEntityFlags::DistributorEntity)) { this->m_distributorCache.synchronize(); }
|
if (entities.testFlag(CEntityFlags::DistributorEntity)) { m_distributorCache.synchronize(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModelDataReader::admitCaches(CEntityFlags::Entity entities)
|
void CModelDataReader::admitCaches(CEntityFlags::Entity entities)
|
||||||
{
|
{
|
||||||
if (entities.testFlag(CEntityFlags::LiveryEntity)) { this->m_liveryCache.admit(); }
|
if (entities.testFlag(CEntityFlags::LiveryEntity)) { m_liveryCache.admit(); }
|
||||||
if (entities.testFlag(CEntityFlags::ModelEntity)) { this->m_modelCache.admit(); }
|
if (entities.testFlag(CEntityFlags::ModelEntity)) { m_modelCache.admit(); }
|
||||||
if (entities.testFlag(CEntityFlags::DistributorEntity)) { this->m_distributorCache.admit(); }
|
if (entities.testFlag(CEntityFlags::DistributorEntity)) { m_distributorCache.admit(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModelDataReader::invalidateCaches(CEntityFlags::Entity entities)
|
void CModelDataReader::invalidateCaches(CEntityFlags::Entity entities)
|
||||||
{
|
{
|
||||||
if (entities.testFlag(CEntityFlags::LiveryEntity)) { CDataCache::instance()->clearAllValues(this->m_liveryCache.getKey()); }
|
if (entities.testFlag(CEntityFlags::LiveryEntity)) { CDataCache::instance()->clearAllValues(m_liveryCache.getKey()); }
|
||||||
if (entities.testFlag(CEntityFlags::ModelEntity)) { CDataCache::instance()->clearAllValues(this->m_modelCache.getKey()); }
|
if (entities.testFlag(CEntityFlags::ModelEntity)) { CDataCache::instance()->clearAllValues(m_modelCache.getKey()); }
|
||||||
if (entities.testFlag(CEntityFlags::DistributorEntity)) { CDataCache::instance()->clearAllValues(this->m_distributorCache.getKey()); }
|
if (entities.testFlag(CEntityFlags::DistributorEntity)) { CDataCache::instance()->clearAllValues(m_distributorCache.getKey()); }
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime CModelDataReader::getCacheTimestamp(CEntityFlags::Entity entity) const
|
QDateTime CModelDataReader::getCacheTimestamp(CEntityFlags::Entity entity) const
|
||||||
{
|
{
|
||||||
switch (entity)
|
switch (entity)
|
||||||
{
|
{
|
||||||
case CEntityFlags::LiveryEntity: return this->m_liveryCache.getAvailableTimestamp();
|
case CEntityFlags::LiveryEntity: return m_liveryCache.getAvailableTimestamp();
|
||||||
case CEntityFlags::ModelEntity: return this->m_modelCache.getAvailableTimestamp();
|
case CEntityFlags::ModelEntity: return m_modelCache.getAvailableTimestamp();
|
||||||
case CEntityFlags::DistributorEntity: return this->m_distributorCache.getAvailableTimestamp();
|
case CEntityFlags::DistributorEntity: return m_distributorCache.getAvailableTimestamp();
|
||||||
default: return QDateTime();
|
default: return QDateTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -569,9 +569,9 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
switch (entity)
|
switch (entity)
|
||||||
{
|
{
|
||||||
case CEntityFlags::LiveryEntity: return this->m_liveryCache.get().size();
|
case CEntityFlags::LiveryEntity: return m_liveryCache.get().size();
|
||||||
case CEntityFlags::ModelEntity: return this->m_modelCache.get().size();
|
case CEntityFlags::ModelEntity: return m_modelCache.get().size();
|
||||||
case CEntityFlags::DistributorEntity: return this->m_distributorCache.get().size();
|
case CEntityFlags::DistributorEntity: return m_distributorCache.get().size();
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -597,7 +597,7 @@ namespace BlackCore
|
|||||||
bool CModelDataReader::hasChangedUrl(CEntityFlags::Entity entity, CUrl &oldUrlInfo, CUrl &newUrlInfo) const
|
bool CModelDataReader::hasChangedUrl(CEntityFlags::Entity entity, CUrl &oldUrlInfo, CUrl &newUrlInfo) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(entity);
|
Q_UNUSED(entity);
|
||||||
oldUrlInfo = this->m_readerUrlCache.get();
|
oldUrlInfo = m_readerUrlCache.get();
|
||||||
newUrlInfo = this->getBaseUrl(CDbFlags::DbReading);
|
newUrlInfo = this->getBaseUrl(CDbFlags::DbReading);
|
||||||
return CDatabaseReader::isChangedUrl(oldUrlInfo, newUrlInfo);
|
return CDatabaseReader::isChangedUrl(oldUrlInfo, newUrlInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,18 +162,18 @@ namespace BlackCore
|
|||||||
BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode = BlackMisc::Db::CDbFlags::DbReading,
|
BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode = BlackMisc::Db::CDbFlags::DbReading,
|
||||||
const QDateTime &newerThan = QDateTime());
|
const QDateTime &newerThan = QDateTime());
|
||||||
|
|
||||||
void ps_liveryCacheChanged();
|
|
||||||
void ps_modelCacheChanged();
|
|
||||||
void ps_distributorCacheChanged();
|
|
||||||
void ps_baseUrlCacheChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BlackMisc::CData<BlackCore::Data::TDbLiveryCache> m_liveryCache {this, &CModelDataReader::ps_liveryCacheChanged };
|
BlackMisc::CData<BlackCore::Data::TDbLiveryCache> m_liveryCache {this, &CModelDataReader::liveryCacheChanged };
|
||||||
BlackMisc::CData<BlackCore::Data::TDbModelCache> m_modelCache {this, &CModelDataReader::ps_modelCacheChanged };
|
BlackMisc::CData<BlackCore::Data::TDbModelCache> m_modelCache {this, &CModelDataReader::modelCacheChanged };
|
||||||
BlackMisc::CData<BlackCore::Data::TDbDistributorCache> m_distributorCache {this, &CModelDataReader::ps_distributorCacheChanged };
|
BlackMisc::CData<BlackCore::Data::TDbDistributorCache> m_distributorCache {this, &CModelDataReader::distributorCacheChanged };
|
||||||
|
|
||||||
//! Reader URL (we read from where?) used to detect changes of location
|
//! Reader URL (we read from where?) used to detect changes of location
|
||||||
BlackMisc::CData<BlackCore::Data::TDbModelReaderBaseUrl> m_readerUrlCache {this, &CModelDataReader::ps_baseUrlCacheChanged };
|
BlackMisc::CData<BlackCore::Data::TDbModelReaderBaseUrl> m_readerUrlCache {this, &CModelDataReader::baseUrlCacheChanged };
|
||||||
|
|
||||||
|
void liveryCacheChanged();
|
||||||
|
void modelCacheChanged();
|
||||||
|
void distributorCacheChanged();
|
||||||
|
void baseUrlCacheChanged();
|
||||||
|
|
||||||
//! Update reader URL
|
//! Update reader URL
|
||||||
void updateReaderUrl(const BlackMisc::Network::CUrl &url);
|
void updateReaderUrl(const BlackMisc::Network::CUrl &url);
|
||||||
|
|||||||
@@ -860,7 +860,7 @@ namespace BlackCore
|
|||||||
const bool needsSharedInfoObjects = dbReaderConfig.needsSharedInfoObjects(dbEntities);
|
const bool needsSharedInfoObjects = dbReaderConfig.needsSharedInfoObjects(dbEntities);
|
||||||
const bool needsDbInfoObjects = dbReaderConfig.possiblyReadsFromSwiftDb();
|
const bool needsDbInfoObjects = dbReaderConfig.possiblyReadsFromSwiftDb();
|
||||||
bool c = false; // for signal connect
|
bool c = false; // for signal connect
|
||||||
const Qt::ConnectionType readerReadSignals = Qt::QueuedConnection; // Decouple processing of the reader signals from the readers
|
const Qt::ConnectionType typeReaderReadSignals = Qt::QueuedConnection; // Decouple processing of the reader signals from the readers
|
||||||
|
|
||||||
// 1a. If any DB data, read the info objects upfront
|
// 1a. If any DB data, read the info objects upfront
|
||||||
if (needsDbInfoObjects)
|
if (needsDbInfoObjects)
|
||||||
@@ -893,7 +893,7 @@ namespace BlackCore
|
|||||||
if (readersNeeded.testFlag(CWebReaderFlags::VatsimStatusReader) || readersNeeded.testFlag(CWebReaderFlags::VatsimDataReader) || readersNeeded.testFlag(CWebReaderFlags::VatsimMetarReader))
|
if (readersNeeded.testFlag(CWebReaderFlags::VatsimStatusReader) || readersNeeded.testFlag(CWebReaderFlags::VatsimDataReader) || readersNeeded.testFlag(CWebReaderFlags::VatsimMetarReader))
|
||||||
{
|
{
|
||||||
m_vatsimStatusReader = new CVatsimStatusFileReader(this);
|
m_vatsimStatusReader = new CVatsimStatusFileReader(this);
|
||||||
c = connect(m_vatsimStatusReader, &CVatsimStatusFileReader::dataFileRead, this, &CWebDataServices::vatsimStatusFileRead, readerReadSignals);
|
c = connect(m_vatsimStatusReader, &CVatsimStatusFileReader::dataFileRead, this, &CWebDataServices::vatsimStatusFileRead, typeReaderReadSignals);
|
||||||
CLogMessage(this).info("Trigger read of VATSIM status file");
|
CLogMessage(this).info("Trigger read of VATSIM status file");
|
||||||
m_vatsimStatusReader->start(QThread::LowPriority);
|
m_vatsimStatusReader->start(QThread::LowPriority);
|
||||||
|
|
||||||
@@ -907,9 +907,9 @@ namespace BlackCore
|
|||||||
if (readersNeeded.testFlag(CWebReaderFlags::WebReaderFlag::VatsimBookingReader))
|
if (readersNeeded.testFlag(CWebReaderFlags::WebReaderFlag::VatsimBookingReader))
|
||||||
{
|
{
|
||||||
m_vatsimBookingReader = new CVatsimBookingReader(this);
|
m_vatsimBookingReader = new CVatsimBookingReader(this);
|
||||||
c = connect(m_vatsimBookingReader, &CVatsimBookingReader::atcBookingsRead, this, &CWebDataServices::receivedBookings, readerReadSignals);
|
c = connect(m_vatsimBookingReader, &CVatsimBookingReader::atcBookingsRead, this, &CWebDataServices::receivedBookings, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "VATSIM booking reader signals");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "VATSIM booking reader signals");
|
||||||
c = connect(m_vatsimBookingReader, &CVatsimBookingReader::dataRead, this, &CWebDataServices::dataRead, readerReadSignals);
|
c = connect(m_vatsimBookingReader, &CVatsimBookingReader::dataRead, this, &CWebDataServices::dataRead, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "connect failed bookings");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "connect failed bookings");
|
||||||
m_entitiesPeriodicallyRead |= CEntityFlags::BookingEntity;
|
m_entitiesPeriodicallyRead |= CEntityFlags::BookingEntity;
|
||||||
m_vatsimBookingReader->start(QThread::LowPriority);
|
m_vatsimBookingReader->start(QThread::LowPriority);
|
||||||
@@ -920,9 +920,9 @@ namespace BlackCore
|
|||||||
if (readersNeeded.testFlag(CWebReaderFlags::WebReaderFlag::VatsimDataReader))
|
if (readersNeeded.testFlag(CWebReaderFlags::WebReaderFlag::VatsimDataReader))
|
||||||
{
|
{
|
||||||
m_vatsimDataFileReader = new CVatsimDataFileReader(this);
|
m_vatsimDataFileReader = new CVatsimDataFileReader(this);
|
||||||
c = connect(m_vatsimDataFileReader, &CVatsimDataFileReader::dataFileRead, this, &CWebDataServices::vatsimDataFileRead, readerReadSignals);
|
c = connect(m_vatsimDataFileReader, &CVatsimDataFileReader::dataFileRead, this, &CWebDataServices::vatsimDataFileRead, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "VATSIM data reader signals");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "VATSIM data reader signals");
|
||||||
c = connect(m_vatsimDataFileReader, &CVatsimDataFileReader::dataRead, this, &CWebDataServices::dataRead, readerReadSignals);
|
c = connect(m_vatsimDataFileReader, &CVatsimDataFileReader::dataRead, this, &CWebDataServices::dataRead, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "connect failed VATSIM data file");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "connect failed VATSIM data file");
|
||||||
m_entitiesPeriodicallyRead |= CEntityFlags::VatsimDataFile;
|
m_entitiesPeriodicallyRead |= CEntityFlags::VatsimDataFile;
|
||||||
m_vatsimDataFileReader->start(QThread::LowPriority);
|
m_vatsimDataFileReader->start(QThread::LowPriority);
|
||||||
@@ -933,9 +933,9 @@ namespace BlackCore
|
|||||||
if (readersNeeded.testFlag(CWebReaderFlags::WebReaderFlag::VatsimMetarReader))
|
if (readersNeeded.testFlag(CWebReaderFlags::WebReaderFlag::VatsimMetarReader))
|
||||||
{
|
{
|
||||||
m_vatsimMetarReader = new CVatsimMetarReader(this);
|
m_vatsimMetarReader = new CVatsimMetarReader(this);
|
||||||
c = connect(m_vatsimMetarReader, &CVatsimMetarReader::metarsRead, this, &CWebDataServices::receivedMetars, readerReadSignals);
|
c = connect(m_vatsimMetarReader, &CVatsimMetarReader::metarsRead, this, &CWebDataServices::receivedMetars, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "VATSIM METAR reader signals");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "VATSIM METAR reader signals");
|
||||||
c = connect(m_vatsimMetarReader, &CVatsimMetarReader::dataRead, this, &CWebDataServices::dataRead, readerReadSignals);
|
c = connect(m_vatsimMetarReader, &CVatsimMetarReader::dataRead, this, &CWebDataServices::dataRead, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "connect failed VATSIM METAR");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "connect failed VATSIM METAR");
|
||||||
m_entitiesPeriodicallyRead |= CEntityFlags::MetarEntity;
|
m_entitiesPeriodicallyRead |= CEntityFlags::MetarEntity;
|
||||||
m_vatsimMetarReader->start(QThread::LowPriority);
|
m_vatsimMetarReader->start(QThread::LowPriority);
|
||||||
@@ -946,11 +946,11 @@ namespace BlackCore
|
|||||||
if (readersNeeded.testFlag(CWebReaderFlags::WebReaderFlag::IcaoDataReader))
|
if (readersNeeded.testFlag(CWebReaderFlags::WebReaderFlag::IcaoDataReader))
|
||||||
{
|
{
|
||||||
m_icaoDataReader = new CIcaoDataReader(this, dbReaderConfig);
|
m_icaoDataReader = new CIcaoDataReader(this, dbReaderConfig);
|
||||||
c = connect(m_icaoDataReader, &CIcaoDataReader::dataRead, this, &CWebDataServices::readFromSwiftReader, readerReadSignals);
|
c = connect(m_icaoDataReader, &CIcaoDataReader::dataRead, this, &CWebDataServices::readFromSwiftReader, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect ICAO reader signals");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect ICAO reader signals");
|
||||||
c = connect(m_icaoDataReader, &CIcaoDataReader::dataRead, this, &CWebDataServices::dataRead, readerReadSignals);
|
c = connect(m_icaoDataReader, &CIcaoDataReader::dataRead, this, &CWebDataServices::dataRead, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect ICAO reader signals");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect ICAO reader signals");
|
||||||
c = connect(m_icaoDataReader, &CIcaoDataReader::swiftDbDataRead, this, &CWebDataServices::swiftDbDataRead, readerReadSignals);
|
c = connect(m_icaoDataReader, &CIcaoDataReader::swiftDbDataRead, this, &CWebDataServices::swiftDbDataRead, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect Model reader signals");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect Model reader signals");
|
||||||
m_icaoDataReader->start(QThread::LowPriority);
|
m_icaoDataReader->start(QThread::LowPriority);
|
||||||
}
|
}
|
||||||
@@ -959,11 +959,11 @@ namespace BlackCore
|
|||||||
if (readersNeeded.testFlag(CWebReaderFlags::WebReaderFlag::ModelReader))
|
if (readersNeeded.testFlag(CWebReaderFlags::WebReaderFlag::ModelReader))
|
||||||
{
|
{
|
||||||
m_modelDataReader = new CModelDataReader(this, dbReaderConfig);
|
m_modelDataReader = new CModelDataReader(this, dbReaderConfig);
|
||||||
c = connect(m_modelDataReader, &CModelDataReader::dataRead, this, &CWebDataServices::readFromSwiftReader, readerReadSignals);
|
c = connect(m_modelDataReader, &CModelDataReader::dataRead, this, &CWebDataServices::readFromSwiftReader, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect Model reader signals");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect Model reader signals");
|
||||||
c = connect(m_modelDataReader, &CModelDataReader::dataRead, this, &CWebDataServices::dataRead, readerReadSignals);
|
c = connect(m_modelDataReader, &CModelDataReader::dataRead, this, &CWebDataServices::dataRead, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect Model reader signals");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect Model reader signals");
|
||||||
c = connect(m_modelDataReader, &CModelDataReader::swiftDbDataRead, this, &CWebDataServices::swiftDbDataRead, readerReadSignals);
|
c = connect(m_modelDataReader, &CModelDataReader::swiftDbDataRead, this, &CWebDataServices::swiftDbDataRead, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect Model reader signals");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect Model reader signals");
|
||||||
m_modelDataReader->start(QThread::LowPriority);
|
m_modelDataReader->start(QThread::LowPriority);
|
||||||
}
|
}
|
||||||
@@ -972,11 +972,11 @@ namespace BlackCore
|
|||||||
if (readersNeeded.testFlag(CWebReaderFlags::WebReaderFlag::AirportReader))
|
if (readersNeeded.testFlag(CWebReaderFlags::WebReaderFlag::AirportReader))
|
||||||
{
|
{
|
||||||
m_airportDataReader = new CAirportDataReader(this, dbReaderConfig);
|
m_airportDataReader = new CAirportDataReader(this, dbReaderConfig);
|
||||||
c = connect(m_airportDataReader, &CAirportDataReader::dataRead, this, &CWebDataServices::readFromSwiftReader, readerReadSignals);
|
c = connect(m_airportDataReader, &CAirportDataReader::dataRead, this, &CWebDataServices::readFromSwiftReader, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect Model reader signals");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect Model reader signals");
|
||||||
c = connect(m_airportDataReader, &CAirportDataReader::dataRead, this, &CWebDataServices::dataRead, readerReadSignals);
|
c = connect(m_airportDataReader, &CAirportDataReader::dataRead, this, &CWebDataServices::dataRead, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect Model reader signals");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect Model reader signals");
|
||||||
c = connect(m_airportDataReader, &CAirportDataReader::swiftDbDataRead, this, &CWebDataServices::swiftDbDataRead, readerReadSignals);
|
c = connect(m_airportDataReader, &CAirportDataReader::swiftDbDataRead, this, &CWebDataServices::swiftDbDataRead, typeReaderReadSignals);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect Model reader signals");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect Model reader signals");
|
||||||
m_airportDataReader->start(QThread::LowPriority);
|
m_airportDataReader->start(QThread::LowPriority);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user