refs #452, simulator info class (which simulator is supported?)

This commit is contained in:
Klaus Basan
2015-09-23 03:00:16 +02:00
committed by Mathew Sutcliffe
parent 46f743c382
commit c5f7179588
2 changed files with 162 additions and 15 deletions

View File

@@ -36,40 +36,89 @@ namespace BlackMisc
//! Simulator
enum SimulatorFlags
{
None = 0,
FSX = 1 << 0,
FS9 = 1 << 1,
XP = 1 << 2
None = 0,
FSX = 1 << 0,
FS9 = 1 << 1,
XPLANE = 1 << 2,
P3D = 1 << 3,
FSX_P3D = FSX | P3D,
AllMS = FSX | FS9 | P3D,
All = FSX | FS9 | XPLANE | P3D
};
Q_DECLARE_FLAGS(Simulator, SimulatorFlags)
//! Default constructor
CSimulatorInfo();
//! Constructor
CSimulatorInfo(const QString &identifierString);
//! Constructor
CSimulatorInfo(Simulator s);
//! Constructor
CSimulatorInfo(bool fsx, bool fs9, bool xp);
CSimulatorInfo(int flagsAsInt);
//! Constructor
CSimulatorInfo(bool fsx, bool fs9, bool xp, bool p3d);
//! Unspecified simulator
bool isUnspecified() const;
//! FSX?
bool fsx() const;
//! FS9?
bool fs9() const;
//! XPlane
bool xplane() const;
//! P3D?
bool p3d() const;
//! Any simulator?
bool isAnySimulator() const;
//! No simulator?
bool isNoSimulator() const;
//! Is all simulators?
bool isAllSimulators() const;
//! Matches all simulators
bool matchesAll(const CSimulatorInfo &otherInfo) const;
//! Matches any simulator
bool matchesAny(const CSimulatorInfo &otherInfo) const;
//! Simulator
Simulator getSimulator() const { return static_cast<Simulator>(m_simulator); }
//! Simulator
void setSimulator(Simulator s) { m_simulator = static_cast<int>(s); }
//! All simulators
void setAllSimulators() { setSimulator(All); }
//! \copydoc CValueObject::convertToQString
QString convertToQString(bool i18n = false) const;
//! Add simulator
void add(const CSimulatorInfo &other);
//! Bool flags to enum
static Simulator boolToFlag(bool fsx, bool fs9, bool xp);
static Simulator boolToFlag(bool fsx, bool fs9, bool xp, bool p3d);
//! Identifer, as provided by plugin
static Simulator identifierToFlag(const QString &identifier);
//! All simulators
static const CSimulatorInfo &allSimulators();
//! Locally installed simulators
static const CSimulatorInfo getLocallyInstalledSimulators();
private:
BLACK_ENABLE_TUPLE_CONVERSION(CSimulatorInfo)
int m_simulator = static_cast<int>(None);
@@ -81,6 +130,7 @@ BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::CSimulatorInfo, (
attr(o.m_simulator)
))
Q_DECLARE_METATYPE(BlackMisc::Simulation::CSimulatorInfo)
Q_DECLARE_METATYPE(BlackMisc::Simulation::CSimulatorInfo::SimulatorFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(BlackMisc::Simulation::CSimulatorInfo::Simulator)
#endif // guard