refs #619, use a combined cache class

* moved caches to blackmisc
* used CModelCaches in loader
* applied changes in simulator specific loader classes
* renamed find function to findFirstByModelStringOrDefault
* made merge function static so it can be used elsewhere
This commit is contained in:
Klaus Basan
2016-03-22 01:57:31 +01:00
parent 7d785b4e3b
commit c339a3d1e0
14 changed files with 336 additions and 201 deletions

View File

@@ -32,33 +32,137 @@ namespace BlackMisc
}
};
//! Trait for XP model cache
//! \name Caches for own models on disk, loaded by BlackMisc::Simulation::IAircraftModelLoader
//! @{
//! XPlane
struct ModelCacheXP : public ModelCache
{
//! Key in data cache
static const char *key() { return "modelcachexp"; }
};
//! Trait for FSX model cache
//! FSX
struct ModelCacheFsx : public ModelCache
{
//! Key in data cache
static const char *key() { return "modelcachefsx"; }
};
//! Trait for FS9 model cache
//! FS9
struct ModelCacheFs9 : public ModelCache
{
//! Key in data cache
static const char *key() { return "modelcachefs9"; }
};
//! Trait for P3D model cache
//! P3D
struct ModelCacheP3D : public ModelCache
{
//! Key in data cache
static const char *key() { return "modelcachep3d"; }
};
//! @}
//! \name Caches for choosen model sets
//! @{
//! XPlane
struct ModelSetCacheXP : public ModelCache
{
//! Key in data cache
static const char *key() { return "modelsetxp"; }
};
//! FSX
struct ModelSetCacheFsx : public ModelCache
{
//! Key in data cache
static const char *key() { return "modelsetfsx"; }
};
//! FS9
struct ModelSetCacheFs9 : public ModelCache
{
//! Key in data cache
static const char *key() { return "modelsetfs9"; }
};
//! P3D
struct ModelSetCacheP3D : public ModelCache
{
//! Key in data cache
static const char *key() { return "modelsetp3d"; }
};
//! @}
//! Trait for vPilot derived models
struct VPilotAircraftModels : public BlackMisc::CDataTrait<BlackMisc::Simulation::CAircraftModelList>
{
//! Key in data cache
static const char *key() { return "vpilot/models"; }
};
//! Bundle of caches for all simulators
//! \remark Temp. workaround
class CModelCaches : public QObject
{
Q_OBJECT
public:
//! Construtor
CModelCaches(QObject *parent = nullptr);
//! Models
CAircraftModelList getModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
//! Set models
BlackMisc::CStatusMessage setModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Cache timestamp
QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
//! Syncronize
void syncronize(const BlackMisc::Simulation::CSimulatorInfo &simulator);
private:
BlackMisc::CData<BlackMisc::Simulation::Data::ModelCacheFsx> m_modelCacheFsx {this }; //!< FSX cache
BlackMisc::CData<BlackMisc::Simulation::Data::ModelCacheFs9> m_modelCacheFs9 {this }; //!< FS9 cache
BlackMisc::CData<BlackMisc::Simulation::Data::ModelCacheP3D> m_modelCacheP3D {this }; //!< P3D cache
BlackMisc::CData<BlackMisc::Simulation::Data::ModelCacheXP> m_modelCacheXP {this }; //!< XP cache
};
//! Bundle of caches for model sets of all simulators
//! \remark Temp. workaround
class CModelSetCaches : public QObject
{
Q_OBJECT
public:
//! Construtor
CModelSetCaches(QObject *parent = nullptr);
//! Models
CAircraftModelList getModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
//! Set models
BlackMisc::CStatusMessage setModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Cache timestamp
QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
//! Syncronize
void syncronize(const BlackMisc::Simulation::CSimulatorInfo &simulator);
private:
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheFsx> m_modelCacheFsx {this }; //!< FSX cache
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheFs9> m_modelCacheFs9 {this }; //!< FS9 cache
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheP3D> m_modelCacheP3D {this }; //!< P3D cache
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheXP> m_modelCacheXP {this }; //!< XP cache
};
} // ns
} // ns