6 #ifndef SWIFT_MISC_SIMULATION_DATA_MODELCACHES
7 #define SWIFT_MISC_SIMULATION_DATA_MODELCACHES
23 namespace swift::misc::simulation::data
39 static const char *
key() {
return "modelcachexp"; }
46 static const char *
key() {
return "modelcachefsx"; }
53 static const char *
key() {
return "modelcachefs9"; }
60 static const char *
key() {
return "modelcachep3d"; }
67 static const char *
key() {
return "modelcachefg"; }
74 static const char *
key() {
return "modelcachemsfs"; }
81 static const char *
key() {
return "modelcachemsfs2024"; }
88 static constexpr
bool isPinned() {
return true; }
94 static const char *
key() {
return "modelcachelastselection"; }
105 static const char *
key() {
return "modelsetxp"; }
112 static const char *
key() {
return "modelsetfsx"; }
119 static const char *
key() {
return "modelsetfs9"; }
126 static const char *
key() {
return "modelsetp3d"; }
133 static const char *
key() {
return "modelsetfg"; }
140 static const char *
key() {
return "modelsetmsfs"; }
147 static const char *
key() {
return "modelsetmsfs2024"; }
160 static const char *
key() {
return "simulatorlastselection"; }
173 static const char *
key() {
return "simulatorlastselections"; }
181 static const char *
key() {
return "vpilot/models"; }
221 virtual QStringList getAllFilenames()
const;
224 CSimulatorInfo getSimulatorForFilename(
const QString &filename)
const;
248 QDateTime getSynchronizedTimestamp(
const CSimulatorInfo &simulator);
264 bool isCacheAlreadySynchronized(
const CSimulatorInfo &simulator)
const;
268 virtual void synchronizeMultiCaches(
const CSimulatorInfo &simulator);
280 QString getInfoString()
const;
284 QString getInfoStringFsFamily()
const;
288 QString getCacheCountAndTimestamp(
const CSimulatorInfo &simulator)
const;
291 virtual void gracefulShutdown();
318 void markCacheAsAlreadySynchronized(
const CSimulatorInfo &simulator,
bool synchronized);
326 std::atomic_bool m_syncFsx {
false };
327 std::atomic_bool m_syncP3D {
false };
328 std::atomic_bool m_syncFS9 {
false };
329 std::atomic_bool m_syncFG {
false };
330 std::atomic_bool m_syncXPlane {
false };
331 std::atomic_bool m_syncMsfs {
false };
332 std::atomic_bool m_syncMsfs2024 {
false };
344 CModelCaches(
bool synchronizeCache, QObject *parent =
nullptr);
347 static const QStringList &getLogCategories();
353 QDateTime getCacheTimestamp(
const CSimulatorInfo &simulator)
const override;
357 QString getFilename(
const CSimulatorInfo &simulator)
const override;
372 void synchronizeCacheImpl(
const CSimulatorInfo &simulator);
376 bool admitCacheImpl(
const CSimulatorInfo &simulator);
390 static const QStringList &getLogCategories();
396 QDateTime getCacheTimestamp(
const CSimulatorInfo &simulator)
const override;
400 QString getFilename(
const CSimulatorInfo &simulator)
const override;
412 CData<TModelSetCacheMsfs2024> m_modelCacheMsfs2024 {
this,
416 void synchronizeCacheImpl(
const CSimulatorInfo &simulator);
420 bool admitCacheImpl(
const CSimulatorInfo &simulator);
424 template <
class TCaches,
class Derived>
434 return instanceCaches().getCachedModels(simulator);
440 return instanceCaches().setCachedModels(models, simulator);
446 return instanceCaches().getCacheTimestamp(simulator);
452 return instanceCaches().setCacheTimestamp(ts, simulator);
458 return instanceCaches().synchronizeCache(simulator);
467 return instanceCaches().getFilename(simulator);
474 QString
getDescription()
const override {
return instanceCaches().getDescription(); }
482 this->setObjectName(name);
488 TCaches m_caches {
false,
this };
491 TCaches &instanceCaches() {
return this->isInstance() ? m_caches : Derived::modelCachesInstance().m_caches; }
494 const TCaches &instanceCaches()
const
496 return this->isInstance() ? m_caches : Derived::modelCachesInstance().m_caches;
501 bool isInstance()
const {
return this == &Derived::modelCachesInstance(); }
613 CCentralMultiSimulatorModelSetCachesProvider>
Description of a swift application.
Class template for accessing a specific value in the CDataCache.
Streamable status message, e.g.
static bool isInThisThread(const QObject *toBeTested)
Is the current thread the object's thread?
Value object encapsulating a list of aircraft models.
Simple hardcoded info about the corresponding simulator.
static const CSimulatorInfo & guessDefaultSimulator()
Guess a default simulator based on installation.
static const CSimulatorInfo & msfs()
Const simulator info objects.
static const CSimulatorInfo & fs9()
Const simulator info objects.
static const CSimulatorInfo & fsx()
Const simulator info objects.
static const CSimulatorInfo & p3d()
Const simulator info objects.
static const CSimulatorInfo & xplane()
Const simulator info objects.
static const CSimulatorInfo & msfs2024()
Const simulator info objects.
static const CSimulatorInfo & fg()
Const simulator info objects.
Interface to "something" backing models, which can be set.
Interface to "something" backing models, which can be modified (updated)
Basically a QObject free (delegate based) version of CCentralMultiSimulatorModelCachesProvider.
QString getInfoStringFsFamily() const
Look like IMultiSimulatorModelCaches interface.
QString getDescription() const
Look like IMultiSimulatorModelCaches interface.
void synchronizeCache(const CSimulatorInfo &simulator)
Look like IMultiSimulatorModelCaches interface.
CStatusMessage setCachedModels(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Look like IMultiSimulatorModelCaches interface.
void setModelsForSimulator(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Set models.
bool isSaved(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
QDateTime getCacheTimestamp(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
CStatusMessage clearCachedModels(const CSimulatorInfo &simulator)
Look like IMultiSimulatorModelCaches interface.
QString getCacheCountAndTimestamp(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
QString getInfoString() const
Look like IMultiSimulatorModelCaches interface.
CStatusMessage setCacheTimestamp(const QDateTime &ts, const CSimulatorInfo &simulator)
Look like IMultiSimulatorModelCaches interface.
int updateModelsForSimulator(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Set models.
CAircraftModelList getCachedModels(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
void admitCache(const CSimulatorInfo &simulator)
Look like IMultiSimulatorModelCaches interface.
QString getFilename(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
int getCachedModelsCount(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
One central instance of the caches base class.
QDateTime getCacheTimestamp(const CSimulatorInfo &simulator) const
Cache timestamp.
void admitCache(const CSimulatorInfo &simulator)
Admit the cache for given simulator.
CAircraftModelList getCachedModels(const CSimulatorInfo &simulator) const
Models for simulator.
QString getFilename(const CSimulatorInfo &simulator) const
Get filename for simulator cache file.
void synchronizeCache(const CSimulatorInfo &simulator)
Synchronize for given simulator.
QString getDescription() const
Descriptive text.
bool isSaved(const CSimulatorInfo &simulator) const
Cache saved?
CStatusMessage setCacheTimestamp(const QDateTime &ts, const CSimulatorInfo &simulator)
Set cache timestamp.
CStatusMessage setCachedModels(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Set cached models.
CCentralMultiSimulatorModelCachesProviderBase(const QString &name, QObject *parent=nullptr)
Ctor.
One central instance of the model caches.
static CCentralMultiSimulatorModelCachesProvider & modelCachesInstance()
Central instance.
CCentralMultiSimulatorModelCachesProvider(const QString &name, QObject *parent=nullptr)
Ctor.
Basically a QObject free (delegate based) version of CCentralMultiSimulatorModelSetCachesProvider.
void admitCache(const CSimulatorInfo &simulator)
Look like IMultiSimulatorModelCaches interface.
QString getDescription() const
Look like IMultiSimulatorModelCaches interface.
QString getFilename(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
int updateModelsForSimulator(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Set models.
void setModelsForSimulator(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Set models.
QString getInfoStringFsFamily() const
Look like IMultiSimulatorModelCaches interface.
CAircraftModelList getCachedModels(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
CStatusMessage setCachedModels(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Look like IMultiSimulatorModelCaches interface.
QString getInfoString() const
Look like IMultiSimulatorModelCaches interface.
QString getCacheCountAndTimestamp(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
QDateTime getCacheTimestamp(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
CStatusMessage setCacheTimestamp(const QDateTime &ts, const CSimulatorInfo &simulator)
Look like IMultiSimulatorModelCaches interface.
bool isSaved(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
int getCachedModelsCount(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
CStatusMessage clearCachedModels(const CSimulatorInfo &simulator)
Look like IMultiSimulatorModelCaches interface.
void synchronizeCache(const CSimulatorInfo &simulator)
Look like IMultiSimulatorModelCaches interface.
One central instance of the model set caches.
CCentralMultiSimulatorModelSetCachesProvider(const QString &name, QObject *parent=nullptr)
Ctor.
static CCentralMultiSimulatorModelSetCachesProvider & modelCachesInstance()
Central instance.
Bundle of caches for all simulators.
QString getDescription() const
Descriptive text.
Bundle of caches for model sets of all simulators.
QString getDescription() const
Descriptive text.
Cache for multiple simulators specified by CSimulatorInfo.
IMultiSimulatorModelCaches(QObject *parent=nullptr)
Construtor.
QString getInfoString() const
Info string about models in cache.
void changedMsfs2024()
Cache has been changed. This will only detect changes elsewhere, owned caches will not signal local c...
virtual QString getDescription() const =0
Descriptive text.
virtual void synchronizeCache(const CSimulatorInfo &simulator)=0
Synchronize for given simulator.
int getCachedModelsCount(const CSimulatorInfo &simulator) const
Count of models for simulator.
void changedFsx()
Cache has been changed. This will only detect changes elsewhere, owned caches will not signal local c...
virtual CStatusMessage clearCachedModels(const CSimulatorInfo &simulator)
Clear cached models.
void changedFs9()
Cache has been changed. This will only detect changes elsewhere, owned caches will not signal local c...
void changedXP()
Cache has been changed. This will only detect changes elsewhere, owned caches will not signal local c...
virtual void admitCache(const CSimulatorInfo &simulator)=0
Admit the cache for given simulator.
void changedFG()
Cache has been changed. This will only detect changes elsewhere, owned caches will not signal local c...
virtual bool isSaved(const CSimulatorInfo &simulator) const =0
Cache saved?
virtual CAircraftModelList getCachedModels(const CSimulatorInfo &simulator) const =0
Models for simulator.
virtual CStatusMessage setCachedModels(const CAircraftModelList &models, const CSimulatorInfo &simulator)=0
Set cached models.
virtual QString getFilename(const CSimulatorInfo &simulator) const =0
Get filename for simulator cache file.
void changedMsfs()
Cache has been changed. This will only detect changes elsewhere, owned caches will not signal local c...
QString getCacheCountAndTimestamp(const CSimulatorInfo &simulator) const
Cache count and timestamp.
void cacheChanged(const swift::misc::simulation::CSimulatorInfo &simulator)
Cache has been changed.
void setModelsForSimulator(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Set models.
void changedP3D()
Cache has been changed. This will only detect changes elsewhere, owned caches will not signal local c...
virtual CStatusMessage setCacheTimestamp(const QDateTime &ts, const CSimulatorInfo &simulator)=0
Set cache timestamp.
QString getInfoStringFsFamily() const
Info string without XPlane (FSX,P3D, FS9)
virtual QDateTime getCacheTimestamp(const CSimulatorInfo &simulator) const =0
Cache timestamp.
int updateModelsForSimulator(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Set models.
Base class for traits to be used as template argument to swift::misc::CData.
static const char * key()
Key in data cache.
static const char * key()
Key in data cache.
static const char * key()
Key in data cache.
static constexpr bool isDeferred()
Defer loading.
static constexpr bool isPinned()
First load is synchronous.
static const char * key()
Key.
static const CSimulatorInfo & defaultValue()
Default simulator.
static const char * key()
Key in data cache.
static const char * key()
Key in data cache.
static const char * key()
Key in data cache.
static const char * key()
Key in data cache.
static const char * key()
Key in data cache.
static const char * key()
Key in data cache.
static const char * key()
Key in data cache.
static const char * key()
Key in data cache.
static const char * key()
Key in data cache.
static const char * key()
Key in data cache.
static const char * key()
Key in data cache.
static const char * key()
Key.
static constexpr bool isPinned()
First load is synchronous.
static const CSimulatorInfo & defaultValue()
Default simulator.
static const CSimulatorInfo & defaultValue()
Default simulator.
static constexpr bool isPinned()
First load is synchronous.
static const char * key()
Key.
Trait for vPilot derived models.
static const char * key()
Key in data cache.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.