mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-03 16:25:54 +08:00
Ref T224, allow to check for empty caches
This commit is contained in:
@@ -185,14 +185,26 @@ namespace BlackCore
|
|||||||
|
|
||||||
bool CWebDataServices::hasDbAircraftData() const
|
bool CWebDataServices::hasDbAircraftData() const
|
||||||
{
|
{
|
||||||
return (this->getModelsCount() > 0) && (this->getLiveriesCount() > 0) && (this->getDistributorsCount() > 0) && (this->getAircraftIcaoCodesCount() > 0);
|
return this->hasDbIcaoData() && this->hasDbModelData();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CWebDataServices::hasDbModelData() const
|
||||||
|
{
|
||||||
|
return (this->getModelsCount() > 0) && (this->getLiveriesCount() > 0) && (this->getDistributorsCount() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CWebDataServices::hasDbIcaoData() const
|
||||||
|
{
|
||||||
|
return (this->getAircraftIcaoCodesCount() > 0) && (this->getAirlineIcaoCodesCount() > 0) && (this->getCountriesCount() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWebDataServices::admitDbCaches(CEntityFlags::Entity entities)
|
void CWebDataServices::admitDbCaches(CEntityFlags::Entity entities)
|
||||||
{
|
{
|
||||||
|
if (m_shuttingDown) { return; }
|
||||||
|
|
||||||
// hint: those 2 are currently doing nothing, but this might change in the future
|
// hint: those 2 are currently doing nothing, but this might change in the future
|
||||||
if (m_dbInfoDataReader) { m_dbInfoDataReader->admitCaches(entities); }
|
// if (m_dbInfoDataReader) { m_dbInfoDataReader->admitCaches(entities); }
|
||||||
if (m_sharedInfoDataReader) { m_sharedInfoDataReader->admitCaches(entities); }
|
// if (m_sharedInfoDataReader) { m_sharedInfoDataReader->admitCaches(entities); }
|
||||||
|
|
||||||
// hint: all the readers use own threads
|
// hint: all the readers use own threads
|
||||||
if (m_modelDataReader) { m_modelDataReader->admitCaches(entities); }
|
if (m_modelDataReader) { m_modelDataReader->admitCaches(entities); }
|
||||||
@@ -200,9 +212,24 @@ namespace BlackCore
|
|||||||
if (m_airportDataReader) { m_airportDataReader->admitCaches(entities); }
|
if (m_airportDataReader) { m_airportDataReader->admitCaches(entities); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWebDataServices::synchronizeDbCaches(CEntityFlags::Entity entities)
|
||||||
|
{
|
||||||
|
if (m_shuttingDown) { return; }
|
||||||
|
|
||||||
|
// hint: those 2 are currently doing nothing, but this might change in the future
|
||||||
|
// if (m_dbInfoDataReader) { m_dbInfoDataReader->synchronizeCaches(entities); }
|
||||||
|
// if (m_sharedInfoDataReader) { m_sharedInfoDataReader->synchronizeCaches(entities); }
|
||||||
|
|
||||||
|
// hint: all the readers use own threads
|
||||||
|
if (m_modelDataReader) { m_modelDataReader->synchronizeCaches(entities); }
|
||||||
|
if (m_icaoDataReader) { m_icaoDataReader->synchronizeCaches(entities); }
|
||||||
|
if (m_airportDataReader) { m_airportDataReader->synchronizeCaches(entities); }
|
||||||
|
}
|
||||||
|
|
||||||
CEntityFlags::Entity CWebDataServices::triggerRead(CEntityFlags::Entity whatToRead, const QDateTime &newerThan)
|
CEntityFlags::Entity CWebDataServices::triggerRead(CEntityFlags::Entity whatToRead, const QDateTime &newerThan)
|
||||||
{
|
{
|
||||||
if (m_shuttingDown) { return CEntityFlags::NoEntity; }
|
if (m_shuttingDown) { return CEntityFlags::NoEntity; }
|
||||||
|
|
||||||
m_initialRead = true; // read started
|
m_initialRead = true; // read started
|
||||||
Q_ASSERT_X(!whatToRead.testFlag(CEntityFlags::DbInfoObjectEntity), Q_FUNC_INFO, "Info object must be read upfront");
|
Q_ASSERT_X(!whatToRead.testFlag(CEntityFlags::DbInfoObjectEntity), Q_FUNC_INFO, "Info object must be read upfront");
|
||||||
CEntityFlags::Entity triggeredRead = CEntityFlags::NoEntity;
|
CEntityFlags::Entity triggeredRead = CEntityFlags::NoEntity;
|
||||||
@@ -392,6 +419,20 @@ namespace BlackCore
|
|||||||
return m_sharedInfoDataReader->getEntitesWithNewerSharedInfoObject(entities);
|
return m_sharedInfoDataReader->getEntitesWithNewerSharedInfoObject(entities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CEntityFlags::Entity CWebDataServices::getEmptyEntities(CEntityFlags::Entity entities) const
|
||||||
|
{
|
||||||
|
entities &= CEntityFlags::AllDbEntities; // handled by this reader
|
||||||
|
CEntityFlags::Entity currentEntity = CEntityFlags::iterateDbEntities(entities);
|
||||||
|
CEntityFlags::Entity emptyEntities = CEntityFlags::NoEntity;
|
||||||
|
while (currentEntity != CEntityFlags::NoEntity)
|
||||||
|
{
|
||||||
|
const int c = this->getCacheCount(currentEntity);
|
||||||
|
if (c < 1) { emptyEntities |= currentEntity; }
|
||||||
|
currentEntity = CEntityFlags::iterateDbEntities(entities);
|
||||||
|
}
|
||||||
|
return emptyEntities;
|
||||||
|
}
|
||||||
|
|
||||||
int CWebDataServices::getCacheCount(CEntityFlags::Entity entity) const
|
int CWebDataServices::getCacheCount(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");
|
||||||
|
|||||||
@@ -397,6 +397,11 @@ namespace BlackCore
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
BlackMisc::Network::CEntityFlags::Entity getEntitiesWithNewerSharedFile(BlackMisc::Network::CEntityFlags::Entity entities) const;
|
BlackMisc::Network::CEntityFlags::Entity getEntitiesWithNewerSharedFile(BlackMisc::Network::CEntityFlags::Entity entities) const;
|
||||||
|
|
||||||
|
//! Empty entities in cache
|
||||||
|
//! \remark can also be empty because cache is not yet synchronized
|
||||||
|
//! \threadsafe
|
||||||
|
BlackMisc::Network::CEntityFlags::Entity getEmptyEntities(BlackMisc::Network::CEntityFlags::Entity entities = BlackMisc::Network::CEntityFlags::AllDbEntities) const;
|
||||||
|
|
||||||
//! Cache count for entity
|
//! Cache count for entity
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
int getCacheCount(BlackMisc::Network::CEntityFlags::Entity entity) const;
|
int getCacheCount(BlackMisc::Network::CEntityFlags::Entity entity) const;
|
||||||
@@ -424,6 +429,12 @@ namespace BlackCore
|
|||||||
//! Are all DB data for an aircraft entity available?
|
//! Are all DB data for an aircraft entity available?
|
||||||
bool hasDbAircraftData() const;
|
bool hasDbAircraftData() const;
|
||||||
|
|
||||||
|
//! Are DB model data available?
|
||||||
|
bool hasDbModelData() const;
|
||||||
|
|
||||||
|
//! Are all DB ICAO data available?
|
||||||
|
bool hasDbIcaoData() const;
|
||||||
|
|
||||||
//! Admit all DB caches specified
|
//! Admit all DB caches specified
|
||||||
void admitDbCaches(BlackMisc::Network::CEntityFlags::Entity entities);
|
void admitDbCaches(BlackMisc::Network::CEntityFlags::Entity entities);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user