6#ifndef SWIFT_MISC_SIMULATION_DATA_MODELCACHES
7#define SWIFT_MISC_SIMULATION_DATA_MODELCACHES
23namespace swift::misc::simulation::data
39 static const char *
key() {
return "modelcachexp"; }
46 static const char *
key() {
return "modelcachep3d"; }
53 static const char *
key() {
return "modelcachefg"; }
60 static const char *
key() {
return "modelcachemsfs"; }
67 static const char *
key() {
return "modelcachemsfs2024"; }
74 static constexpr bool isPinned() {
return true; }
80 static const char *
key() {
return "modelcachelastselection"; }
91 static const char *
key() {
return "modelsetxp"; }
98 static const char *
key() {
return "modelsetp3d"; }
105 static const char *
key() {
return "modelsetfg"; }
112 static const char *
key() {
return "modelsetmsfs"; }
119 static const char *
key() {
return "modelsetmsfs2024"; }
132 static const char *
key() {
return "simulatorlastselection"; }
145 static const char *
key() {
return "simulatorlastselections"; }
153 static const char *
key() {
return "vpilot/models"; }
288 void markCacheAsAlreadySynchronized(
const CSimulatorInfo &simulator,
bool synchronized);
296 std::atomic_bool m_syncP3D {
false };
297 std::atomic_bool m_syncFG {
false };
298 std::atomic_bool m_syncXPlane {
false };
299 std::atomic_bool m_syncMsfs {
false };
300 std::atomic_bool m_syncMsfs2024 {
false };
334 CData<TModelCacheMsfs> m_modelCacheMsfs {
this, &CModelCaches::changedMsfs };
335 CData<TModelCacheMsfs2024> m_modelCacheMsfs2024 {
this, &CModelCaches::changedMsfs2024 };
338 void synchronizeCacheImpl(
const CSimulatorInfo &simulator);
342 bool admitCacheImpl(
const CSimulatorInfo &simulator);
375 CData<TModelSetCacheMsfs> m_modelCacheMsfs {
this, &CModelSetCaches::changedMsfs };
376 CData<TModelSetCacheMsfs2024> m_modelCacheMsfs2024 {
this,
377 &CModelSetCaches::changedMsfs2024 };
380 void synchronizeCacheImpl(
const CSimulatorInfo &simulator);
384 bool admitCacheImpl(
const CSimulatorInfo &simulator);
388 template <
class TCaches,
class Derived>
398 return instanceCaches().getCachedModels(simulator);
404 return instanceCaches().setCachedModels(models, simulator);
410 return instanceCaches().getCacheTimestamp(simulator);
416 return instanceCaches().setCacheTimestamp(ts, simulator);
422 return instanceCaches().synchronizeCache(simulator);
431 return instanceCaches().getFilename(simulator);
452 TCaches m_caches {
false,
this };
455 TCaches &instanceCaches() {
return this->isInstance() ? m_caches : Derived::modelCachesInstance().m_caches; }
458 const TCaches &instanceCaches()
const
460 return this->isInstance() ? m_caches : Derived::modelCachesInstance().m_caches;
465 bool isInstance()
const {
return this == &Derived::modelCachesInstance(); }
577 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 & msfs()
Const simulator info objects.
static const CSimulatorInfo & xplane()
Const simulator info objects.
static const CSimulatorInfo & p3d()
Const simulator info objects.
static const CSimulatorInfo & fg()
Const simulator info objects.
static const CSimulatorInfo & msfs2024()
Const simulator info objects.
static const CSimulatorInfo & guessDefaultSimulator()
Guess a default simulator based on installation.
Interface to "something" backing models, which can be set.
IModelsForSimulatorSetable()=default
Ctor, dtor, copy operators (CLANG warnings).
Interface to "something" backing models, which can be modified (updated).
IModelsForSimulatorUpdatable()=default
Ctor, dtor, copy operators (CLANG warnings).
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.
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.
CCentralMultiSimulatorModelCachesProvider(const QString &name, QObject *parent=nullptr)
Ctor.
static CCentralMultiSimulatorModelCachesProvider & modelCachesInstance()
Central instance.
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.
CCentralMultiSimulatorModelSetCachesProvider(const QString &name, QObject *parent=nullptr)
Ctor.
static CCentralMultiSimulatorModelSetCachesProvider & modelCachesInstance()
Central instance.
CAircraftModelList getCachedModels(const CSimulatorInfo &simulator) const
Models for simulator.
CModelCaches(bool synchronizeCache, QObject *parent=nullptr)
Construtor.
QString getDescription() const
Descriptive text.
CStatusMessage setCachedModels(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Set cached models.
bool isSaved(const CSimulatorInfo &simulator) const
Cache saved?
void synchronizeCache(const CSimulatorInfo &simulator)
Synchronize for given simulator.
QDateTime getCacheTimestamp(const CSimulatorInfo &simulator) const
Cache timestamp.
void admitCache(const CSimulatorInfo &simulator)
Admit the cache for given simulator.
CStatusMessage setCacheTimestamp(const QDateTime &ts, const CSimulatorInfo &simulator)
Set cache timestamp.
static const QStringList & getLogCategories()
Log categories.
QString getFilename(const CSimulatorInfo &simulator) const
Get filename for simulator cache file.
void admitCache(const CSimulatorInfo &simulator)
Admit the cache for given simulator.
QString getDescription() const
Descriptive text.
QString getFilename(const CSimulatorInfo &simulator) const
Get filename for simulator cache file.
CModelSetCaches(bool synchronizeCache, QObject *parent=nullptr)
Construtor.
CStatusMessage setCacheTimestamp(const QDateTime &ts, const CSimulatorInfo &simulator)
Set cache timestamp.
CStatusMessage setCachedModels(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Set cached models.
bool isSaved(const CSimulatorInfo &simulator) const
Cache saved?
void synchronizeCache(const CSimulatorInfo &simulator)
Synchronize for given simulator.
static const QStringList & getLogCategories()
Log categories.
QDateTime getCacheTimestamp(const CSimulatorInfo &simulator) const
Cache timestamp.
CAircraftModelList getCachedModels(const CSimulatorInfo &simulator) const
Models for simulator.
CSimulatorInfo simulatorsWithInitializedCache() const
Initialized caches for which simulator?
IMultiSimulatorModelCaches(QObject *parent=nullptr)
Construtor.
virtual void gracefulShutdown()
Graceful shutdown.
CSimulatorInfo otherVersionSimulatorsWithFile(const swift::misc::CApplicationInfo &info) const
Simulators of given other versionwhich have a cache file.
CSimulatorInfo getSimulatorForFilename(const QString &filename) const
Simulator which uses cache with filename.
bool isCacheAlreadySynchronized(const CSimulatorInfo &simulator) const
Is the cache already synchronized?
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.
virtual CStatusMessage clearCachedModels(const CSimulatorInfo &simulator)
Clear cached models.
void changedXP()
Cache has been changed. This will only detect changes elsewhere, owned caches will not signal local c...
bool hasOtherVersionFile(const swift::misc::CApplicationInfo &info, const CSimulatorInfo &simulator) const
Has the other version the file?
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.
CAircraftModelList getSynchronizedCachedModels(const CSimulatorInfo &simulator)
Models.
CSimulatorInfo simulatorsWithModels() const
Simulators which have models.
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...
virtual void synchronizeMultiCaches(const CSimulatorInfo &simulator)
Synchronize multiple simulators.
void emitCacheChanged(const CSimulatorInfo &simulator)
Emit cacheChanged() utility function (allows breakpoint).
QString getCacheCountAndTimestamp(const CSimulatorInfo &simulator) const
Cache count and timestamp.
virtual QStringList getAllFilenames() const
All file names.
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.
QDateTime getSynchronizedTimestamp(const CSimulatorInfo &simulator)
Timestamp.
virtual void admitMultiCaches(const CSimulatorInfo &simulator)
Synchronize multiple simulators.
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.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
void setObjectName(QAnyStringView name)
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 CSimulatorInfo & defaultValue()
Default simulator.
static constexpr bool isPinned()
First load is synchronous.
static const char * key()
Key.
static const CSimulatorInfo & defaultValue()
Default simulator.
static const char * key()
Key.
static constexpr bool isPinned()
First load is synchronous.
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.