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),
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

View File

@@ -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

View File

@@ -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

View File

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

View File

@@ -84,18 +84,18 @@ namespace BlackSimPlugin
BlackMisc::IPluginStorageProvider *pluginStorageProvider,
QObject *parent = nullptr);
QString simulatorDetails; //!< describes version etc.
QScopedPointer<FsCommon::CFsuipc> 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<FsCommon::CFsuipc> 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<BlackMisc::Simulation::FsCommon::CAircraftCfgParser> m_aircraftCfgParser; //!< aircraft.cfg parser

View File

@@ -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);