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
This commit is contained in:
Klaus Basan
2015-12-08 20:07:29 +01:00
parent 2a10aa93ec
commit c1b612e193
6 changed files with 23 additions and 33 deletions

View File

@@ -33,7 +33,7 @@ namespace BlackCore
CPluginStorageAware(pluginStorageProvider), CPluginStorageAware(pluginStorageProvider),
m_simulatorPluginInfo(info) m_simulatorPluginInfo(info)
{ {
this->setObjectName("Simulator:" + info.getIdentifier()); this->setObjectName("Simulator: " + info.getIdentifier());
// provider signals // provider signals
m_remoteAircraftProviderConnections.append( m_remoteAircraftProviderConnections.append(
@@ -222,8 +222,7 @@ namespace BlackCore
void CSimulatorCommon::unload() void CSimulatorCommon::unload()
{ {
this->disconnectFrom(); // disconnect from simulator this->disconnectFrom(); // disconnect from simulator
this->m_remoteAircraftProviderConnections.disconnectAll(); this->m_remoteAircraftProviderConnections.disconnectAll(); // disconnect signals from provider
CLogHandler::instance()->disconnect();
} }
CLength CSimulatorCommon::getRenderedDistanceBoundary() const CLength CSimulatorCommon::getRenderedDistanceBoundary() const

View File

@@ -32,15 +32,13 @@
namespace BlackCore namespace BlackCore
{ {
//! Common base class with providers, interface and some base functionality //! Common base class with providers, interface and some base functionality
class BLACKCORE_EXPORT CSimulatorCommon : class BLACKCORE_EXPORT CSimulatorCommon :
public BlackCore::ISimulator, 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::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 Q_OBJECT
public: public:
@@ -138,8 +136,9 @@ namespace BlackCore
bool setInitialAircraftSituation(BlackMisc::Simulation::CSimulatedAircraft &aircraft) const; bool setInitialAircraftSituation(BlackMisc::Simulation::CSimulatedAircraft &aircraft) const;
protected: protected:
IInterpolator *m_interpolator = nullptr; //!< interpolator instance IInterpolator *m_interpolator = nullptr; //!< interpolator instance
bool m_pausedSimFreezesInterpolation = false; //!< paused simulator will also pause interpolation (so AI aircraft will hold) bool m_pausedSimFreezesInterpolation = false; //!< paused simulator will also pause interpolation (so AI aircraft will hold)
BlackMisc::Simulation::CSimulatorSetup m_simulatorSetup; //!< setup object
private: private:
bool m_debugMessages = false; //!< Display debug messages bool m_debugMessages = false; //!< Display debug messages
@@ -148,7 +147,6 @@ namespace BlackCore
int m_timerCounter = 0; //!< allows to calculate n seconds int m_timerCounter = 0; //!< allows to calculate n seconds
QTimer m_oneSecondTimer {this}; //!< timer QTimer m_oneSecondTimer {this}; //!< timer
BlackMisc::Simulation::CSimulatorPluginInfo m_simulatorPluginInfo; //!< info object 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::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored
BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered
int m_maxRenderedAircraft = MaxAircraftInfinite; //!< max.rendered aircraft int m_maxRenderedAircraft = MaxAircraftInfinite; //!< max.rendered aircraft

View File

@@ -17,44 +17,39 @@
namespace BlackMisc namespace BlackMisc
{ {
//! Interface for a plugin storage provider. //! Interface for a plugin storage provider.
//! It allows plugins to store any arbitrary data which can be packed into a \sa CVariant //! 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 //! Every plugin shall have its own data area. This means mulitple plugins can store
//! data under the same key without overwriting each other. //! data under the same key without overwriting each other.
class IPluginStorageProvider class IPluginStorageProvider
{ {
public: public:
//! Destructor //! Destructor
virtual ~IPluginStorageProvider() {} virtual ~IPluginStorageProvider() {}
//! Get plugin data stored for object and identified by key //! 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 //! 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 //! Delegating class which can be directly used to access an \sa IPluginStorageProvider instance
class CPluginStorageAware class CPluginStorageAware
{ {
public: protected:
//! \copydoc IPluginStorageProvider::getPluginData //! \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); return m_pluginStorageProvider->getPluginData(obj, key);
} }
//! \copydoc IOwnAircraftProvider::ownAircraft //! \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); m_pluginStorageProvider->setPluginData(obj, key, value);
} }
protected:
//! Constructor //! Constructor
CPluginStorageAware(IPluginStorageProvider *pluginStorageProvider) : CPluginStorageAware(IPluginStorageProvider *pluginStorageProvider) :
m_pluginStorageProvider(pluginStorageProvider) m_pluginStorageProvider(pluginStorageProvider)
@@ -63,7 +58,6 @@ namespace BlackMisc
} }
IPluginStorageProvider *m_pluginStorageProvider = nullptr; //!< access to object IPluginStorageProvider *m_pluginStorageProvider = nullptr; //!< access to object
}; };
} // namespace } // namespace
#endif #endif

View File

@@ -40,7 +40,6 @@ namespace BlackMisc
} }
} }
return s; return s;
} }
const QString &CFsxSimulatorSetup::KeyLocalSimConnectCfgFilename() const QString &CFsxSimulatorSetup::KeyLocalSimConnectCfgFilename()

View File

@@ -84,18 +84,18 @@ namespace BlackSimPlugin
BlackMisc::IPluginStorageProvider *pluginStorageProvider, BlackMisc::IPluginStorageProvider *pluginStorageProvider,
QObject *parent = nullptr); QObject *parent = nullptr);
QString simulatorDetails; //!< describes version etc. QString simulatorDetails; //!< describes version etc.
QScopedPointer<FsCommon::CFsuipc> m_fsuipc; //!< FSUIPC QScopedPointer<FsCommon::CFsuipc> m_fsuipc; //!< FSUIPC
bool m_useFsuipc = true; //!< use FSUIPC bool m_useFsuipc = true; //!< use FSUIPC
bool m_simPaused = false; //!< Simulator paused? bool m_simPaused = false; //!< Simulator paused?
bool m_simTimeSynced = false; //!< Time synchronized? bool m_simTimeSynced = false; //!< Time synchronized?
BlackMisc::PhysicalQuantities::CTime m_syncTimeOffset; //!< time offset BlackMisc::PhysicalQuantities::CTime m_syncTimeOffset; //!< time offset
BlackMisc::Aviation::CAirportList m_airportsInRange; //!< aiports in range of own aircraft BlackMisc::Aviation::CAirportList m_airportsInRange; //!< aiports in range of own aircraft
// cockpit as set in SIM // cockpit as set in SIM
BlackMisc::Aviation::CComSystem m_simCom1; //!< cockpit COM1 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::CComSystem m_simCom2; //!< cockpit COM2 state in simulator
BlackMisc::Aviation::CTransponder m_simTransponder; //!< cockpit xpdr state in simulator BlackMisc::Aviation::CTransponder m_simTransponder; //!< cockpit xpdr state in simulator
// parser / matcher // parser / matcher
std::unique_ptr<BlackMisc::Simulation::FsCommon::CAircraftCfgParser> m_aircraftCfgParser; //!< aircraft.cfg parser std::unique_ptr<BlackMisc::Simulation::FsCommon::CAircraftCfgParser> m_aircraftCfgParser; //!< aircraft.cfg parser

View File

@@ -48,7 +48,7 @@ namespace BlackSimPlugin
{ {
Q_ASSERT(ownAircraftProvider); Q_ASSERT(ownAircraftProvider);
Q_ASSERT(remoteAircraftProvider); Q_ASSERT(remoteAircraftProvider);
CSimulatorSetup setup(CFsxSimulatorSetup::getInitialSetup()); this->m_simulatorSetup = CFsxSimulatorSetup::getInitialSetup();
m_useFsuipc = false; // do not use FSUIPC at the moment with FSX m_useFsuipc = false; // do not use FSUIPC at the moment with FSX
this->m_interpolator = new CInterpolatorLinear(remoteAircraftProvider, this); this->m_interpolator = new CInterpolatorLinear(remoteAircraftProvider, this);