refs #787, caches/model set loader

* Caches initialized
* simulators with model set
This commit is contained in:
Klaus Basan
2016-11-27 01:21:53 +01:00
parent 967e3de226
commit 2ccf3fd4a2
4 changed files with 28 additions and 1 deletions

View File

@@ -126,6 +126,11 @@ namespace BlackMisc
return this->getSimulator().matchesAny(info); return this->getSimulator().matchesAny(info);
} }
CSimulatorInfo CAircraftModelSetLoader::simulatorsWithInitializedModelSet() const
{
return this->m_caches.simulatorsWithInitializedCache();
}
void CAircraftModelSetLoader::gracefulShutdown() void CAircraftModelSetLoader::gracefulShutdown()
{ {
// void // void

View File

@@ -84,6 +84,9 @@ namespace BlackMisc
//! Is the given simulator supported? //! Is the given simulator supported?
bool supportsSimulator(const BlackMisc::Simulation::CSimulatorInfo &info); bool supportsSimulator(const BlackMisc::Simulation::CSimulatorInfo &info);
//! Simulators with initialized caches
CSimulatorInfo simulatorsWithInitializedModelSet() const;
//! Shutdown //! Shutdown
void gracefulShutdown(); void gracefulShutdown();

View File

@@ -88,6 +88,21 @@ namespace BlackMisc
return true; return true;
} }
CSimulatorInfo IMultiSimulatorModelCaches::simulatorsWithInitializedCache() const
{
static const QDateTime outdated = QDateTime::currentDateTimeUtc().addDays(-365 * 5);
CSimulatorInfo withInitializedCache;
for (const CSimulatorInfo &simInfo : CSimulatorInfo::allSimulators().asSingleSimulatorSet())
{
const QDateTime ts = this->getCacheTimestamp(simInfo);
if (ts.isValid() && ts > outdated)
{
withInitializedCache.add(simInfo);
}
}
return withInitializedCache;
}
CModelCaches::CModelCaches(bool synchronizeCache, QObject *parent) : IMultiSimulatorModelCaches(parent) CModelCaches::CModelCaches(bool synchronizeCache, QObject *parent) : IMultiSimulatorModelCaches(parent)
{ {
this->m_currentSimulator.synchronize(); this->m_currentSimulator.synchronize();

View File

@@ -166,6 +166,10 @@ namespace BlackMisc
//! \threadsafe //! \threadsafe
virtual QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const = 0; virtual QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const = 0;
//! Initilaized caches for which simulator
//! \threadsafe
BlackMisc::Simulation::CSimulatorInfo simulatorsWithInitializedCache() const;
//! Timestamp //! Timestamp
QDateTime getSynchronizedTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator); QDateTime getSynchronizedTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator);
@@ -194,7 +198,7 @@ namespace BlackMisc
//! \threadsafe //! \threadsafe
virtual BlackMisc::Simulation::CSimulatorInfo getCurrentSimulator() const = 0; virtual BlackMisc::Simulation::CSimulatorInfo getCurrentSimulator() const = 0;
//!Selected simulator //! Selected simulator
virtual BlackMisc::CStatusMessage setCurrentSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0; virtual BlackMisc::CStatusMessage setCurrentSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0;
//! \copydoc IModelsPerSimulatorSetable::setModels //! \copydoc IModelsPerSimulatorSetable::setModels