mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 18:55:38 +08:00
refs #445, simulator info for database operations
This commit is contained in:
committed by
Mathew Sutcliffe
parent
6a1f5e8347
commit
03e16e37e7
@@ -13,6 +13,7 @@
|
|||||||
#include "blackmisc/simulation/airspaceaircraftsnapshot.h"
|
#include "blackmisc/simulation/airspaceaircraftsnapshot.h"
|
||||||
#include "blackmisc/simulation/distributorlist.h"
|
#include "blackmisc/simulation/distributorlist.h"
|
||||||
#include "blackmisc/simulation/simulatorsetup.h"
|
#include "blackmisc/simulation/simulatorsetup.h"
|
||||||
|
#include "blackmisc/simulation/simulatorinfo.h"
|
||||||
#include "blackmisc/simulation/fsx/simconnectutilities.h"
|
#include "blackmisc/simulation/fsx/simconnectutilities.h"
|
||||||
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
||||||
#include "blackmisc/simulation/fscommon/vpilotmodelruleset.h"
|
#include "blackmisc/simulation/fscommon/vpilotmodelruleset.h"
|
||||||
@@ -43,5 +44,6 @@ void BlackMisc::Simulation::registerMetadata()
|
|||||||
CVPilotModelRule::registerMetadata();
|
CVPilotModelRule::registerMetadata();
|
||||||
CVPilotModelRuleSet::registerMetadata();
|
CVPilotModelRuleSet::registerMetadata();
|
||||||
CSimulatorSetup::registerMetadata();
|
CSimulatorSetup::registerMetadata();
|
||||||
|
CSimulatorInfo::registerMetadata();
|
||||||
CAirspaceAircraftSnapshot::registerMetadata();
|
CAirspaceAircraftSnapshot::registerMetadata();
|
||||||
}
|
}
|
||||||
|
|||||||
73
src/blackmisc/simulation/simulatorinfo.cpp
Normal file
73
src/blackmisc/simulation/simulatorinfo.cpp
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
/* Copyright (C) 2013
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "simulatorinfo.h"
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Simulation
|
||||||
|
{
|
||||||
|
CSimulatorInfo::CSimulatorInfo()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
CSimulatorInfo::CSimulatorInfo(Simulator s) : m_simulator(static_cast<int>(s))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
CSimulatorInfo::CSimulatorInfo(bool fsx, bool fs9, bool xp) :
|
||||||
|
m_simulator(boolToFlag(fsx, fs9, xp))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
bool CSimulatorInfo::isUnspecified() const
|
||||||
|
{
|
||||||
|
return m_simulator < 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CSimulatorInfo::convertToQString(bool i18n) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(i18n);
|
||||||
|
Simulator s = getSimulator();
|
||||||
|
QString str;
|
||||||
|
if (s.testFlag(FSX)) { str.append("FSX "); }
|
||||||
|
if (s.testFlag(FS9)) { str.append("FS9 "); }
|
||||||
|
if (s.testFlag(XP)) { str.append("XPlane "); }
|
||||||
|
return str.trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
CSimulatorInfo::Simulator CSimulatorInfo::boolToFlag(bool fsx, bool fs9, bool xp)
|
||||||
|
{
|
||||||
|
Simulator s = fsx ? FSX : None;
|
||||||
|
if (fs9) { s |= FS9; }
|
||||||
|
if (xp) { s |= XP; }
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSimulatorInfo::Simulator CSimulatorInfo::identifierToFlag(const QString &identifier)
|
||||||
|
{
|
||||||
|
QString i(identifier.toLower().trimmed());
|
||||||
|
if (i.isEmpty()) { return None; }
|
||||||
|
|
||||||
|
Simulator s = None;
|
||||||
|
if (i.contains("fsx"))
|
||||||
|
{
|
||||||
|
s |= FSX;
|
||||||
|
}
|
||||||
|
if (i.contains("fs9"))
|
||||||
|
{
|
||||||
|
s |= FS9;
|
||||||
|
}
|
||||||
|
if (i.contains("xplane") || i.contains("xp"))
|
||||||
|
{
|
||||||
|
s |= XP;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
86
src/blackmisc/simulation/simulatorinfo.h
Normal file
86
src/blackmisc/simulation/simulatorinfo.h
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
/* Copyright (C) 2013
|
||||||
|
* swift Project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKMISC_SIMULATION_SIMULATORINFO_H
|
||||||
|
#define BLACKMISC_SIMULATION_SIMULATORINFO_H
|
||||||
|
|
||||||
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
#include "blackmisc/valueobject.h"
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Simulation
|
||||||
|
{
|
||||||
|
//! Simple hardcoded info about the corresponding simulator.
|
||||||
|
//! * in an ideal world this class would not exist, all would depend on flexible plugins \sa CSimulatorPluginInfo
|
||||||
|
//! * in a real world the info is needed in a couple of places to specify the simulator
|
||||||
|
//! ** when data from the swift data store a read, the corresponding simulator is specified
|
||||||
|
//! ** when model metadata are written to the swift data store the DB simulator info needs to be provided
|
||||||
|
//! ** when models are indexed from disk it does not know the corresponding driver
|
||||||
|
//! ** also there is no strict dependency of some functions to the driver. I might not have the XP plugin installed,
|
||||||
|
//! but need to handle XP data from the swift data store
|
||||||
|
//! If someone manages to remove this hardocded simulator information and makes it entirely flexible
|
||||||
|
//! based upon the plugin metadata feel free.
|
||||||
|
class BLACKMISC_EXPORT CSimulatorInfo : public BlackMisc::CValueObject<CSimulatorInfo>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Simulator
|
||||||
|
enum SimulatorFlags
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
FSX = 1 << 0,
|
||||||
|
FS9 = 1 << 1,
|
||||||
|
XP = 1 << 2
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(Simulator, SimulatorFlags)
|
||||||
|
|
||||||
|
//! Default constructor
|
||||||
|
CSimulatorInfo();
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
CSimulatorInfo(Simulator s);
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
CSimulatorInfo(bool fsx, bool fs9, bool xp);
|
||||||
|
|
||||||
|
//! Unspecified simulator
|
||||||
|
bool isUnspecified() const;
|
||||||
|
|
||||||
|
//! Simulator
|
||||||
|
Simulator getSimulator() const { return static_cast<Simulator>(m_simulator); }
|
||||||
|
|
||||||
|
//! Simulator
|
||||||
|
void setSimulator(Simulator s) { m_simulator = static_cast<int>(s); }
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::convertToQString
|
||||||
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
|
//! Bool flags to enum
|
||||||
|
static Simulator boolToFlag(bool fsx, bool fs9, bool xp);
|
||||||
|
|
||||||
|
//! Identifer, as provided by plugin
|
||||||
|
static Simulator identifierToFlag(const QString &identifier);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BLACK_ENABLE_TUPLE_CONVERSION(CSimulatorInfo)
|
||||||
|
int m_simulator = static_cast<int>(None);
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::CSimulatorInfo, (
|
||||||
|
attr(o.m_simulator)
|
||||||
|
))
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Simulation::CSimulatorInfo)
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(BlackMisc::Simulation::CSimulatorInfo::Simulator)
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
Reference in New Issue
Block a user