mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Use nested namespaces (C++17 feature)
This commit is contained in:
@@ -23,131 +23,128 @@ using namespace BlackMisc::Weather;
|
||||
using namespace BlackCore;
|
||||
using namespace BlackSimPlugin::Common;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
namespace BlackSimPlugin::FsCommon
|
||||
{
|
||||
namespace FsCommon
|
||||
CSimulatorFsCommon::CSimulatorFsCommon(
|
||||
const CSimulatorPluginInfo &info,
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *renderedAircraftProvider,
|
||||
IWeatherGridProvider *weatherGridProvider,
|
||||
IClientProvider *clientProvider,
|
||||
QObject *parent) :
|
||||
CSimulatorPluginCommon(info, ownAircraftProvider, renderedAircraftProvider, weatherGridProvider, clientProvider, parent),
|
||||
m_fsuipc(new CFsuipc(this))
|
||||
{
|
||||
CSimulatorFsCommon::CSimulatorFsCommon(
|
||||
const CSimulatorPluginInfo &info,
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *renderedAircraftProvider,
|
||||
IWeatherGridProvider *weatherGridProvider,
|
||||
IClientProvider *clientProvider,
|
||||
QObject *parent) :
|
||||
CSimulatorPluginCommon(info, ownAircraftProvider, renderedAircraftProvider, weatherGridProvider, clientProvider, parent),
|
||||
m_fsuipc(new CFsuipc(this))
|
||||
CSimulatorFsCommon::registerHelp();
|
||||
}
|
||||
|
||||
CSimulatorFsCommon::~CSimulatorFsCommon() { }
|
||||
|
||||
void CSimulatorFsCommon::initSimulatorInternals()
|
||||
{
|
||||
CSimulatorPluginCommon::initSimulatorInternals();
|
||||
m_simulatorInternals.setSimulatorVersion(this->getSimulatorVersion());
|
||||
m_simulatorInternals.setValue("fscommon/fsuipc", boolToOnOff(m_useFsuipc));
|
||||
if (m_fsuipc)
|
||||
{
|
||||
CSimulatorFsCommon::registerHelp();
|
||||
const QString v(m_fsuipc->getVersion());
|
||||
if (!v.isEmpty()) { m_simulatorInternals.setValue("fscommon/fsuipcversion", v); }
|
||||
m_simulatorInternals.setValue("fscommon/fsuipcopen", boolToYesNo(m_fsuipc->isOpened()));
|
||||
}
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::parseDetails(const CSimpleCommandParser &parser)
|
||||
{
|
||||
// .driver fsuipc on|off
|
||||
if (parser.matchesPart(1, "fsuipc") && parser.hasPart(2))
|
||||
{
|
||||
const bool on = parser.toBool(2);
|
||||
const bool s = this->useFsuipc(on);
|
||||
CLogMessage(this, CLogCategories::cmdLine()).info(u"FSUIPC is '%1'") << boolToOnOff(s);
|
||||
return s;
|
||||
}
|
||||
return CSimulatorPluginCommon::parseDetails(parser);
|
||||
}
|
||||
|
||||
void CSimulatorFsCommon::reset()
|
||||
{
|
||||
m_ownAircraftUpdateCycles = 0;
|
||||
m_skipCockpitUpdateCycles = 0;
|
||||
|
||||
ISimulator::reset();
|
||||
}
|
||||
|
||||
void CSimulatorFsCommon::registerHelp()
|
||||
{
|
||||
if (CSimpleCommandParser::registered("BlackSimPlugin::FsCommon::CSimulatorFsCommon")) { return; }
|
||||
CSimpleCommandParser::registerCommand({".drv", "alias: .driver .plugin"});
|
||||
CSimpleCommandParser::registerCommand({".drv fsuipc on|off", "FSUIPC on|off if applicable"});
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::disconnectFrom()
|
||||
{
|
||||
if (m_fsuipc) { m_fsuipc->close(); }
|
||||
|
||||
// reset flags
|
||||
m_simPaused = false;
|
||||
const bool r = CSimulatorPluginCommon::disconnectFrom();
|
||||
this->emitSimulatorCombinedStatus();
|
||||
return r;
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::isFsuipcOpened() const
|
||||
{
|
||||
return m_fsuipc && m_fsuipc->isOpened();
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::useFsuipc(bool on)
|
||||
{
|
||||
if (!m_fsuipc) { return false; } // no FSUIPC available
|
||||
if (m_useFsuipc == on) { return m_useFsuipc; } // nothing changed
|
||||
m_useFsuipc = on;
|
||||
if (on)
|
||||
{
|
||||
m_useFsuipc = m_fsuipc->open();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fsuipc->close();
|
||||
}
|
||||
|
||||
CSimulatorFsCommon::~CSimulatorFsCommon() { }
|
||||
this->initSimulatorInternals(); // update internals
|
||||
return m_useFsuipc;
|
||||
}
|
||||
|
||||
void CSimulatorFsCommon::initSimulatorInternals()
|
||||
CTime CSimulatorFsCommon::getTimeSynchronizationOffset() const
|
||||
{
|
||||
return m_syncTimeOffset;
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::setTimeSynchronization(bool enable, const PhysicalQuantities::CTime &offset)
|
||||
{
|
||||
m_simTimeSynced = enable;
|
||||
m_syncTimeOffset = offset;
|
||||
return true;
|
||||
}
|
||||
|
||||
CAirportList CSimulatorFsCommon::getAirportsInRange(bool recalculateDistance) const
|
||||
{
|
||||
if (!m_airportsInRangeFromSimulator.isEmpty())
|
||||
{
|
||||
CSimulatorPluginCommon::initSimulatorInternals();
|
||||
m_simulatorInternals.setSimulatorVersion(this->getSimulatorVersion());
|
||||
m_simulatorInternals.setValue("fscommon/fsuipc", boolToOnOff(m_useFsuipc));
|
||||
if (m_fsuipc)
|
||||
{
|
||||
const QString v(m_fsuipc->getVersion());
|
||||
if (!v.isEmpty()) { m_simulatorInternals.setValue("fscommon/fsuipcversion", v); }
|
||||
m_simulatorInternals.setValue("fscommon/fsuipcopen", boolToYesNo(m_fsuipc->isOpened()));
|
||||
}
|
||||
CAirportList airports = m_airportsInRangeFromSimulator;
|
||||
if (recalculateDistance) { airports.calculcateAndUpdateRelativeDistanceAndBearing(this->getOwnAircraftPosition()); }
|
||||
return airports;
|
||||
}
|
||||
return ISimulator::getAirportsInRange(recalculateDistance);
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::parseDetails(const CSimpleCommandParser &parser)
|
||||
void CSimulatorFsCommon::onSwiftDbAirportsRead()
|
||||
{
|
||||
const CAirportList webServiceAirports = this->getWebServiceAirports();
|
||||
if (!webServiceAirports.isEmpty())
|
||||
{
|
||||
// .driver fsuipc on|off
|
||||
if (parser.matchesPart(1, "fsuipc") && parser.hasPart(2))
|
||||
{
|
||||
const bool on = parser.toBool(2);
|
||||
const bool s = this->useFsuipc(on);
|
||||
CLogMessage(this, CLogCategories::cmdLine()).info(u"FSUIPC is '%1'") << boolToOnOff(s);
|
||||
return s;
|
||||
}
|
||||
return CSimulatorPluginCommon::parseDetails(parser);
|
||||
m_airportsInRangeFromSimulator.updateMissingParts(webServiceAirports);
|
||||
}
|
||||
|
||||
void CSimulatorFsCommon::reset()
|
||||
{
|
||||
m_ownAircraftUpdateCycles = 0;
|
||||
m_skipCockpitUpdateCycles = 0;
|
||||
|
||||
ISimulator::reset();
|
||||
}
|
||||
|
||||
void CSimulatorFsCommon::registerHelp()
|
||||
{
|
||||
if (CSimpleCommandParser::registered("BlackSimPlugin::FsCommon::CSimulatorFsCommon")) { return; }
|
||||
CSimpleCommandParser::registerCommand({".drv", "alias: .driver .plugin"});
|
||||
CSimpleCommandParser::registerCommand({".drv fsuipc on|off", "FSUIPC on|off if applicable"});
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::disconnectFrom()
|
||||
{
|
||||
if (m_fsuipc) { m_fsuipc->close(); }
|
||||
|
||||
// reset flags
|
||||
m_simPaused = false;
|
||||
const bool r = CSimulatorPluginCommon::disconnectFrom();
|
||||
this->emitSimulatorCombinedStatus();
|
||||
return r;
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::isFsuipcOpened() const
|
||||
{
|
||||
return m_fsuipc && m_fsuipc->isOpened();
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::useFsuipc(bool on)
|
||||
{
|
||||
if (!m_fsuipc) { return false; } // no FSUIPC available
|
||||
if (m_useFsuipc == on) { return m_useFsuipc; } // nothing changed
|
||||
m_useFsuipc = on;
|
||||
if (on)
|
||||
{
|
||||
m_useFsuipc = m_fsuipc->open();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fsuipc->close();
|
||||
}
|
||||
|
||||
this->initSimulatorInternals(); // update internals
|
||||
return m_useFsuipc;
|
||||
}
|
||||
|
||||
CTime CSimulatorFsCommon::getTimeSynchronizationOffset() const
|
||||
{
|
||||
return m_syncTimeOffset;
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::setTimeSynchronization(bool enable, const PhysicalQuantities::CTime &offset)
|
||||
{
|
||||
m_simTimeSynced = enable;
|
||||
m_syncTimeOffset = offset;
|
||||
return true;
|
||||
}
|
||||
|
||||
CAirportList CSimulatorFsCommon::getAirportsInRange(bool recalculateDistance) const
|
||||
{
|
||||
if (!m_airportsInRangeFromSimulator.isEmpty())
|
||||
{
|
||||
CAirportList airports = m_airportsInRangeFromSimulator;
|
||||
if (recalculateDistance) { airports.calculcateAndUpdateRelativeDistanceAndBearing(this->getOwnAircraftPosition()); }
|
||||
return airports;
|
||||
}
|
||||
return ISimulator::getAirportsInRange(recalculateDistance);
|
||||
}
|
||||
|
||||
void CSimulatorFsCommon::onSwiftDbAirportsRead()
|
||||
{
|
||||
const CAirportList webServiceAirports = this->getWebServiceAirports();
|
||||
if (!webServiceAirports.isEmpty())
|
||||
{
|
||||
m_airportsInRangeFromSimulator.updateMissingParts(webServiceAirports);
|
||||
}
|
||||
ISimulator::onSwiftDbAirportsRead();
|
||||
}
|
||||
} // namespace
|
||||
ISimulator::onSwiftDbAirportsRead();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user