mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 07:35:41 +08:00
refs #445, value objects and containers
* common base class for DB based classes * common base class for DB based containers * Livery, distributor value class * adjusted value classes to livery * utility functions for DB values (blackmisc free functions) * register new objects with metadata system
This commit is contained in:
committed by
Mathew Sutcliffe
parent
99b7c52383
commit
25fd0f4f2d
@@ -13,8 +13,10 @@
|
||||
#define BLACKMISC_SIMULATION_AIRCRAFTMODEL_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/aviation/aircraft.h"
|
||||
#include "blackmisc/aviation/aircrafticaodata.h"
|
||||
#include "blackmisc/aviation/livery.h"
|
||||
#include "blackmisc/network/user.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
|
||||
@@ -22,21 +24,23 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
//! Aircraft model (other pilot, my models on disk)
|
||||
//! Aircraft model (used by another pilot, my models on disk)
|
||||
//! \remarks Simulator independent class, supposed to be common denominator
|
||||
class BLACKMISC_EXPORT CAircraftModel : public CValueObject<CAircraftModel>
|
||||
class BLACKMISC_EXPORT CAircraftModel :
|
||||
public CValueObject<CAircraftModel>,
|
||||
public BlackMisc::IDatastoreObjectWithIntegerKey
|
||||
{
|
||||
public:
|
||||
//! Model type
|
||||
enum ModelType
|
||||
{
|
||||
TypeUnknown,
|
||||
TypeQueriedFromNetwork, //!< model was queried by network protocol
|
||||
TypeModelMatching, //!< model is result of model matching
|
||||
TypeQueriedFromNetwork, //!< model was queried by network protocol
|
||||
TypeModelMatching, //!< model is result of model matching
|
||||
TypeModelMatchingDefaultModel, //!< a default model assigned by model matching
|
||||
TypeModelMapping, //!< used along with mapping definition
|
||||
TypeManuallySet, //!< manually set, e.g. from GUI
|
||||
TypeOwnSimulatorModel //!< represents own simulator model
|
||||
TypeModelMapping, //!< used along with mapping definition
|
||||
TypeManuallySet, //!< manually set, e.g. from GUI
|
||||
TypeOwnSimulatorModel //!< represents own simulator model
|
||||
};
|
||||
|
||||
//! Indexes
|
||||
@@ -46,6 +50,7 @@ namespace BlackMisc
|
||||
IndexCallsign,
|
||||
IndexDescription,
|
||||
IndexIcao,
|
||||
IndexLivery,
|
||||
IndexFileName,
|
||||
IndexModelType,
|
||||
IndexModelTypeAsString,
|
||||
@@ -56,11 +61,10 @@ namespace BlackMisc
|
||||
CAircraftModel() {}
|
||||
|
||||
//! Constructor.
|
||||
CAircraftModel(const QString &model, ModelType type) : m_modelString(model), m_modelType(type) {}
|
||||
CAircraftModel(const QString &model, ModelType type);
|
||||
|
||||
//! Constructor.
|
||||
CAircraftModel(const QString &model, ModelType type, const QString &description, const BlackMisc::Aviation::CAircraftIcaoData &icao) :
|
||||
m_icao(icao), m_modelString(model), m_description(description), m_modelType(type) {}
|
||||
CAircraftModel(const QString &model, ModelType type, const QString &description, const BlackMisc::Aviation::CAircraftIcaoData &icao, const BlackMisc::Aviation::CLivery &livery = BlackMisc::Aviation::CLivery());
|
||||
|
||||
//! Constructor
|
||||
CAircraftModel(const BlackMisc::Aviation::CAircraft &aircraft);
|
||||
@@ -80,7 +84,7 @@ namespace BlackMisc
|
||||
//! Callsign empty
|
||||
bool isCallsignEmpty() const { return this->m_callsign.isEmpty(); }
|
||||
|
||||
//! Queried model string
|
||||
//! Model string, either queried or loaded from simulator model
|
||||
const QString &getModelString() const { return this->m_modelString; }
|
||||
|
||||
//! Model string
|
||||
@@ -107,18 +111,42 @@ namespace BlackMisc
|
||||
//! \copydoc CAircraftIcaoData::hasAircraftDesignator
|
||||
bool hasAircraftDesignator() const { return this->m_icao.hasAircraftDesignator(); }
|
||||
|
||||
//! Aircraft ICAO code
|
||||
const BlackMisc::Aviation::CAircraftIcaoCode &getAircraftIcaoCode() const;
|
||||
|
||||
//! Airline ICAO code
|
||||
const BlackMisc::Aviation::CAirlineIcaoCode &getAirlineIcaoCode() const;
|
||||
|
||||
//! Get livery
|
||||
const BlackMisc::Aviation::CLivery &getLivery() const { return m_livery; }
|
||||
|
||||
//! Livery
|
||||
void setLivery(const BlackMisc::Aviation::CLivery &livery) { this->m_livery = livery; }
|
||||
|
||||
//! Livery available?
|
||||
bool hasLivery() const { return m_livery.hasCompleteData();}
|
||||
|
||||
//! Model type
|
||||
ModelType getModelType() const { return static_cast<ModelType>(m_modelType); }
|
||||
ModelType getModelType() const { return m_modelType; }
|
||||
|
||||
//! Model type
|
||||
QString getModelTypeAsString() const { return modelTypeToString(getModelType()); }
|
||||
|
||||
//! Set type
|
||||
void setModelType(ModelType type) { this->m_modelType = static_cast<int>(type); }
|
||||
void setModelType(ModelType type) { this->m_modelType = type; }
|
||||
|
||||
//! File name
|
||||
//! Simulator info
|
||||
CSimulatorInfo getSimulatorInfo() const { return this->m_simulator; }
|
||||
|
||||
//! Set simulator info
|
||||
void setSimulatorInfo(const CSimulatorInfo &simulator) { this->m_simulator = simulator; }
|
||||
|
||||
//! File name (corresponding data for simulator, only available if representing simulator model=
|
||||
QString getFileName() const { return m_fileName; }
|
||||
|
||||
//! File name?
|
||||
bool hasFileName() const { return !m_fileName.isEmpty(); }
|
||||
|
||||
//! File name
|
||||
void setFileName(const QString &fileName) { m_fileName = fileName; }
|
||||
|
||||
@@ -137,20 +165,25 @@ namespace BlackMisc
|
||||
//! Matches model string?
|
||||
bool matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const;
|
||||
|
||||
//! Model type
|
||||
static QString modelTypeToString(ModelType type);
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! Model type
|
||||
static QString modelTypeToString(ModelType type);
|
||||
|
||||
//! From swift DB JSON
|
||||
static CAircraftModel fromDatabaseJson(const QJsonObject &json);
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CAircraftModel)
|
||||
BlackMisc::Aviation::CCallsign m_callsign; //!< aircraft's callsign
|
||||
BlackMisc::Aviation::CAircraftIcaoData m_icao; //!< ICAO data if available
|
||||
QString m_modelString; //!< Simulator model string
|
||||
QString m_description; //!< descriptive text
|
||||
QString m_fileName; //!< file name
|
||||
int m_modelType = static_cast<int>(TypeUnknown); //!< model string is queried from network?
|
||||
BlackMisc::Aviation::CCallsign m_callsign; //!< aircraft's callsign if any
|
||||
BlackMisc::Aviation::CAircraftIcaoData m_icao; //!< ICAO data if available
|
||||
BlackMisc::Aviation::CLivery m_livery; //!< livery information
|
||||
CSimulatorInfo m_simulator; //!< model for given simulator
|
||||
QString m_modelString; //!< Simulator model string
|
||||
QString m_description; //!< descriptive text
|
||||
QString m_fileName; //!< file name
|
||||
ModelType m_modelType = TypeUnknown; //!< model string is coming from ...?
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
@@ -159,6 +192,7 @@ BLACK_DECLARE_TUPLE_CONVERSION(
|
||||
BlackMisc::Simulation::CAircraftModel, (
|
||||
attr(o.m_callsign),
|
||||
attr(o.m_icao),
|
||||
attr(o.m_simulator),
|
||||
attr(o.m_modelString, flags<CaseInsensitiveComparison>()),
|
||||
attr(o.m_description, flags<DisabledForComparison>()),
|
||||
attr(o.m_fileName, flags <DisabledForComparison> ()),
|
||||
|
||||
Reference in New Issue
Block a user