refs #656, using deferred for large caches

This commit is contained in:
Klaus Basan
2016-05-27 23:32:39 +02:00
parent 467f37db7f
commit e6f0db73c5
3 changed files with 24 additions and 4 deletions

View File

@@ -33,6 +33,9 @@ namespace BlackCore
//! Default value //! Default value
static const BlackMisc::Simulation::CAircraftModelList &defaultValue(); static const BlackMisc::Simulation::CAircraftModelList &defaultValue();
//! Defer loading
static constexpr bool isDeferred() { return true; }
//! Key in data cache //! Key in data cache
static const char *key() { return "dbmodelcache"; } static const char *key() { return "dbmodelcache"; }
}; };
@@ -43,6 +46,9 @@ namespace BlackCore
//! Default value //! Default value
static const BlackMisc::Aviation::CAirlineIcaoCodeList &defaultValue(); static const BlackMisc::Aviation::CAirlineIcaoCodeList &defaultValue();
//! Defer loading
static constexpr bool isDeferred() { return true; }
//! Key in data cache //! Key in data cache
static const char *key() { return "dbairlineicaocache"; } static const char *key() { return "dbairlineicaocache"; }
}; };
@@ -54,6 +60,9 @@ namespace BlackCore
//! Default value //! Default value
static const BlackMisc::Aviation::CAircraftIcaoCodeList &defaultValue(); static const BlackMisc::Aviation::CAircraftIcaoCodeList &defaultValue();
//! Defer loading
static constexpr bool isDeferred() { return true; }
//! Key in data cache //! Key in data cache
static const char *key() { return "dbaircrafticaocache"; } static const char *key() { return "dbaircrafticaocache"; }
}; };
@@ -64,6 +73,9 @@ namespace BlackCore
//! Default value //! Default value
static const BlackMisc::CCountryList &defaultValue(); static const BlackMisc::CCountryList &defaultValue();
//! Defer loading (no currently small)
static constexpr bool isDeferred() { return false; }
//! Key in data cache //! Key in data cache
static const char *key() { return "dbcountrycache"; } static const char *key() { return "dbcountrycache"; }
}; };
@@ -74,6 +86,9 @@ namespace BlackCore
//! Default value //! Default value
static const BlackMisc::Aviation::CLiveryList &defaultValue(); static const BlackMisc::Aviation::CLiveryList &defaultValue();
//! Defer loading
static constexpr bool isDeferred() { return true; }
//! Key in data cache //! Key in data cache
static const char *key() { return "dbliverycache"; } static const char *key() { return "dbliverycache"; }
}; };

View File

@@ -43,6 +43,7 @@ namespace BlackMisc
CModelCaches::CModelCaches(QObject *parent) : IMultiSimulatorModelCaches(parent) CModelCaches::CModelCaches(QObject *parent) : IMultiSimulatorModelCaches(parent)
{ {
this->m_currentSimulator.synchronize(); this->m_currentSimulator.synchronize();
this->syncronizeCache(this->m_currentSimulator.getCopy());
} }
CAircraftModelList CModelCaches::getCachedModels(const CSimulatorInfo &simulator) const CAircraftModelList CModelCaches::getCachedModels(const CSimulatorInfo &simulator) const
@@ -123,6 +124,7 @@ namespace BlackMisc
CModelSetCaches::CModelSetCaches(QObject *parent) : IMultiSimulatorModelCaches(parent) CModelSetCaches::CModelSetCaches(QObject *parent) : IMultiSimulatorModelCaches(parent)
{ {
this->m_currentSimulator.synchronize(); this->m_currentSimulator.synchronize();
this->syncronizeCache(this->m_currentSimulator.getCopy());
} }
CAircraftModelList CModelSetCaches::getCachedModels(const CSimulatorInfo &simulator) const CAircraftModelList CModelSetCaches::getCachedModels(const CSimulatorInfo &simulator) const
@@ -189,10 +191,10 @@ namespace BlackMisc
if (m.isFailure()) { CLogMessage::preformatted(m); } if (m.isFailure()) { CLogMessage::preformatted(m); }
switch (simulator.getSimulator()) switch (simulator.getSimulator())
{ {
case CSimulatorInfo::FS9: return this->m_modelCacheFs9.synchronize(); break; case CSimulatorInfo::FS9: this->m_modelCacheFs9.synchronize(); break;
case CSimulatorInfo::FSX: return this->m_modelCacheFsx.synchronize(); break; case CSimulatorInfo::FSX: this->m_modelCacheFsx.synchronize(); break;
case CSimulatorInfo::P3D: return this->m_modelCacheP3D.synchronize(); break; case CSimulatorInfo::P3D: this->m_modelCacheP3D.synchronize(); break;
case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.synchronize(); break; case CSimulatorInfo::XPLANE: this->m_modelCacheXP.synchronize(); break;
default: default:
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator"); Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
} }

View File

@@ -30,6 +30,9 @@ namespace BlackMisc
//! Trait for model cache //! Trait for model cache
struct ModelCache : public BlackMisc::CDataTrait<BlackMisc::Simulation::CAircraftModelList> struct ModelCache : public BlackMisc::CDataTrait<BlackMisc::Simulation::CAircraftModelList>
{ {
//! Defer loading
static constexpr bool isDeferred() { return true; }
//! Default value //! Default value
static const BlackMisc::Simulation::CAircraftModelList &defaultValue() static const BlackMisc::Simulation::CAircraftModelList &defaultValue()
{ {