From c1b612e193048bd08556e53015adb672fdab2099 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 8 Dec 2015 20:07:29 +0100 Subject: [PATCH] Some fixes as follow up of refs #533 * made plugin aware functions protected * set setup for FSX ( refs #547 ) and made setup protected * removed CLogHandler::instance()->disconnect(); as discussed in slack * some formatting --- src/blackcore/simulatorcommon.cpp | 5 ++--- src/blackcore/simulatorcommon.h | 12 +++++------ src/blackmisc/pluginstorageprovider.h | 16 +++++---------- .../simulation/fsx/fsxsimulatorsetup.cpp | 1 - .../simulator/fscommon/simulatorfscommon.h | 20 +++++++++---------- src/plugins/simulator/fsx/simulatorfsx.cpp | 2 +- 6 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/blackcore/simulatorcommon.cpp b/src/blackcore/simulatorcommon.cpp index cd6abbadc..e61f2c085 100644 --- a/src/blackcore/simulatorcommon.cpp +++ b/src/blackcore/simulatorcommon.cpp @@ -33,7 +33,7 @@ namespace BlackCore CPluginStorageAware(pluginStorageProvider), m_simulatorPluginInfo(info) { - this->setObjectName("Simulator:" + info.getIdentifier()); + this->setObjectName("Simulator: " + info.getIdentifier()); // provider signals m_remoteAircraftProviderConnections.append( @@ -222,8 +222,7 @@ namespace BlackCore void CSimulatorCommon::unload() { this->disconnectFrom(); // disconnect from simulator - this->m_remoteAircraftProviderConnections.disconnectAll(); - CLogHandler::instance()->disconnect(); + this->m_remoteAircraftProviderConnections.disconnectAll(); // disconnect signals from provider } CLength CSimulatorCommon::getRenderedDistanceBoundary() const diff --git a/src/blackcore/simulatorcommon.h b/src/blackcore/simulatorcommon.h index e6eb1357b..b17e785b1 100644 --- a/src/blackcore/simulatorcommon.h +++ b/src/blackcore/simulatorcommon.h @@ -32,15 +32,13 @@ namespace BlackCore { - //! Common base class with providers, interface and some base functionality class BLACKCORE_EXPORT CSimulatorCommon : public BlackCore::ISimulator, - public BlackMisc::Simulation::COwnAircraftAware, // gain access to in memory own aircraft data + public BlackMisc::Simulation::COwnAircraftAware, // gain access to in memory own aircraft data public BlackMisc::Simulation::CRemoteAircraftAware, // gain access to in memory remote aircraft data - public BlackMisc::CPluginStorageAware // gain access to in memory plugin storage + public BlackMisc::CPluginStorageAware // gain access to in memory plugin storage { - Q_OBJECT public: @@ -138,8 +136,9 @@ namespace BlackCore bool setInitialAircraftSituation(BlackMisc::Simulation::CSimulatedAircraft &aircraft) const; protected: - IInterpolator *m_interpolator = nullptr; //!< interpolator instance - bool m_pausedSimFreezesInterpolation = false; //!< paused simulator will also pause interpolation (so AI aircraft will hold) + IInterpolator *m_interpolator = nullptr; //!< interpolator instance + bool m_pausedSimFreezesInterpolation = false; //!< paused simulator will also pause interpolation (so AI aircraft will hold) + BlackMisc::Simulation::CSimulatorSetup m_simulatorSetup; //!< setup object private: bool m_debugMessages = false; //!< Display debug messages @@ -148,7 +147,6 @@ namespace BlackCore int m_timerCounter = 0; //!< allows to calculate n seconds QTimer m_oneSecondTimer {this}; //!< timer BlackMisc::Simulation::CSimulatorPluginInfo m_simulatorPluginInfo; //!< info object - BlackMisc::Simulation::CSimulatorSetup m_simulatorSetup; //!< setup object BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered int m_maxRenderedAircraft = MaxAircraftInfinite; //!< max.rendered aircraft diff --git a/src/blackmisc/pluginstorageprovider.h b/src/blackmisc/pluginstorageprovider.h index 9acbe6d7e..c02197f3b 100644 --- a/src/blackmisc/pluginstorageprovider.h +++ b/src/blackmisc/pluginstorageprovider.h @@ -17,44 +17,39 @@ namespace BlackMisc { - //! Interface for a plugin storage provider. //! It allows plugins to store any arbitrary data which can be packed into a \sa CVariant //! Every plugin shall have its own data area. This means mulitple plugins can store //! data under the same key without overwriting each other. class IPluginStorageProvider { - public: - //! Destructor virtual ~IPluginStorageProvider() {} //! Get plugin data stored for object and identified by key - virtual CVariant getPluginData(const QObject *obj, const QString& key) const = 0; + virtual CVariant getPluginData(const QObject *obj, const QString &key) const = 0; //! Store plugin data for object, identified by key and packed into value - virtual void setPluginData(const QObject *obj, const QString& key, const CVariant &value) = 0; + virtual void setPluginData(const QObject *obj, const QString &key, const CVariant &value) = 0; }; //! Delegating class which can be directly used to access an \sa IPluginStorageProvider instance class CPluginStorageAware { - public: + protected: //! \copydoc IPluginStorageProvider::getPluginData - virtual CVariant getPluginData(const QObject *obj, const QString& key) const + virtual CVariant getPluginData(const QObject *obj, const QString &key) const { return m_pluginStorageProvider->getPluginData(obj, key); } //! \copydoc IOwnAircraftProvider::ownAircraft - virtual void setPluginData(const QObject *obj, const QString& key, const CVariant &value) + virtual void setPluginData(const QObject *obj, const QString &key, const CVariant &value) { m_pluginStorageProvider->setPluginData(obj, key, value); } - - protected: //! Constructor CPluginStorageAware(IPluginStorageProvider *pluginStorageProvider) : m_pluginStorageProvider(pluginStorageProvider) @@ -63,7 +58,6 @@ namespace BlackMisc } IPluginStorageProvider *m_pluginStorageProvider = nullptr; //!< access to object }; - } // namespace #endif diff --git a/src/blackmisc/simulation/fsx/fsxsimulatorsetup.cpp b/src/blackmisc/simulation/fsx/fsxsimulatorsetup.cpp index ff14e2fcc..e1e3a329a 100644 --- a/src/blackmisc/simulation/fsx/fsxsimulatorsetup.cpp +++ b/src/blackmisc/simulation/fsx/fsxsimulatorsetup.cpp @@ -40,7 +40,6 @@ namespace BlackMisc } } return s; - } const QString &CFsxSimulatorSetup::KeyLocalSimConnectCfgFilename() diff --git a/src/plugins/simulator/fscommon/simulatorfscommon.h b/src/plugins/simulator/fscommon/simulatorfscommon.h index 103ca6ae2..ed768769d 100644 --- a/src/plugins/simulator/fscommon/simulatorfscommon.h +++ b/src/plugins/simulator/fscommon/simulatorfscommon.h @@ -84,18 +84,18 @@ namespace BlackSimPlugin BlackMisc::IPluginStorageProvider *pluginStorageProvider, QObject *parent = nullptr); - QString simulatorDetails; //!< describes version etc. - QScopedPointer m_fsuipc; //!< FSUIPC - bool m_useFsuipc = true; //!< use FSUIPC - bool m_simPaused = false; //!< Simulator paused? - bool m_simTimeSynced = false; //!< Time synchronized? - BlackMisc::PhysicalQuantities::CTime m_syncTimeOffset; //!< time offset - BlackMisc::Aviation::CAirportList m_airportsInRange; //!< aiports in range of own aircraft + QString simulatorDetails; //!< describes version etc. + QScopedPointer m_fsuipc; //!< FSUIPC + bool m_useFsuipc = true; //!< use FSUIPC + bool m_simPaused = false; //!< Simulator paused? + bool m_simTimeSynced = false; //!< Time synchronized? + BlackMisc::PhysicalQuantities::CTime m_syncTimeOffset; //!< time offset + BlackMisc::Aviation::CAirportList m_airportsInRange; //!< aiports in range of own aircraft // cockpit as set in SIM - BlackMisc::Aviation::CComSystem m_simCom1; //!< cockpit COM1 state in simulator - BlackMisc::Aviation::CComSystem m_simCom2; //!< cockpit COM2 state in simulator - BlackMisc::Aviation::CTransponder m_simTransponder; //!< cockpit xpdr state in simulator + BlackMisc::Aviation::CComSystem m_simCom1; //!< cockpit COM1 state in simulator + BlackMisc::Aviation::CComSystem m_simCom2; //!< cockpit COM2 state in simulator + BlackMisc::Aviation::CTransponder m_simTransponder; //!< cockpit xpdr state in simulator // parser / matcher std::unique_ptr m_aircraftCfgParser; //!< aircraft.cfg parser diff --git a/src/plugins/simulator/fsx/simulatorfsx.cpp b/src/plugins/simulator/fsx/simulatorfsx.cpp index 1030b7269..8197db409 100644 --- a/src/plugins/simulator/fsx/simulatorfsx.cpp +++ b/src/plugins/simulator/fsx/simulatorfsx.cpp @@ -48,7 +48,7 @@ namespace BlackSimPlugin { Q_ASSERT(ownAircraftProvider); Q_ASSERT(remoteAircraftProvider); - CSimulatorSetup setup(CFsxSimulatorSetup::getInitialSetup()); + this->m_simulatorSetup = CFsxSimulatorSetup::getInitialSetup(); m_useFsuipc = false; // do not use FSUIPC at the moment with FSX this->m_interpolator = new CInterpolatorLinear(remoteAircraftProvider, this);