mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 05:55:33 +08:00
Ref T259, Ref T243 adjusted providers to use common base classes
This commit is contained in:
@@ -190,7 +190,7 @@ namespace BlackCore
|
||||
// remark for simulation snapshot is used when there are restrictions
|
||||
// nevertheless we calculate all the time as the snapshot could be used in other scenarios
|
||||
|
||||
CSimulatedAircraftList aircraftInRange(getAircraftInRange()); // thread safe copy from provider
|
||||
CSimulatedAircraftList aircraftInRange(this->getAircraftInRange()); // thread safe copy from provider
|
||||
CAirspaceAircraftSnapshot snapshot(
|
||||
aircraftInRange,
|
||||
restricted, enabled,
|
||||
|
||||
@@ -121,6 +121,9 @@ namespace BlackCore
|
||||
virtual BlackMisc::CStatusMessageList getReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
//! @}
|
||||
|
||||
//! \copydoc BlackMisc::IProvider::asQObject
|
||||
virtual QObject *asQObject() override { return this; }
|
||||
|
||||
//! Returns the list of users we know about
|
||||
BlackMisc::Network::CUserList getUsers() const;
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ namespace BlackCore
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTOWNAIRCRAFT_INTERFACENAME)
|
||||
Q_INTERFACES(BlackMisc::Simulation::IOwnAircraftProvider)
|
||||
Q_INTERFACES(BlackMisc::IProvider)
|
||||
friend class BlackCore::CCoreFacade;
|
||||
friend class IContextOwnAircraft;
|
||||
|
||||
@@ -106,6 +107,9 @@ namespace BlackCore
|
||||
//! \ingroup ownaircraftprovider
|
||||
virtual bool updateOwnParts(const BlackMisc::Aviation::CAircraftParts &parts) override;
|
||||
|
||||
//! \copydoc BlackMisc::IProvider::asQObject
|
||||
virtual QObject *asQObject() override { return this; }
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextOwnAircraft::getOwnAircraft()
|
||||
//! \ingroup ownaircraftprovider
|
||||
|
||||
@@ -34,11 +34,6 @@ namespace BlackCore
|
||||
return status;
|
||||
}
|
||||
|
||||
const CSimulatorInfo &ISimulator::getSimulatorInfo() const
|
||||
{
|
||||
return this->getSimulatorPluginInfo().getSimulatorInfo();
|
||||
}
|
||||
|
||||
void ISimulator::registerHelp()
|
||||
{
|
||||
if (CSimpleCommandParser::registered("BlackCore::ISimulator")) { return; }
|
||||
@@ -61,11 +56,14 @@ namespace BlackCore
|
||||
return s.join(", ");
|
||||
}
|
||||
|
||||
ISimulator::ISimulator(IOwnAircraftProvider *ownAircraftProvider, IRemoteAircraftProvider *remoteAircraftProvider, IWeatherGridProvider *weatherGridProvider, QObject *parent) :
|
||||
ISimulator::ISimulator(
|
||||
const CSimulatorPluginInfo &pluginInfo, IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *remoteAircraftProvider, IWeatherGridProvider *weatherGridProvider, QObject *parent) :
|
||||
QObject(parent),
|
||||
COwnAircraftAware(ownAircraftProvider),
|
||||
CRemoteAircraftAware(remoteAircraftProvider),
|
||||
CWeatherGridAware(weatherGridProvider),
|
||||
ISimulationEnvironmentProvider(pluginInfo),
|
||||
CIdentifiable(this)
|
||||
{
|
||||
ISimulator::registerHelp();
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace BlackCore
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(BlackMisc::Simulation::ISimulationEnvironmentProvider)
|
||||
Q_INTERFACES(BlackMisc::IProvider)
|
||||
|
||||
public:
|
||||
//! ISimulator status
|
||||
@@ -83,12 +84,6 @@ namespace BlackCore
|
||||
//! Is time synchronization on?
|
||||
virtual bool isTimeSynchronized() const = 0;
|
||||
|
||||
//! Get the simulator info (metadata of plugin)
|
||||
virtual const BlackMisc::Simulation::CSimulatorPluginInfo &getSimulatorPluginInfo() const = 0;
|
||||
|
||||
//! Get simulator info (default implementation)
|
||||
const BlackMisc::Simulation::CSimulatorInfo &getSimulatorInfo() const;
|
||||
|
||||
//! Get the setup (simulator environemnt)
|
||||
virtual const BlackMisc::Simulation::CSimulatorInternals &getSimulatorInternals() const = 0;
|
||||
|
||||
@@ -98,9 +93,6 @@ namespace BlackCore
|
||||
//! Disconnect from simulator
|
||||
virtual bool disconnectFrom() = 0;
|
||||
|
||||
//! Get default aircraft model
|
||||
virtual BlackMisc::Simulation::CAircraftModel getDefaultModel() const = 0;
|
||||
|
||||
//! Logically add a new aircraft. Depending on max. aircraft, enabled status etc.
|
||||
//! it will physically added to the simulator.
|
||||
//! \sa physicallyAddRemoteAircraft
|
||||
@@ -184,6 +176,9 @@ namespace BlackCore
|
||||
//! Is overall (swift) application shutting down
|
||||
virtual bool isShuttingDown() const = 0;
|
||||
|
||||
//! \copydoc BlackMisc::IProvider::asQObject
|
||||
virtual QObject *asQObject() override { return this; }
|
||||
|
||||
//! Set interpolation mode, empty callsign applies to all know callsigns
|
||||
//! \return Returns true if the mode changed, otherwise false. Note that some implementations always return true.
|
||||
virtual bool setInterpolatorMode(BlackMisc::Simulation::CInterpolatorMulti::Mode mode, const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
||||
@@ -231,7 +226,8 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Default constructor
|
||||
ISimulator(BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
|
||||
ISimulator(const BlackMisc::Simulation::CSimulatorPluginInfo &pluginInfo,
|
||||
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
|
||||
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
@@ -52,15 +52,14 @@ namespace BlackCore
|
||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
IWeatherGridProvider *weatherGridProvider,
|
||||
QObject *parent)
|
||||
: ISimulator(ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, parent),
|
||||
m_simulatorPluginInfo(info)
|
||||
: ISimulator(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, parent)
|
||||
{
|
||||
this->setObjectName("Simulator: " + info.getIdentifier());
|
||||
CSimulatorCommon::registerHelp();
|
||||
|
||||
// provider signals, hook up with remote aircraft provider
|
||||
m_remoteAircraftProviderConnections.append(
|
||||
m_remoteAircraftProvider->connectRemoteAircraftProviderSignals(
|
||||
CRemoteAircraftAware::provider()->connectRemoteAircraftProviderSignals(
|
||||
this, // receiver must match object in bind
|
||||
std::bind(&CSimulatorCommon::rapOnRemoteProviderAddedAircraftSituation, this, std::placeholders::_1),
|
||||
std::bind(&CSimulatorCommon::rapOnRemoteProviderAddedAircraftParts, this, std::placeholders::_1, std::placeholders::_2),
|
||||
@@ -82,7 +81,7 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
// info
|
||||
CLogMessage(this).info("Initialized simulator driver: '%1'") << m_simulatorPluginInfo.toQString();
|
||||
CLogMessage(this).info("Initialized simulator driver: '%1'") << this->getSimulatorInfo().toQString();
|
||||
}
|
||||
|
||||
CSimulatorCommon::~CSimulatorCommon()
|
||||
@@ -125,12 +124,6 @@ namespace BlackCore
|
||||
return false;
|
||||
}
|
||||
|
||||
void CSimulatorCommon::setNewPluginInfo(const CSimulatorPluginInfo &info, const CAircraftModel &defaultModel)
|
||||
{
|
||||
m_simulatorPluginInfo = info;
|
||||
m_defaultModel = defaultModel;
|
||||
}
|
||||
|
||||
int CSimulatorCommon::maxAirportsInRange() const
|
||||
{
|
||||
// might change in future or become a setting or such
|
||||
@@ -302,16 +295,6 @@ namespace BlackCore
|
||||
// void, can be overridden in specialized drivers
|
||||
}
|
||||
|
||||
CAircraftModel CSimulatorCommon::getDefaultModel() const
|
||||
{
|
||||
return m_defaultModel;
|
||||
}
|
||||
|
||||
const CSimulatorPluginInfo &CSimulatorCommon::getSimulatorPluginInfo() const
|
||||
{
|
||||
return m_simulatorPluginInfo;
|
||||
}
|
||||
|
||||
const CSimulatorInternals &CSimulatorCommon::getSimulatorInternals() const
|
||||
{
|
||||
return m_simulatorInternals;
|
||||
|
||||
@@ -55,7 +55,8 @@ namespace BlackMisc
|
||||
namespace BlackCore
|
||||
{
|
||||
//! Common base class with providers, interface and some base functionality
|
||||
class BLACKCORE_EXPORT CSimulatorCommon : public BlackCore::ISimulator {
|
||||
class BLACKCORE_EXPORT CSimulatorCommon : public ISimulator
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@@ -66,11 +67,9 @@ namespace BlackCore
|
||||
virtual ~CSimulatorCommon();
|
||||
|
||||
// --------- ISimulator implementations ------------
|
||||
virtual BlackMisc::Simulation::CAircraftModel getDefaultModel() const override;
|
||||
virtual void setInterpolationAndRenderingSetup(const BlackMisc::Simulation::CInterpolationAndRenderingSetup &setup) override;
|
||||
virtual BlackMisc::Simulation::CInterpolationAndRenderingSetup getInterpolationAndRenderingSetup() const override;
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
virtual const BlackMisc::Simulation::CSimulatorPluginInfo &getSimulatorPluginInfo() const override;
|
||||
virtual const BlackMisc::Simulation::CSimulatorInternals &getSimulatorInternals() const override;
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
virtual void setWeatherActivated(bool activated) override;
|
||||
@@ -154,10 +153,6 @@ namespace BlackCore
|
||||
virtual void onRemoteProviderAddedAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts);
|
||||
//! @}
|
||||
|
||||
//! New plugin info
|
||||
//! \remark normally only used by
|
||||
void setNewPluginInfo(const BlackMisc::Simulation::CSimulatorPluginInfo &info, const BlackMisc::Simulation::CAircraftModel &defaultModel);
|
||||
|
||||
//! Max.airports in range
|
||||
int maxAirportsInRange() const;
|
||||
|
||||
@@ -222,8 +217,7 @@ namespace BlackCore
|
||||
int m_statsUpdateAircraftCountMs = 0; //!< statistics update count
|
||||
qint64 m_statsUpdateAircraftTimeTotalMs = 0; //!< statistics update time
|
||||
qint64 m_statsUpdateAircraftTimeAvgMs = 0; //!< statistics update time
|
||||
BlackMisc::Simulation::CAircraftModel m_defaultModel; //!< default model
|
||||
BlackMisc::Simulation::CSimulatorInternals m_simulatorInternals; //!< setup object
|
||||
BlackMisc::Simulation::CSimulatorInternals m_simulatorInternals; //!< setup object
|
||||
BlackMisc::Simulation::CInterpolationLogger m_interpolationLogger; //!< log interpolation
|
||||
|
||||
// setup for logging etc.
|
||||
@@ -260,10 +254,9 @@ namespace BlackCore
|
||||
qint64 m_highlightEndTimeMsEpoch = 0; //!< end highlighting
|
||||
int m_timerCounter = 0; //!< allows to calculate n seconds
|
||||
QTimer m_oneSecondTimer; //!< multi purpose timer
|
||||
BlackMisc::Simulation::CSimulatorPluginInfo m_simulatorPluginInfo; //!< info object
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored
|
||||
BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered
|
||||
BlackMisc::CConnectionGuard m_remoteAircraftProviderConnections; //!< connected signal/slots
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored
|
||||
BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered
|
||||
BlackMisc::CConnectionGuard m_remoteAircraftProviderConnections; //!< connected signal/slots
|
||||
|
||||
// statistics values of how often those functions are called
|
||||
// those are the added counters, overflow will not be an issue here (discussed in T171 review)
|
||||
|
||||
Reference in New Issue
Block a user