mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 05:28:09 +08:00
* adjustments to use deferred caches * removed simulator from CAircraftModelSetLoader`s signature as it was not used * only change current simulator when explicitly set (avoid unintended setting) * added function to obtain number of elements from model caches
This commit is contained in:
@@ -51,7 +51,6 @@ namespace BlackCore
|
||||
CEntityFlags::Entity allEntities = entities;
|
||||
CEntityFlags::Entity currentEntity = CEntityFlags::iterateDbEntities(allEntities); // CEntityFlags::InfoObjectEntity will be ignored
|
||||
const bool hasInfoObjects = this->hasInfoObjects();
|
||||
const bool changedUrl = this->hasChangedUrl(currentEntity);
|
||||
while (currentEntity)
|
||||
{
|
||||
const CDatabaseReaderConfig config(this->getConfigForEntity(currentEntity));
|
||||
@@ -59,6 +58,7 @@ namespace BlackCore
|
||||
{
|
||||
if (hasInfoObjects)
|
||||
{
|
||||
const bool changedUrl = this->hasChangedUrl(currentEntity);
|
||||
const QDateTime cacheTs(this->getCacheTimestamp(currentEntity));
|
||||
const QDateTime latestEntityTs(this->getLatestEntityTimestamp(currentEntity));
|
||||
const qint64 cacheTimestamp = cacheTs.isValid() ? cacheTs.toMSecsSinceEpoch() : -1;
|
||||
@@ -76,7 +76,8 @@ namespace BlackCore
|
||||
{
|
||||
if (changedUrl)
|
||||
{
|
||||
CLogMessage(this).info("Data location changed, will override cache");
|
||||
CLogMessage(this).info("Data location changed, will override cache for %1")
|
||||
<< CEntityFlags::flagToString(currentEntity);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -90,7 +91,11 @@ namespace BlackCore
|
||||
{
|
||||
// no info objects, server down
|
||||
this->syncronizeCaches(currentEntity);
|
||||
CLogMessage(this).info("No info object for %1, using cache") << CEntityFlags::flagToString(currentEntity);
|
||||
const int c = this->getCacheCount(currentEntity);
|
||||
CLogMessage(this).info("No info object for %1, using cache with %2 objects")
|
||||
<< CEntityFlags::flagToString(currentEntity)
|
||||
<< c;
|
||||
entities &= ~currentEntity; // do not load from web
|
||||
}
|
||||
}
|
||||
currentEntity = CEntityFlags::iterateDbEntities(allEntities);
|
||||
|
||||
@@ -149,7 +149,10 @@ namespace BlackCore
|
||||
virtual void syncronizeCaches(BlackMisc::Network::CEntityFlags::Entity entities) = 0;
|
||||
|
||||
//! Cache`s timestamp for given entity
|
||||
virtual QDateTime getCacheTimestamp(BlackMisc::Network::CEntityFlags::Entity entities) = 0;
|
||||
virtual QDateTime getCacheTimestamp(BlackMisc::Network::CEntityFlags::Entity entities) const = 0;
|
||||
|
||||
//! Cache`s number of entities
|
||||
virtual int getCacheCount(BlackMisc::Network::CEntityFlags::Entity entity) const = 0;
|
||||
|
||||
//! Invalidate the caches for given entities
|
||||
virtual void invalidateCaches(BlackMisc::Network::CEntityFlags::Entity entities) = 0;
|
||||
|
||||
@@ -399,7 +399,7 @@ namespace BlackCore
|
||||
if (entities.testFlag(CEntityFlags::CountryEntity)) {CDataCache::instance()->clearAllValues(this->m_countryCache.getKey()); }
|
||||
}
|
||||
|
||||
QDateTime CIcaoDataReader::getCacheTimestamp(CEntityFlags::Entity entity)
|
||||
QDateTime CIcaoDataReader::getCacheTimestamp(CEntityFlags::Entity entity) const
|
||||
{
|
||||
switch (entity)
|
||||
{
|
||||
@@ -410,6 +410,17 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
int CIcaoDataReader::getCacheCount(CEntityFlags::Entity entity) const
|
||||
{
|
||||
switch (entity)
|
||||
{
|
||||
case CEntityFlags::AircraftIcaoEntity: return this->m_aircraftIcaoCache.getCopy().size();
|
||||
case CEntityFlags::AirlineIcaoEntity: return this->m_airlineIcaoCache.getCopy().size();
|
||||
case CEntityFlags::CountryEntity: return this->m_countryCache.getCopy().size();
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool CIcaoDataReader::hasChangedUrl(CEntityFlags::Entity entity) const
|
||||
{
|
||||
Q_UNUSED(entity);
|
||||
|
||||
@@ -123,7 +123,8 @@ namespace BlackCore
|
||||
//! @{
|
||||
virtual void syncronizeCaches(BlackMisc::Network::CEntityFlags::Entity entities) override;
|
||||
virtual void invalidateCaches(BlackMisc::Network::CEntityFlags::Entity entities) override;
|
||||
virtual QDateTime getCacheTimestamp(BlackMisc::Network::CEntityFlags::Entity entity) override;
|
||||
virtual QDateTime getCacheTimestamp(BlackMisc::Network::CEntityFlags::Entity entity) const override;
|
||||
virtual int getCacheCount(BlackMisc::Network::CEntityFlags::Entity entity) const override;
|
||||
virtual bool hasChangedUrl(BlackMisc::Network::CEntityFlags::Entity entity) const override;
|
||||
//! @}
|
||||
|
||||
|
||||
@@ -62,13 +62,20 @@ namespace BlackCore
|
||||
Q_UNUSED(entities);
|
||||
}
|
||||
|
||||
QDateTime CInfoDataReader::getCacheTimestamp(CEntityFlags::Entity entity)
|
||||
QDateTime CInfoDataReader::getCacheTimestamp(CEntityFlags::Entity entity) const
|
||||
{
|
||||
// no caching used here
|
||||
Q_UNUSED(entity);
|
||||
return QDateTime();
|
||||
}
|
||||
|
||||
int CInfoDataReader::getCacheCount(CEntityFlags::Entity entity) const
|
||||
{
|
||||
// no caching used here
|
||||
Q_UNUSED(entity);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CInfoDataReader::hasChangedUrl(CEntityFlags::Entity entity) const
|
||||
{
|
||||
// not implemented
|
||||
|
||||
@@ -61,7 +61,8 @@ namespace BlackCore
|
||||
//! @{
|
||||
virtual void syncronizeCaches(BlackMisc::Network::CEntityFlags::Entity entities) override;
|
||||
virtual void invalidateCaches(BlackMisc::Network::CEntityFlags::Entity entities) override;
|
||||
virtual QDateTime getCacheTimestamp(BlackMisc::Network::CEntityFlags::Entity entity) override;
|
||||
virtual QDateTime getCacheTimestamp(BlackMisc::Network::CEntityFlags::Entity entity) const override;
|
||||
virtual int getCacheCount(BlackMisc::Network::CEntityFlags::Entity entity) const override;
|
||||
virtual bool hasChangedUrl(BlackMisc::Network::CEntityFlags::Entity entity) const override;
|
||||
//! @}
|
||||
|
||||
|
||||
@@ -437,12 +437,18 @@ namespace BlackCore
|
||||
Q_UNUSED(entities);
|
||||
}
|
||||
|
||||
QDateTime CModelDataReader::getCacheTimestamp(CEntityFlags::Entity entity)
|
||||
QDateTime CModelDataReader::getCacheTimestamp(CEntityFlags::Entity entity) const
|
||||
{
|
||||
Q_UNUSED(entity);
|
||||
return QDateTime();
|
||||
}
|
||||
|
||||
int CModelDataReader::getCacheCount(CEntityFlags::Entity entity) const
|
||||
{
|
||||
Q_UNUSED(entity);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CModelDataReader::hasChangedUrl(CEntityFlags::Entity entity) const
|
||||
{
|
||||
Q_UNUSED(entity);
|
||||
|
||||
@@ -128,7 +128,8 @@ namespace BlackCore
|
||||
//! @{
|
||||
virtual void syncronizeCaches(BlackMisc::Network::CEntityFlags::Entity entities) override;
|
||||
virtual void invalidateCaches(BlackMisc::Network::CEntityFlags::Entity entities) override;
|
||||
virtual QDateTime getCacheTimestamp(BlackMisc::Network::CEntityFlags::Entity entity) override;
|
||||
virtual QDateTime getCacheTimestamp(BlackMisc::Network::CEntityFlags::Entity entity) const override;
|
||||
virtual int getCacheCount(BlackMisc::Network::CEntityFlags::Entity entity) const override;
|
||||
virtual bool hasChangedUrl(BlackMisc::Network::CEntityFlags::Entity entity) const override;
|
||||
//! @}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace BlackCore
|
||||
|
||||
//! \todo unclear if this is valid for all simulators or for MS/P3D simulators only
|
||||
BlackCore::CAircraftMatcher m_modelMatcher; //!< Model matcher
|
||||
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { BlackMisc::Simulation::CSimulatorInfo(BlackMisc::Simulation::CSimulatorInfo::FSX), this }; //!< load model set from caches
|
||||
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { this }; //!< load model set from caches
|
||||
|
||||
private:
|
||||
bool m_debugMessages = false; //!< Display debug messages
|
||||
|
||||
Reference in New Issue
Block a user