mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
refs #743, utility functions and formatting / typos
* simulator info for FS family / as set * fixed synchronized typo * info string for caches * getter for cached models from the loaders * get all FS family models (FSX/P3D/FS9) from list
This commit is contained in:
committed by
Mathew Sutcliffe
parent
7446ffcb80
commit
11e32a065e
@@ -26,15 +26,32 @@ namespace BlackMisc
|
||||
this->setCachedModels(models, simulator);
|
||||
}
|
||||
|
||||
void IMultiSimulatorModelCaches::emitCacheChanged(const CSimulatorInfo &simulator)
|
||||
QString IMultiSimulatorModelCaches::getInfoString() const
|
||||
{
|
||||
emit cacheChanged(simulator);
|
||||
static const QString is("FSX: %1 P3D: %2 FS9: %3 XP: %4");
|
||||
return is.arg(this->getCachedModelsCount(CSimulatorInfo::FSX)).arg(this->getCachedModelsCount(CSimulatorInfo::P3D)).arg(this->getCachedModelsCount(CSimulatorInfo::FS9)).arg(this->getCachedModelsCount(CSimulatorInfo::XPLANE));
|
||||
}
|
||||
|
||||
CAircraftModelList IMultiSimulatorModelCaches::getSyncronizedCachedModels(const CSimulatorInfo &simulator)
|
||||
QString IMultiSimulatorModelCaches::getInfoStringFsFamily() const
|
||||
{
|
||||
static const QString is("FSX: %1 P3D: %2 FS9: %3");
|
||||
return is.arg(this->getCachedModelsCount(CSimulatorInfo::FSX)).arg(this->getCachedModelsCount(CSimulatorInfo::P3D)).arg(this->getCachedModelsCount(CSimulatorInfo::FS9));
|
||||
}
|
||||
|
||||
void IMultiSimulatorModelCaches::emitCacheChanged(const CSimulatorInfo &simulator)
|
||||
{
|
||||
emit this->cacheChanged(simulator);
|
||||
}
|
||||
|
||||
int IMultiSimulatorModelCaches::getCachedModelsCount(const CSimulatorInfo &simulator) const
|
||||
{
|
||||
return this->getCachedModels(simulator).size();
|
||||
}
|
||||
|
||||
CAircraftModelList IMultiSimulatorModelCaches::getSynchronizedCachedModels(const CSimulatorInfo &simulator)
|
||||
{
|
||||
BLACK_VERIFY_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||
this->syncronizeCache(simulator);
|
||||
this->synchronizeCache(simulator);
|
||||
return this->getCachedModels(simulator);
|
||||
}
|
||||
|
||||
@@ -46,19 +63,19 @@ namespace BlackMisc
|
||||
return this->getCachedModels(sim);
|
||||
}
|
||||
|
||||
QDateTime IMultiSimulatorModelCaches::getSyncronizedTimestamp(const CSimulatorInfo &simulator)
|
||||
QDateTime IMultiSimulatorModelCaches::getSynchronizedTimestamp(const CSimulatorInfo &simulator)
|
||||
{
|
||||
BLACK_VERIFY_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||
this->syncronizeCache(simulator);
|
||||
this->synchronizeCache(simulator);
|
||||
return this->getCacheTimestamp(simulator);
|
||||
}
|
||||
|
||||
bool IMultiSimulatorModelCaches::syncronizeCurrentCache()
|
||||
bool IMultiSimulatorModelCaches::synchronizeCurrentCache()
|
||||
{
|
||||
const CSimulatorInfo sim(this->getCurrentSimulator());
|
||||
BLACK_VERIFY_X(sim.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||
if (!sim.isSingleSimulator()) { return false; }
|
||||
this->syncronizeCache(sim);
|
||||
this->synchronizeCache(sim);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -72,7 +89,7 @@ namespace BlackMisc
|
||||
this->m_currentSimulator.set(sim);
|
||||
CLogMessage(this).warning("Invalid simulator, reseting");
|
||||
}
|
||||
this->syncronizeCacheImpl(sim);
|
||||
this->synchronizeCacheImpl(sim);
|
||||
const QString simStr(sim.toQString(true));
|
||||
CLogMessage(this).info("Initialized model caches to %1") << simStr;
|
||||
}
|
||||
@@ -130,9 +147,9 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
void CModelCaches::syncronizeCache(const CSimulatorInfo &simulator)
|
||||
void CModelCaches::synchronizeCache(const CSimulatorInfo &simulator)
|
||||
{
|
||||
this->syncronizeCacheImpl(simulator);
|
||||
this->synchronizeCacheImpl(simulator);
|
||||
}
|
||||
|
||||
CStatusMessage CModelCaches::setCurrentSimulator(const CSimulatorInfo &simulator)
|
||||
@@ -141,11 +158,11 @@ namespace BlackMisc
|
||||
const CSimulatorInfo s = this->m_currentSimulator.get();
|
||||
if (s == simulator) { return sameSimMsg; }
|
||||
const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator);
|
||||
this->syncronizeCache(simulator);
|
||||
this->synchronizeCache(simulator);
|
||||
return m;
|
||||
}
|
||||
|
||||
void CModelCaches::syncronizeCacheImpl(const CSimulatorInfo &simulator)
|
||||
void CModelCaches::synchronizeCacheImpl(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||
switch (simulator.getSimulator())
|
||||
@@ -170,7 +187,7 @@ namespace BlackMisc
|
||||
this->m_currentSimulator.set(sim);
|
||||
CLogMessage(this).warning("Invalid simulator, reseting");
|
||||
}
|
||||
this->syncronizeCacheImpl(sim);
|
||||
this->synchronizeCacheImpl(sim);
|
||||
const QString simStr(sim.toQString(true));
|
||||
CLogMessage(this).info("Initialized model caches to %1") << simStr;
|
||||
}
|
||||
@@ -230,9 +247,9 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
void CModelSetCaches::syncronizeCache(const CSimulatorInfo &simulator)
|
||||
void CModelSetCaches::synchronizeCache(const CSimulatorInfo &simulator)
|
||||
{
|
||||
this->syncronizeCacheImpl(simulator);
|
||||
this->synchronizeCacheImpl(simulator);
|
||||
}
|
||||
|
||||
CStatusMessage CModelSetCaches::setCurrentSimulator(const CSimulatorInfo &simulator)
|
||||
@@ -241,11 +258,11 @@ namespace BlackMisc
|
||||
const CSimulatorInfo s = this->m_currentSimulator.get();
|
||||
if (s == simulator) { return sameSimMsg; }
|
||||
const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator);
|
||||
this->syncronizeCache(simulator);
|
||||
this->synchronizeCache(simulator);
|
||||
return m;
|
||||
}
|
||||
|
||||
void CModelSetCaches::syncronizeCacheImpl(const CSimulatorInfo &simulator)
|
||||
void CModelSetCaches::synchronizeCacheImpl(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||
switch (simulator.getSimulator())
|
||||
|
||||
@@ -151,13 +151,16 @@ namespace BlackMisc
|
||||
IMultiSimulatorModelCaches(QObject *parent = nullptr) : QObject(parent)
|
||||
{ }
|
||||
|
||||
//! Models
|
||||
//! Models for simulator
|
||||
//! \threadsafe
|
||||
virtual CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const = 0;
|
||||
|
||||
//! Count of models for simulator
|
||||
int getCachedModelsCount(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
|
||||
|
||||
//! Models
|
||||
//! \todo is that threadsafe?
|
||||
CAircraftModelList getSyncronizedCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
CAircraftModelList getSynchronizedCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Models
|
||||
//! \threadsafe
|
||||
@@ -169,7 +172,7 @@ namespace BlackMisc
|
||||
|
||||
//! Timestamp
|
||||
//! \todo is that threadsafe?
|
||||
QDateTime getSyncronizedTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
QDateTime getSynchronizedTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Last selection`s timestamp
|
||||
//! \threadsafe
|
||||
@@ -178,12 +181,12 @@ namespace BlackMisc
|
||||
//! Set cache
|
||||
virtual BlackMisc::CStatusMessage setCachedModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0;
|
||||
|
||||
//! Syncronize
|
||||
//! Synchronize
|
||||
//! \todo is that threadsafe?
|
||||
virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0;
|
||||
virtual void synchronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0;
|
||||
|
||||
//! Last cache
|
||||
bool syncronizeCurrentCache();
|
||||
bool synchronizeCurrentCache();
|
||||
|
||||
//! Selected simulator
|
||||
//! \threadsafe
|
||||
@@ -195,6 +198,12 @@ namespace BlackMisc
|
||||
//! \copydoc IModelsPerSimulatorSetable::setModels
|
||||
virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||
|
||||
//! Info string about models in cache
|
||||
QString getInfoString() const;
|
||||
|
||||
//! Info string without XPlane (FSX,P3D, FS9)
|
||||
QString getInfoStringFsFamily() const;
|
||||
|
||||
signals:
|
||||
//! Cache has been changed
|
||||
void cacheChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
@@ -228,7 +237,7 @@ namespace BlackMisc
|
||||
virtual CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override;
|
||||
virtual BlackMisc::CStatusMessage setCachedModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||
virtual QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override;
|
||||
virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||
virtual void synchronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||
virtual BlackMisc::Simulation::CSimulatorInfo getCurrentSimulator() const override { return this->m_currentSimulator.get(); }
|
||||
virtual BlackMisc::CStatusMessage setCurrentSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||
//! @}
|
||||
@@ -241,7 +250,7 @@ namespace BlackMisc
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TModelCacheLastSelection> m_currentSimulator { this }; //!< current simulator
|
||||
|
||||
//! Non virtaul version (used in ctor)
|
||||
void syncronizeCacheImpl(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
void synchronizeCacheImpl(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
};
|
||||
|
||||
//! Bundle of caches for model sets of all simulators
|
||||
@@ -259,7 +268,7 @@ namespace BlackMisc
|
||||
virtual CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override;
|
||||
virtual BlackMisc::CStatusMessage setCachedModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||
virtual QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override;
|
||||
virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||
virtual void synchronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||
virtual BlackMisc::Simulation::CSimulatorInfo getCurrentSimulator() const override { return this->m_currentSimulator.get(); }
|
||||
virtual BlackMisc::CStatusMessage setCurrentSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||
//! @}
|
||||
@@ -272,7 +281,7 @@ namespace BlackMisc
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TModelSetLastSelection> m_currentSimulator { this }; //!< current simulator
|
||||
|
||||
//! Non virtaul version (used in ctor)
|
||||
void syncronizeCacheImpl(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
void synchronizeCacheImpl(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user