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
@@ -35,7 +35,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
const CLogCategoryList &CAircraftMatcher::getLogCategories()
|
const CLogCategoryList &CAircraftMatcher::getLogCategories()
|
||||||
{
|
{
|
||||||
static const BlackMisc::CLogCategoryList cats { BlackMisc::CLogCategory::matching() };
|
static const BlackMisc::CLogCategoryList cats { CLogCategory::matching() };
|
||||||
return cats;
|
return cats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,7 +545,7 @@ namespace BlackCore
|
|||||||
return inList;
|
return inList;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CAircraftModelList outList(inList.findByManunfacturer(m));
|
const CAircraftModelList outList(inList.findByManufacturer(m));
|
||||||
if (outList.isEmpty())
|
if (outList.isEmpty())
|
||||||
{
|
{
|
||||||
if (log) { CMatchingUtils::addLogDetailsToList(log , remoteAircraft, info + " Not found " + m + ", cannot reduce", getLogCategories()); }
|
if (log) { CMatchingUtils::addLogDetailsToList(log , remoteAircraft, info + " Not found " + m + ", cannot reduce", getLogCategories()); }
|
||||||
|
|||||||
@@ -417,6 +417,11 @@ namespace BlackMisc
|
|||||||
return (static_cast<int>(simulator.getSimulator()) & static_cast<int>(this->getSimulator().getSimulator())) > 0;
|
return (static_cast<int>(simulator.getSimulator()) & static_cast<int>(this->getSimulator().getSimulator())) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAircraftModel::matchesSimulatorFlag(CSimulatorInfo::Simulator simulator) const
|
||||||
|
{
|
||||||
|
return (static_cast<int>(simulator) & static_cast<int>(this->getSimulator().getSimulator())) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
CPixmap CAircraftModel::loadIcon(CStatusMessage &success) const
|
CPixmap CAircraftModel::loadIcon(CStatusMessage &success) const
|
||||||
{
|
{
|
||||||
static const CStatusMessage noIcon(this, CStatusMessage::SeverityInfo, "no icon");
|
static const CStatusMessage noIcon(this, CStatusMessage::SeverityInfo, "no icon");
|
||||||
|
|||||||
@@ -276,6 +276,9 @@ namespace BlackMisc
|
|||||||
//! Matches given simulator?
|
//! Matches given simulator?
|
||||||
bool matchesSimulator(const CSimulatorInfo &simulator) const;
|
bool matchesSimulator(const CSimulatorInfo &simulator) const;
|
||||||
|
|
||||||
|
//! Matches given simulator?
|
||||||
|
bool matchesSimulatorFlag(CSimulatorInfo::Simulator simulator) const;
|
||||||
|
|
||||||
//! File name (corresponding data for simulator, only available if representing simulator model
|
//! File name (corresponding data for simulator, only available if representing simulator model
|
||||||
QString getFileName() const { return m_fileName; }
|
QString getFileName() const { return m_fileName; }
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ namespace BlackMisc
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModelList CAircraftModelList::findByManunfacturer(const QString &manufacturer) const
|
CAircraftModelList CAircraftModelList::findByManufacturer(const QString &manufacturer) const
|
||||||
{
|
{
|
||||||
if (manufacturer.isEmpty()) { return CAircraftModelList(); }
|
if (manufacturer.isEmpty()) { return CAircraftModelList(); }
|
||||||
const QString m(manufacturer.toUpper().trimmed());
|
const QString m(manufacturer.toUpper().trimmed());
|
||||||
@@ -201,6 +201,14 @@ namespace BlackMisc
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAircraftModelList CAircraftModelList::getAllFsFamilyModels() const
|
||||||
|
{
|
||||||
|
return this->findBy([ = ](const CAircraftModel & model)
|
||||||
|
{
|
||||||
|
return model.getSimulator().isMicrosoftOrPrepare3DSimulator();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
QString CAircraftModelList::findModelIconPathByModelString(const QString &modelString) const
|
QString CAircraftModelList::findModelIconPathByModelString(const QString &modelString) const
|
||||||
{
|
{
|
||||||
if (modelString.isEmpty()) { return ""; }
|
if (modelString.isEmpty()) { return ""; }
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ namespace BlackMisc
|
|||||||
CAircraftModelList findWithKnownAircraftDesignator() const;
|
CAircraftModelList findWithKnownAircraftDesignator() const;
|
||||||
|
|
||||||
//! Find by manufacturer
|
//! Find by manufacturer
|
||||||
CAircraftModelList findByManunfacturer(const QString &manufacturer) const;
|
CAircraftModelList findByManufacturer(const QString &manufacturer) const;
|
||||||
|
|
||||||
//! Models with aircraft family
|
//! Models with aircraft family
|
||||||
CAircraftModelList findByFamily(const QString &family) const;
|
CAircraftModelList findByFamily(const QString &family) const;
|
||||||
@@ -120,6 +120,9 @@ namespace BlackMisc
|
|||||||
//! Find by military flag
|
//! Find by military flag
|
||||||
CAircraftModelList findByMilitaryFlag(bool military) const;
|
CAircraftModelList findByMilitaryFlag(bool military) const;
|
||||||
|
|
||||||
|
//! All models of the FS (FSX, P3D, FS9) family
|
||||||
|
CAircraftModelList getAllFsFamilyModels() const;
|
||||||
|
|
||||||
//! Model icon path
|
//! Model icon path
|
||||||
QString findModelIconPathByModelString(const QString &modelString) const;
|
QString findModelIconPathByModelString(const QString &modelString) const;
|
||||||
|
|
||||||
@@ -174,7 +177,7 @@ namespace BlackMisc
|
|||||||
//! Simulator counts
|
//! Simulator counts
|
||||||
CCountPerSimulator countPerSimulator() const;
|
CCountPerSimulator countPerSimulator() const;
|
||||||
|
|
||||||
//! Which simulator(s) have the most entries
|
//! Which simulator(s) have the most entries?
|
||||||
CSimulatorInfo simulatorsWithMaxEntries() const;
|
CSimulatorInfo simulatorsWithMaxEntries() const;
|
||||||
|
|
||||||
//! Update distributor, all models in list are set to given distributor
|
//! Update distributor, all models in list are set to given distributor
|
||||||
|
|||||||
@@ -48,7 +48,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(); // support default values
|
const CSimulatorInfo sim = simulator.isSingleSimulator() ? simulator : this->getSimulator(); // support default values
|
||||||
CAircraftModelList allModels(this->m_caches.getSyncronizedCachedModels(sim));
|
CAircraftModelList allModels(this->m_caches.getSynchronizedCachedModels(sim));
|
||||||
int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive);
|
int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive);
|
||||||
if (c > 0)
|
if (c > 0)
|
||||||
{
|
{
|
||||||
@@ -95,6 +95,11 @@ namespace BlackMisc
|
|||||||
return this->m_caches.getCurrentCachedModels();
|
return this->m_caches.getCurrentCachedModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAircraftModelList IAircraftModelLoader::getCachedAircraftModels(const CSimulatorInfo &simulator) const
|
||||||
|
{
|
||||||
|
return this->m_caches.getCachedModels(simulator);
|
||||||
|
}
|
||||||
|
|
||||||
QDateTime IAircraftModelLoader::getCacheTimestamp() const
|
QDateTime IAircraftModelLoader::getCacheTimestamp() const
|
||||||
{
|
{
|
||||||
return this->m_caches.getCurrentCacheTimestamp();
|
return this->m_caches.getCurrentCacheTimestamp();
|
||||||
@@ -164,6 +169,16 @@ namespace BlackMisc
|
|||||||
this->cancelLoading();
|
this->cancelLoading();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString IAircraftModelLoader::getInfoString() const
|
||||||
|
{
|
||||||
|
return this->m_caches.getInfoString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IAircraftModelLoader::getInfoStringFsFamily() const
|
||||||
|
{
|
||||||
|
return this->m_caches.getInfoStringFsFamily();
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<IAircraftModelLoader> IAircraftModelLoader::createModelLoader(const CSimulatorInfo &simulator)
|
std::unique_ptr<IAircraftModelLoader> IAircraftModelLoader::createModelLoader(const CSimulatorInfo &simulator)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Single simulator");
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Single simulator");
|
||||||
|
|||||||
@@ -80,10 +80,14 @@ namespace BlackMisc
|
|||||||
//! Loading finished?
|
//! Loading finished?
|
||||||
virtual bool isLoadingFinished() const = 0;
|
virtual bool isLoadingFinished() const = 0;
|
||||||
|
|
||||||
//! The loaded models
|
//! Get the loaded models
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
BlackMisc::Simulation::CAircraftModelList getAircraftModels() const;
|
BlackMisc::Simulation::CAircraftModelList getAircraftModels() const;
|
||||||
|
|
||||||
|
//! Get the cached models
|
||||||
|
//! \threadsafe
|
||||||
|
BlackMisc::Simulation::CAircraftModelList getCachedAircraftModels(const CSimulatorInfo &simulator) const;
|
||||||
|
|
||||||
//! Count of loaded models
|
//! Count of loaded models
|
||||||
int getAircraftModelsCount() const { return getAircraftModels().size(); }
|
int getAircraftModelsCount() const { return getAircraftModels().size(); }
|
||||||
|
|
||||||
@@ -114,6 +118,12 @@ namespace BlackMisc
|
|||||||
//! Shutdown
|
//! Shutdown
|
||||||
void gracefulShutdown();
|
void gracefulShutdown();
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoString
|
||||||
|
QString getInfoString() const;
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoStringFsFamily
|
||||||
|
QString getInfoStringFsFamily() const;
|
||||||
|
|
||||||
//! \name Implementations of the model interfaces (allows to set models modified in utility functions)
|
//! \name Implementations of the model interfaces (allows to set models modified in utility functions)
|
||||||
//! @{
|
//! @{
|
||||||
virtual void setModels(const CAircraftModelList &models) override { this->setCachedModels(models, this->getSimulator()); }
|
virtual void setModels(const CAircraftModelList &models) override { this->setCachedModels(models, this->getSimulator()); }
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ 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"); }
|
||||||
this->m_caches.syncronizeCache(sim);
|
this->m_caches.synchronizeCache(sim);
|
||||||
CAircraftModelList allModels(this->m_caches.getSyncronizedCachedModels(sim));
|
CAircraftModelList allModels(this->m_caches.getSynchronizedCachedModels(sim));
|
||||||
const int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive);
|
const int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive);
|
||||||
if (c > 0)
|
if (c > 0)
|
||||||
{
|
{
|
||||||
@@ -60,7 +60,7 @@ namespace BlackMisc
|
|||||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Only one simulator per loader");
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Only one simulator per loader");
|
||||||
if (this->getSimulator() == simulator) { return; }
|
if (this->getSimulator() == simulator) { return; }
|
||||||
this->m_caches.setCurrentSimulator(simulator);
|
this->m_caches.setCurrentSimulator(simulator);
|
||||||
this->m_caches.syncronizeCurrentCache();
|
this->m_caches.synchronizeCurrentCache();
|
||||||
emit simulatorChanged(simulator);
|
emit simulatorChanged(simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ namespace BlackMisc
|
|||||||
CAircraftModelList CAircraftModelSetLoader::getAircraftModels(const CSimulatorInfo &simulator)
|
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.getSyncronizedCachedModels(simulator);
|
return this->m_caches.getSynchronizedCachedModels(simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CAircraftModelSetLoader::getAircraftModelsCount() const
|
int CAircraftModelSetLoader::getAircraftModelsCount() const
|
||||||
@@ -86,14 +86,19 @@ namespace BlackMisc
|
|||||||
return this->getAircraftModels().findFirstByModelStringOrDefault(modelString);
|
return this->getAircraftModels().findFirstByModelStringOrDefault(modelString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAircraftModelList CAircraftModelSetLoader::getCachedModels(const CSimulatorInfo &simulator) const
|
||||||
|
{
|
||||||
|
return this->m_caches.getCachedModels(simulator);
|
||||||
|
}
|
||||||
|
|
||||||
QDateTime CAircraftModelSetLoader::getCacheTimestamp() const
|
QDateTime CAircraftModelSetLoader::getCacheTimestamp() const
|
||||||
{
|
{
|
||||||
return this->m_caches.getCurrentCacheTimestamp();
|
return this->m_caches.getCurrentCacheTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAircraftModelSetLoader::syncronizeCache()
|
bool CAircraftModelSetLoader::synchronizeCache()
|
||||||
{
|
{
|
||||||
return this->m_caches.syncronizeCurrentCache();
|
return this->m_caches.synchronizeCurrentCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAircraftModelSetLoader::hasCachedData() const
|
bool CAircraftModelSetLoader::hasCachedData() const
|
||||||
@@ -118,12 +123,22 @@ namespace BlackMisc
|
|||||||
|
|
||||||
bool CAircraftModelSetLoader::supportsSimulator(const CSimulatorInfo &info)
|
bool CAircraftModelSetLoader::supportsSimulator(const CSimulatorInfo &info)
|
||||||
{
|
{
|
||||||
return getSimulator().matchesAny(info);
|
return this->getSimulator().matchesAny(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAircraftModelSetLoader::gracefulShutdown()
|
void CAircraftModelSetLoader::gracefulShutdown()
|
||||||
{
|
{
|
||||||
// void
|
// void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CAircraftModelSetLoader::getInfoString() const
|
||||||
|
{
|
||||||
|
return this->m_caches.getInfoString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CAircraftModelSetLoader::getInfoStringFsFamily() const
|
||||||
|
{
|
||||||
|
return this->m_caches.getInfoStringFsFamily();
|
||||||
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ namespace BlackMisc
|
|||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~CAircraftModelSetLoader();
|
virtual ~CAircraftModelSetLoader();
|
||||||
|
|
||||||
//! Make sure cache is syncronized
|
//! Make sure cache is synchronized
|
||||||
bool syncronizeCache();
|
bool synchronizeCache();
|
||||||
|
|
||||||
//! The loaded models
|
//! The loaded models
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
@@ -60,7 +60,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! The loaded models for given simulator
|
//! The loaded models for given simulator
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
//! \remark non-const because it syncronizes cache
|
//! \remark non-const because it synchronizes cache
|
||||||
BlackMisc::Simulation::CAircraftModelList getAircraftModels(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
BlackMisc::Simulation::CAircraftModelList getAircraftModels(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
//! Count of loaded models
|
//! Count of loaded models
|
||||||
@@ -71,6 +71,10 @@ namespace BlackMisc
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
BlackMisc::Simulation::CAircraftModel getModelForModelString(const QString &modelString) const;
|
BlackMisc::Simulation::CAircraftModel getModelForModelString(const QString &modelString) const;
|
||||||
|
|
||||||
|
//! Models from cache
|
||||||
|
//! \threadsafe
|
||||||
|
BlackMisc::Simulation::CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
|
||||||
|
|
||||||
//! Which simulator is supported by that very loader
|
//! Which simulator is supported by that very loader
|
||||||
CSimulatorInfo getSimulator() const;
|
CSimulatorInfo getSimulator() const;
|
||||||
|
|
||||||
@@ -83,6 +87,12 @@ namespace BlackMisc
|
|||||||
//! Shutdown
|
//! Shutdown
|
||||||
void gracefulShutdown();
|
void gracefulShutdown();
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoString
|
||||||
|
QString getInfoString() const;
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoStringFsFamily
|
||||||
|
QString getInfoStringFsFamily() const;
|
||||||
|
|
||||||
//! \name Implementations of the models interfaces
|
//! \name Implementations of the models interfaces
|
||||||
//! @{
|
//! @{
|
||||||
virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models) override { this->setCachedModels(models, this->getSimulator()); }
|
virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models) override { this->setCachedModels(models, this->getSimulator()); }
|
||||||
|
|||||||
@@ -26,15 +26,32 @@ namespace BlackMisc
|
|||||||
this->setCachedModels(models, simulator);
|
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");
|
BLACK_VERIFY_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||||
this->syncronizeCache(simulator);
|
this->synchronizeCache(simulator);
|
||||||
return this->getCachedModels(simulator);
|
return this->getCachedModels(simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,19 +63,19 @@ namespace BlackMisc
|
|||||||
return this->getCachedModels(sim);
|
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");
|
BLACK_VERIFY_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||||
this->syncronizeCache(simulator);
|
this->synchronizeCache(simulator);
|
||||||
return this->getCacheTimestamp(simulator);
|
return this->getCacheTimestamp(simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IMultiSimulatorModelCaches::syncronizeCurrentCache()
|
bool IMultiSimulatorModelCaches::synchronizeCurrentCache()
|
||||||
{
|
{
|
||||||
const CSimulatorInfo sim(this->getCurrentSimulator());
|
const CSimulatorInfo sim(this->getCurrentSimulator());
|
||||||
BLACK_VERIFY_X(sim.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
BLACK_VERIFY_X(sim.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||||
if (!sim.isSingleSimulator()) { return false; }
|
if (!sim.isSingleSimulator()) { return false; }
|
||||||
this->syncronizeCache(sim);
|
this->synchronizeCache(sim);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +89,7 @@ namespace BlackMisc
|
|||||||
this->m_currentSimulator.set(sim);
|
this->m_currentSimulator.set(sim);
|
||||||
CLogMessage(this).warning("Invalid simulator, reseting");
|
CLogMessage(this).warning("Invalid simulator, reseting");
|
||||||
}
|
}
|
||||||
this->syncronizeCacheImpl(sim);
|
this->synchronizeCacheImpl(sim);
|
||||||
const QString simStr(sim.toQString(true));
|
const QString simStr(sim.toQString(true));
|
||||||
CLogMessage(this).info("Initialized model caches to %1") << simStr;
|
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)
|
CStatusMessage CModelCaches::setCurrentSimulator(const CSimulatorInfo &simulator)
|
||||||
@@ -141,11 +158,11 @@ namespace BlackMisc
|
|||||||
const CSimulatorInfo s = this->m_currentSimulator.get();
|
const CSimulatorInfo s = this->m_currentSimulator.get();
|
||||||
if (s == simulator) { return sameSimMsg; }
|
if (s == simulator) { return sameSimMsg; }
|
||||||
const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator);
|
const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator);
|
||||||
this->syncronizeCache(simulator);
|
this->synchronizeCache(simulator);
|
||||||
return m;
|
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");
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
switch (simulator.getSimulator())
|
switch (simulator.getSimulator())
|
||||||
@@ -170,7 +187,7 @@ namespace BlackMisc
|
|||||||
this->m_currentSimulator.set(sim);
|
this->m_currentSimulator.set(sim);
|
||||||
CLogMessage(this).warning("Invalid simulator, reseting");
|
CLogMessage(this).warning("Invalid simulator, reseting");
|
||||||
}
|
}
|
||||||
this->syncronizeCacheImpl(sim);
|
this->synchronizeCacheImpl(sim);
|
||||||
const QString simStr(sim.toQString(true));
|
const QString simStr(sim.toQString(true));
|
||||||
CLogMessage(this).info("Initialized model caches to %1") << simStr;
|
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)
|
CStatusMessage CModelSetCaches::setCurrentSimulator(const CSimulatorInfo &simulator)
|
||||||
@@ -241,11 +258,11 @@ namespace BlackMisc
|
|||||||
const CSimulatorInfo s = this->m_currentSimulator.get();
|
const CSimulatorInfo s = this->m_currentSimulator.get();
|
||||||
if (s == simulator) { return sameSimMsg; }
|
if (s == simulator) { return sameSimMsg; }
|
||||||
const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator);
|
const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator);
|
||||||
this->syncronizeCache(simulator);
|
this->synchronizeCache(simulator);
|
||||||
return m;
|
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");
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
switch (simulator.getSimulator())
|
switch (simulator.getSimulator())
|
||||||
|
|||||||
@@ -151,13 +151,16 @@ namespace BlackMisc
|
|||||||
IMultiSimulatorModelCaches(QObject *parent = nullptr) : QObject(parent)
|
IMultiSimulatorModelCaches(QObject *parent = nullptr) : QObject(parent)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
//! Models
|
//! Models for simulator
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
virtual CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const = 0;
|
virtual CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const = 0;
|
||||||
|
|
||||||
|
//! Count of models for simulator
|
||||||
|
int getCachedModelsCount(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
|
||||||
|
|
||||||
//! Models
|
//! Models
|
||||||
//! \todo is that threadsafe?
|
//! \todo is that threadsafe?
|
||||||
CAircraftModelList getSyncronizedCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
CAircraftModelList getSynchronizedCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
//! Models
|
//! Models
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
@@ -169,7 +172,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! Timestamp
|
//! Timestamp
|
||||||
//! \todo is that threadsafe?
|
//! \todo is that threadsafe?
|
||||||
QDateTime getSyncronizedTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
QDateTime getSynchronizedTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
//! Last selection`s timestamp
|
//! Last selection`s timestamp
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
@@ -178,12 +181,12 @@ namespace BlackMisc
|
|||||||
//! 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
|
//! Synchronize
|
||||||
//! \todo is that threadsafe?
|
//! \todo is that threadsafe?
|
||||||
virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0;
|
virtual void synchronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) = 0;
|
||||||
|
|
||||||
//! Last cache
|
//! Last cache
|
||||||
bool syncronizeCurrentCache();
|
bool synchronizeCurrentCache();
|
||||||
|
|
||||||
//! Selected simulator
|
//! Selected simulator
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
@@ -195,6 +198,12 @@ namespace BlackMisc
|
|||||||
//! \copydoc IModelsPerSimulatorSetable::setModels
|
//! \copydoc IModelsPerSimulatorSetable::setModels
|
||||||
virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
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:
|
signals:
|
||||||
//! Cache has been changed
|
//! Cache has been changed
|
||||||
void cacheChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
void cacheChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
@@ -228,7 +237,7 @@ namespace BlackMisc
|
|||||||
virtual CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override;
|
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 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 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::Simulation::CSimulatorInfo getCurrentSimulator() const override { return this->m_currentSimulator.get(); }
|
||||||
virtual BlackMisc::CStatusMessage setCurrentSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
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
|
BlackMisc::CData<BlackMisc::Simulation::Data::TModelCacheLastSelection> m_currentSimulator { this }; //!< current simulator
|
||||||
|
|
||||||
//! Non virtaul version (used in ctor)
|
//! 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
|
//! 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 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 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 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::Simulation::CSimulatorInfo getCurrentSimulator() const override { return this->m_currentSimulator.get(); }
|
||||||
virtual BlackMisc::CStatusMessage setCurrentSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
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
|
BlackMisc::CData<BlackMisc::Simulation::Data::TModelSetLastSelection> m_currentSimulator { this }; //!< current simulator
|
||||||
|
|
||||||
//! Non virtaul version (used in ctor)
|
//! Non virtaul version (used in ctor)
|
||||||
void syncronizeCacheImpl(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
void synchronizeCacheImpl(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -145,6 +145,16 @@ namespace BlackMisc
|
|||||||
this->setSimulator(this->getSimulator() | other.getSimulator());
|
this->setSimulator(this->getSimulator() | other.getSimulator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSet<CSimulatorInfo> CSimulatorInfo::asSingleSimulatorSet() const
|
||||||
|
{
|
||||||
|
QSet<CSimulatorInfo> set;
|
||||||
|
if (this->m_simulator & FSX) { set.insert(CSimulatorInfo(FSX)); }
|
||||||
|
if (this->m_simulator & FS9) { set.insert(CSimulatorInfo(FS9)); }
|
||||||
|
if (this->m_simulator & P3D) { set.insert(CSimulatorInfo(P3D)); }
|
||||||
|
if (this->m_simulator & XPLANE) { set.insert(CSimulatorInfo(XPLANE)); }
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
CSimulatorInfo::Simulator CSimulatorInfo::boolToFlag(bool fsx, bool fs9, bool xp, bool p3d)
|
CSimulatorInfo::Simulator CSimulatorInfo::boolToFlag(bool fsx, bool fs9, bool xp, bool p3d)
|
||||||
{
|
{
|
||||||
Simulator s = fsx ? FSX : None;
|
Simulator s = fsx ? FSX : None;
|
||||||
@@ -185,6 +195,12 @@ namespace BlackMisc
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CSimulatorInfo &CSimulatorInfo::allFsFamilySimulators()
|
||||||
|
{
|
||||||
|
static const CSimulatorInfo s(CSimulatorInfo::AllFsFamily);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
const CSimulatorInfo CSimulatorInfo::getLocallyInstalledSimulators()
|
const CSimulatorInfo CSimulatorInfo::getLocallyInstalledSimulators()
|
||||||
{
|
{
|
||||||
//! \todo add XP, ...
|
//! \todo add XP, ...
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include <QFlags>
|
#include <QFlags>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QSet>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QMultiMap>
|
#include <QMultiMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -45,14 +46,14 @@ namespace BlackMisc
|
|||||||
//! Simulator
|
//! Simulator
|
||||||
enum SimulatorFlag
|
enum SimulatorFlag
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
FSX = 1 << 0,
|
FSX = 1 << 0,
|
||||||
FS9 = 1 << 1,
|
FS9 = 1 << 1,
|
||||||
XPLANE = 1 << 2,
|
XPLANE = 1 << 2,
|
||||||
P3D = 1 << 3,
|
P3D = 1 << 3,
|
||||||
FSX_P3D = FSX | P3D,
|
FSX_P3D = FSX | P3D,
|
||||||
AllMS = FSX | FS9 | P3D,
|
AllFsFamily = FSX | FS9 | P3D,
|
||||||
All = FSX | FS9 | XPLANE | P3D
|
All = FSX | FS9 | XPLANE | P3D
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(Simulator, SimulatorFlag)
|
Q_DECLARE_FLAGS(Simulator, SimulatorFlag)
|
||||||
|
|
||||||
@@ -143,6 +144,9 @@ namespace BlackMisc
|
|||||||
//! Add simulator
|
//! Add simulator
|
||||||
void add(const CSimulatorInfo &other);
|
void add(const CSimulatorInfo &other);
|
||||||
|
|
||||||
|
//! As a set of single simulator info objects
|
||||||
|
QSet<CSimulatorInfo> asSingleSimulatorSet() const;
|
||||||
|
|
||||||
//! Bool flags to enum
|
//! Bool flags to enum
|
||||||
static Simulator boolToFlag(bool fsx, bool fs9, bool xp, bool p3d);
|
static Simulator boolToFlag(bool fsx, bool fs9, bool xp, bool p3d);
|
||||||
|
|
||||||
@@ -152,6 +156,9 @@ namespace BlackMisc
|
|||||||
//! All simulators
|
//! All simulators
|
||||||
static const CSimulatorInfo &allSimulators();
|
static const CSimulatorInfo &allSimulators();
|
||||||
|
|
||||||
|
//! All simulators of the FS family (P3D FSX, FS9)
|
||||||
|
static const CSimulatorInfo &allFsFamilySimulators();
|
||||||
|
|
||||||
//! Locally installed simulators
|
//! Locally installed simulators
|
||||||
static const CSimulatorInfo getLocallyInstalledSimulators();
|
static const CSimulatorInfo getLocallyInstalledSimulators();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user