From d9b5ce54f1a46897ac586fc08b491dbf5ae2bfed Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 14 Apr 2014 12:21:55 +0200 Subject: [PATCH] refs #207, added SimulatorInfo to context --- src/blackcore/context_simulator.h | 4 ++++ src/blackcore/context_simulator_impl.cpp | 12 ++++++++++-- src/blackcore/context_simulator_impl.h | 3 +++ src/blackcore/context_simulator_proxy.cpp | 7 +++++-- src/blackcore/context_simulator_proxy.h | 3 +++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/blackcore/context_simulator.h b/src/blackcore/context_simulator.h index 5bf6bf454..3bf8ca647 100644 --- a/src/blackcore/context_simulator.h +++ b/src/blackcore/context_simulator.h @@ -13,6 +13,7 @@ #include "blackcore/dbus_server.h" #include "blackcore/context_runtime.h" #include "blackmisc/avaircraft.h" +#include "blacksim/simulatorinfo.h" #include namespace BlackCore @@ -53,6 +54,9 @@ namespace BlackCore //! Get user aircraft value object virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const = 0; + //! Simulator info + virtual BlackSim::CSimulatorInfo getSimulatorInfo() const = 0; + protected: //! \brief Constructor IContextSimulator(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {} diff --git a/src/blackcore/context_simulator_impl.cpp b/src/blackcore/context_simulator_impl.cpp index 1fc19def5..e26c22cd6 100644 --- a/src/blackcore/context_simulator_impl.cpp +++ b/src/blackcore/context_simulator_impl.cpp @@ -41,6 +41,13 @@ namespace BlackCore return m_ownAircraft; } + BlackSim::CSimulatorInfo CContextSimulator::getSimulatorInfo() const + { + if (this->getRuntime()->isSlotLogForSimulatorEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO); + if (!m_simulator) return BlackSim::CSimulatorInfo::UnspecifiedSim(); + return m_simulator->getSimulatorInfo(); + } + void CContextSimulator::updateOwnAircraft() { m_ownAircraft = m_simulator->getOwnAircraft(); @@ -72,11 +79,12 @@ namespace BlackCore QObject *plugin = loader.instance(); if (plugin) { - ISimulatorFactory *factory = qobject_cast(plugin); - if(factory) + ISimulatorFactory *factory = qobject_cast(plugin); + if (factory) { m_simulator = factory->create(this); connect(m_simulator, SIGNAL(connectionChanged(bool)), this, SLOT(setConnectionStatus(bool))); + qDebug() << "Simulator plugin:" << m_simulator->getSimulatorInfo().toQString(); break; } } diff --git a/src/blackcore/context_simulator_impl.h b/src/blackcore/context_simulator_impl.h index 15f22e462..91d70d0df 100644 --- a/src/blackcore/context_simulator_impl.h +++ b/src/blackcore/context_simulator_impl.h @@ -35,6 +35,9 @@ namespace BlackCore //! \copydoc IContextSimulator::getOwnAircraft() virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const override; + //! \copydoc IContextSimulator::getSimulatorInfo() + virtual BlackSim::CSimulatorInfo getSimulatorInfo() const override; + protected: //! \brief Constructor CContextSimulator(CRuntimeConfig::ContextMode, CRuntime *runtime); diff --git a/src/blackcore/context_simulator_proxy.cpp b/src/blackcore/context_simulator_proxy.cpp index 3cedfb22d..9bf1677ae 100644 --- a/src/blackcore/context_simulator_proxy.cpp +++ b/src/blackcore/context_simulator_proxy.cpp @@ -16,7 +16,6 @@ using namespace BlackMisc::Geo; namespace BlackCore { - // Constructor for DBus CContextSimulatorProxy::CContextSimulatorProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextSimulator(mode, runtime), m_dBusInterface(nullptr) { this->m_dBusInterface = new BlackMisc::CGenericDBusInterface( @@ -25,7 +24,6 @@ namespace BlackCore this->relaySignals(serviceName, connection); } - // Workaround for signals, not working without, but why? void CContextSimulatorProxy::relaySignals(const QString &/*serviceName*/, QDBusConnection &/*connection*/) { } @@ -39,4 +37,9 @@ namespace BlackCore return m_dBusInterface->callDBusRet(QLatin1Literal("getOwnAircraft")); } + BlackSim::CSimulatorInfo CContextSimulatorProxy::getSimulatorInfo() const + { + return m_dBusInterface->callDBusRet(QLatin1Literal("getSimulatorInfo")); + } + } // namespace BlackCore diff --git a/src/blackcore/context_simulator_proxy.h b/src/blackcore/context_simulator_proxy.h index 893637b62..9711eb6da 100644 --- a/src/blackcore/context_simulator_proxy.h +++ b/src/blackcore/context_simulator_proxy.h @@ -40,6 +40,9 @@ namespace BlackCore //! \copydoc IContextSimulator::getOwnAircraft() virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const override; + + //! \copydoc IContextSimulator::getSimulatorInfo + virtual BlackSim::CSimulatorInfo getSimulatorInfo() const override; }; } // namespace BlackCore