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 "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"; }
236 bool isCacheAlreadySynchronized(
const CSimulatorInfo &simulator)
const;
240 virtual void synchronizeMultiCaches(
const CSimulatorInfo &simulator);
256 QString getInfoStringFsFamily()
const;
263 virtual void gracefulShutdown();
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 };
338 void synchronizeCacheImpl(
const CSimulatorInfo &simulator);
342 bool admitCacheImpl(
const CSimulatorInfo &simulator);
376 CData<TModelSetCacheMsfs2024> m_modelCacheMsfs2024 {
this,
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 & guessDefaultSimulator()
Guess a default simulator based on installation.
static const CSimulatorInfo & msfs()
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.
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...
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.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
void setObjectName(QAnyStringView name)
Base class for traits to be used as template argument to swift::misc::CData.
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.
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.