mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-30 05:51:23 +08:00
refs #649, add.function getSyncronizedValues
Normally getValue should transparently sync. But this force me to make the function non-const.
This commit is contained in:
@@ -58,7 +58,7 @@ namespace BlackMisc
|
|||||||
if (models.isEmpty()) { return CStatusMessage(this, CStatusMessage::SeverityInfo, "No data"); }
|
if (models.isEmpty()) { return CStatusMessage(this, CStatusMessage::SeverityInfo, "No data"); }
|
||||||
const CSimulatorInfo sim = simulator.isSingleSimulator() ? simulator : this->getSimulator();
|
const CSimulatorInfo sim = simulator.isSingleSimulator() ? simulator : this->getSimulator();
|
||||||
if (!sim.isSingleSimulator()) { return CStatusMessage(this, CStatusMessage::SeverityError, "Invalid simuataor"); }
|
if (!sim.isSingleSimulator()) { return CStatusMessage(this, CStatusMessage::SeverityError, "Invalid simuataor"); }
|
||||||
CAircraftModelList allModels(this->m_caches.getCachedModels(sim));
|
CAircraftModelList allModels(this->m_caches.getSyncronizedCachedModels(sim));
|
||||||
int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive);
|
int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive);
|
||||||
if (c > 0)
|
if (c > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,8 +42,9 @@ namespace BlackMisc
|
|||||||
if (models.isEmpty()) { return CStatusMessage(this, CStatusMessage::SeverityInfo, "No data"); }
|
if (models.isEmpty()) { return CStatusMessage(this, CStatusMessage::SeverityInfo, "No data"); }
|
||||||
const CSimulatorInfo sim = simulator.isSingleSimulator() ? simulator : this->m_caches.getCurrentSimulator();
|
const CSimulatorInfo sim = simulator.isSingleSimulator() ? simulator : this->m_caches.getCurrentSimulator();
|
||||||
if (!sim.isSingleSimulator()) { return CStatusMessage(this, CStatusMessage::SeverityError, "Invalid simuataor"); }
|
if (!sim.isSingleSimulator()) { return CStatusMessage(this, CStatusMessage::SeverityError, "Invalid simuataor"); }
|
||||||
CAircraftModelList allModels(this->m_caches.getCachedModels(sim));
|
this->m_caches.syncronizeCache(sim);
|
||||||
int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive);
|
CAircraftModelList allModels(this->m_caches.getSyncronizedCachedModels(sim));
|
||||||
|
const int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive);
|
||||||
if (c > 0)
|
if (c > 0)
|
||||||
{
|
{
|
||||||
return this->setCachedModels(models, sim);
|
return this->setCachedModels(models, sim);
|
||||||
@@ -67,10 +68,10 @@ namespace BlackMisc
|
|||||||
return this->m_caches.getCurrentCachedModels();
|
return this->m_caches.getCurrentCachedModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModelList CAircraftModelSetLoader::getAircraftModels(const CSimulatorInfo &simulator) const
|
CAircraftModelList CAircraftModelSetLoader::getAircraftModels(const CSimulatorInfo &simulator)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||||
return this->m_caches.getCachedModels(simulator);
|
return this->m_caches.getSyncronizedCachedModels(simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CAircraftModelSetLoader::getAircraftModelsCount() const
|
int CAircraftModelSetLoader::getAircraftModelsCount() const
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! The loaded models for given simulator
|
//! The loaded models for given simulator
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
BlackMisc::Simulation::CAircraftModelList getAircraftModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
|
//! \remark non-const because it syncronizes cache
|
||||||
|
BlackMisc::Simulation::CAircraftModelList getAircraftModels(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
//! Count of loaded models
|
//! Count of loaded models
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
|
|||||||
@@ -26,6 +26,13 @@ namespace BlackMisc
|
|||||||
this->setCachedModels(models, simulator);
|
this->setCachedModels(models, simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAircraftModelList IMultiSimulatorModelCaches::getSyncronizedCachedModels(const CSimulatorInfo &simulator)
|
||||||
|
{
|
||||||
|
BLACK_VERIFY_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||||
|
this->syncronizeCache(simulator);
|
||||||
|
return this->getCachedModels(simulator);
|
||||||
|
}
|
||||||
|
|
||||||
CAircraftModelList IMultiSimulatorModelCaches::getCurrentCachedModels() const
|
CAircraftModelList IMultiSimulatorModelCaches::getCurrentCachedModels() const
|
||||||
{
|
{
|
||||||
const CSimulatorInfo sim(this->getCurrentSimulator());
|
const CSimulatorInfo sim(this->getCurrentSimulator());
|
||||||
@@ -34,6 +41,13 @@ namespace BlackMisc
|
|||||||
return this->getCachedModels(sim);
|
return this->getCachedModels(sim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDateTime IMultiSimulatorModelCaches::getSyncronizedTimestamp(const CSimulatorInfo &simulator)
|
||||||
|
{
|
||||||
|
BLACK_VERIFY_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||||
|
this->syncronizeCache(simulator);
|
||||||
|
return this->getCacheTimestamp(simulator);
|
||||||
|
}
|
||||||
|
|
||||||
bool IMultiSimulatorModelCaches::syncronizeCurrentCache()
|
bool IMultiSimulatorModelCaches::syncronizeCurrentCache()
|
||||||
{
|
{
|
||||||
const CSimulatorInfo sim(this->getCurrentSimulator());
|
const CSimulatorInfo sim(this->getCurrentSimulator());
|
||||||
|
|||||||
@@ -162,6 +162,10 @@ namespace BlackMisc
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
virtual CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const = 0;
|
virtual CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const = 0;
|
||||||
|
|
||||||
|
//! Models
|
||||||
|
//! \todo is that threadsafe?
|
||||||
|
CAircraftModelList getSyncronizedCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
//! Models
|
//! Models
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
CAircraftModelList getCurrentCachedModels() const;
|
CAircraftModelList getCurrentCachedModels() const;
|
||||||
@@ -170,13 +174,19 @@ namespace BlackMisc
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
virtual QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const = 0;
|
virtual QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const = 0;
|
||||||
|
|
||||||
|
//! Timestamp
|
||||||
|
//! \todo is that threadsafe?
|
||||||
|
QDateTime getSyncronizedTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
//! Last selection`s timestamp
|
//! Last selection`s timestamp
|
||||||
|
//! \threadsafe
|
||||||
QDateTime getCurrentCacheTimestamp() const;
|
QDateTime getCurrentCacheTimestamp() const;
|
||||||
|
|
||||||
//! Set cache
|
//! Set cache
|
||||||
virtual BlackMisc::CStatusMessage setCachedModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0;
|
virtual BlackMisc::CStatusMessage setCachedModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0;
|
||||||
|
|
||||||
//! Syncronize
|
//! Syncronize
|
||||||
|
//! \todo is that threadsafe?
|
||||||
virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0;
|
virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0;
|
||||||
|
|
||||||
//! Last cache
|
//! Last cache
|
||||||
|
|||||||
Reference in New Issue
Block a user