mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 08:45:36 +08:00
Ref T490, "ps_read" replacement
This commit is contained in:
committed by
Mat Sutcliffe
parent
788f827110
commit
003ad0f0de
@@ -239,7 +239,7 @@ namespace BlackCore
|
||||
this->emitAndLogDataRead(CEntityFlags::AirportEntity, size, res);
|
||||
}
|
||||
|
||||
void CAirportDataReader::ps_read(CEntityFlags::Entity entity, CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)
|
||||
void CAirportDataReader::read(CEntityFlags::Entity entity, CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)
|
||||
{
|
||||
this->threadAssertCheck();
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
|
||||
@@ -69,11 +69,6 @@ namespace BlackCore
|
||||
virtual bool hasChangedUrl(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CUrl &oldUrlInfo, BlackMisc::Network::CUrl &newUrlInfo) const override;
|
||||
virtual BlackMisc::Network::CUrl getDbServiceBaseUrl() const override;
|
||||
|
||||
private slots:
|
||||
//! Read / re-read data file
|
||||
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());
|
||||
|
||||
private:
|
||||
BlackMisc::CData<BlackCore::Data::TDbAirportCache> m_airportCache {this, &CAirportDataReader::airportCacheChanged}; //!< cache file
|
||||
std::atomic_bool m_syncedAirportCache { false }; //!< already synchronized?
|
||||
@@ -81,6 +76,9 @@ namespace BlackCore
|
||||
//! Reader URL (we read from where?) used to detect changes of location
|
||||
BlackMisc::CData<BlackCore::Data::TDbModelReaderBaseUrl> m_readerUrlCache {this, &CAirportDataReader::baseUrlCacheChanged };
|
||||
|
||||
//! \copydoc CDatabaseReader::read
|
||||
void read(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan) override;
|
||||
|
||||
//! Parse downloaded JSON file
|
||||
void parseAirportData(QNetworkReply *nwReplyPtr);
|
||||
|
||||
|
||||
@@ -221,14 +221,13 @@ namespace BlackCore
|
||||
if (entities == CEntityFlags::NoEntity) { return; }
|
||||
if (!this->isInternetAccessible(QStringLiteral("No network/internet access, will not read %1").arg(CEntityFlags::flagToString(entities)))) { return; }
|
||||
|
||||
//! \todo MS 2018-12 Error: CDatabaseReader has no ps_read method -> T490
|
||||
//! \todo KB 2018-12 https://dev.swift-project.org/T490
|
||||
const bool s = QMetaObject::invokeMethod(this, "ps_read",
|
||||
Q_ARG(BlackMisc::Network::CEntityFlags::Entity, entities),
|
||||
Q_ARG(BlackMisc::Db::CDbFlags::DataRetrievalModeFlag, mode),
|
||||
Q_ARG(QDateTime, newerThan));
|
||||
Q_ASSERT_X(s, Q_FUNC_INFO, "Invoke failed");
|
||||
Q_UNUSED(s);
|
||||
//! https://dev.swift-project.org/T490
|
||||
QPointer<CDatabaseReader> myself(this);
|
||||
QTimer::singleShot(0, this, [ = ]
|
||||
{
|
||||
if (!sApp || sApp->isShuttingDown() || !myself) { return; }
|
||||
this->read(entities, mode, newerThan);
|
||||
});
|
||||
}
|
||||
|
||||
CDatabaseReader::JsonDatastoreResponse CDatabaseReader::transformReplyIntoDatastoreResponse(QNetworkReply *nwReply) const
|
||||
|
||||
@@ -431,6 +431,10 @@ namespace BlackCore
|
||||
|
||||
//! Network request progress
|
||||
virtual void networkReplyProgress(int logId, qint64 current, qint64 max, const QUrl &url) override;
|
||||
|
||||
private:
|
||||
//! Read / re-read data file
|
||||
virtual void read(BlackMisc::Network::CEntityFlags::Entity entities, BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan) = 0;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace BlackCore
|
||||
return this->getCountries().size();
|
||||
}
|
||||
|
||||
void CIcaoDataReader::ps_read(CEntityFlags::Entity entities, CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)
|
||||
void CIcaoDataReader::read(CEntityFlags::Entity entities, CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)
|
||||
{
|
||||
this->threadAssertCheck(); // runs in background thread
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
|
||||
@@ -154,11 +154,6 @@ namespace BlackCore
|
||||
virtual bool hasChangedUrl(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CUrl &oldUrlInfo, BlackMisc::Network::CUrl &newUrlInfo) const override;
|
||||
virtual BlackMisc::Network::CUrl getDbServiceBaseUrl() const override;
|
||||
|
||||
private slots:
|
||||
//! Read / re-read data
|
||||
void ps_read(BlackMisc::Network::CEntityFlags::Entity entities,
|
||||
BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan);
|
||||
|
||||
private:
|
||||
BlackMisc::CData<BlackCore::Data::TDbAircraftIcaoCache> m_aircraftIcaoCache {this, &CIcaoDataReader::aircraftIcaoCacheChanged };
|
||||
BlackMisc::CData<BlackCore::Data::TDbAirlineIcaoCache> m_airlineIcaoCache {this, &CIcaoDataReader::airlineIcaoCacheChanged };
|
||||
@@ -167,6 +162,10 @@ namespace BlackCore
|
||||
std::atomic_bool m_syncedAirlineIcaoCache { false }; //!< already synchronized?
|
||||
std::atomic_bool m_syncedCountryCache { false }; //!< already synchronized?
|
||||
|
||||
//! \copydoc CDatabaseReader::read
|
||||
virtual void read(BlackMisc::Network::CEntityFlags::Entity entities,
|
||||
BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan) override;
|
||||
|
||||
//! Reader URL (we read from where?) used to detect changes of location
|
||||
BlackMisc::CData<BlackCore::Data::TDbIcaoReaderBaseUrl> m_readerUrlCache {this, &CIcaoDataReader::baseUrlCacheChanged };
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace BlackCore
|
||||
return sApp->getGlobalSetup().getDbInfoReaderUrl();
|
||||
}
|
||||
|
||||
void CInfoDataReader::read()
|
||||
void CInfoDataReader::readInfoData()
|
||||
{
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
|
||||
@@ -206,17 +206,25 @@ namespace BlackCore
|
||||
CEntityFlags::EntityFlag CInfoDataReader::getEntityForMode() const
|
||||
{
|
||||
if (m_mode == CDbFlags::DbReading) return CEntityFlags::DbInfoObjectEntity;
|
||||
if (m_mode == CDbFlags::Shared) return CEntityFlags::SharedInfoObjectEntity;
|
||||
if (m_mode == CDbFlags::Shared) return CEntityFlags::SharedInfoObjectEntity;
|
||||
qFatal("Wrong mode");
|
||||
return CEntityFlags::NoEntity;
|
||||
}
|
||||
|
||||
void CInfoDataReader::read(CEntityFlags::Entity entities, CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)
|
||||
{
|
||||
Q_UNUSED(entities);
|
||||
Q_UNUSED(mode);
|
||||
Q_UNUSED(newerThan);
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Not implemented for CInfoDataReader");
|
||||
}
|
||||
|
||||
CUrl CInfoDataReader::getInfoObjectsUrl() const
|
||||
{
|
||||
switch (m_mode)
|
||||
{
|
||||
case CDbFlags::DbReading: return getDbInfoObjectsUrl();
|
||||
case CDbFlags::Shared: return getSharedInfoObjectsUrl();
|
||||
case CDbFlags::Shared: return getSharedInfoObjectsUrl();
|
||||
default: qFatal("Wrong mode");
|
||||
}
|
||||
return CUrl();
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace BlackCore
|
||||
bool areAllInfoObjectsRead() const;
|
||||
|
||||
//! Allow to call directly, special for info objects reader
|
||||
void read();
|
||||
void readInfoData();
|
||||
|
||||
//! URL depending on mode, i.e. shared/DB
|
||||
BlackMisc::Network::CUrl getInfoObjectsUrl() const;
|
||||
@@ -86,6 +86,9 @@ namespace BlackCore
|
||||
//! \remark CEntityFlags::DbInfoObjectEntity or CEntityFlags::SharedInfoObjectEntity
|
||||
BlackMisc::Network::CEntityFlags::EntityFlag getEntityForMode() const;
|
||||
|
||||
//! \copydoc CDatabaseReader::read
|
||||
virtual void read(BlackMisc::Network::CEntityFlags::Entity entities, BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan) override;
|
||||
|
||||
BlackMisc::Db::CDbFlags::DataRetrievalModeFlag m_mode; //!< shared or DB web service?
|
||||
BlackMisc::Db::CDbInfoList m_infoObjects;
|
||||
BlackMisc::Network::CUrl m_urlInfoObjects;
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace BlackCore
|
||||
this->getDistributorsCount() > 0;
|
||||
}
|
||||
|
||||
void CModelDataReader::ps_read(CEntityFlags::Entity entities, CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)
|
||||
void CModelDataReader::read(CEntityFlags::Entity entities, CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)
|
||||
{
|
||||
this->threadAssertCheck();
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
|
||||
@@ -154,12 +154,6 @@ namespace BlackCore
|
||||
virtual bool hasChangedUrl(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CUrl &oldUrlInfo, BlackMisc::Network::CUrl &newUrlInfo) const override;
|
||||
virtual BlackMisc::Network::CUrl getDbServiceBaseUrl() const override;
|
||||
|
||||
private slots:
|
||||
//! Read / re-read data file
|
||||
void ps_read(BlackMisc::Network::CEntityFlags::Entity entities = BlackMisc::Network::CEntityFlags::DistributorLiveryModel,
|
||||
BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode = BlackMisc::Db::CDbFlags::DbReading,
|
||||
const QDateTime &newerThan = QDateTime());
|
||||
|
||||
private:
|
||||
BlackMisc::CData<BlackCore::Data::TDbLiveryCache> m_liveryCache { this, &CModelDataReader::liveryCacheChanged };
|
||||
BlackMisc::CData<BlackCore::Data::TDbModelCache> m_modelCache { this, &CModelDataReader::modelCacheChanged };
|
||||
@@ -168,6 +162,10 @@ namespace BlackCore
|
||||
std::atomic_bool m_syncedModelCache { false }; //!< already synchronized?
|
||||
std::atomic_bool m_syncedDistributorCache { false }; //!< already synchronized?
|
||||
|
||||
//! \copydoc CDatabaseReader::read
|
||||
virtual void read(BlackMisc::Network::CEntityFlags::Entity entities = BlackMisc::Network::CEntityFlags::DistributorLiveryModel,
|
||||
BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode = BlackMisc::Db::CDbFlags::DbReading, const QDateTime &newerThan = QDateTime()) override;
|
||||
|
||||
//! Reader URL (we read from where?) used to detect changes of location
|
||||
BlackMisc::CData<BlackCore::Data::TDbModelReaderBaseUrl> m_readerUrlCache { this, &CModelDataReader::baseUrlCacheChanged };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user