From 04906e4bfc2750b150db89e183008f26da638ecb Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Mon, 21 Apr 2014 22:44:27 +0200 Subject: [PATCH] Find and catalog all plugins in findSimulatorPlugins refs #215 --- src/blackcore/context_simulator_impl.cpp | 10 +++++----- src/blackcore/context_simulator_impl.h | 10 ++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/blackcore/context_simulator_impl.cpp b/src/blackcore/context_simulator_impl.cpp index 4842482cd..98e03b8fa 100644 --- a/src/blackcore/context_simulator_impl.cpp +++ b/src/blackcore/context_simulator_impl.cpp @@ -22,7 +22,7 @@ namespace BlackCore m_simulator(nullptr), m_updateTimer(nullptr) { m_updateTimer = new QTimer(this); - loadPlugins(); + findSimulatorPlugins(); connect(m_updateTimer, &QTimer::timeout, this, &CContextSimulator::updateOwnAircraft); connectTo(); } @@ -89,7 +89,7 @@ namespace BlackCore emit connectionChanged(value); } - void CContextSimulator::loadPlugins() + void CContextSimulator::findSimulatorPlugins() { m_pluginsDir = QDir(qApp->applicationDirPath().append("/plugins/simulator")); if (!m_pluginsDir.exists()) @@ -107,9 +107,9 @@ namespace BlackCore 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(); + CSimulatorInfo simulatorInfo = factory->getSimulatorInfo(); + qDebug() << "Found simulator plugin: " << simulatorInfo.toQString(); + m_simulatorFactories.insert(factory); break; } } diff --git a/src/blackcore/context_simulator_impl.h b/src/blackcore/context_simulator_impl.h index 312db541a..87a7c85e4 100644 --- a/src/blackcore/context_simulator_impl.h +++ b/src/blackcore/context_simulator_impl.h @@ -68,16 +68,14 @@ namespace BlackCore void setConnectionStatus(bool value); private: - /*! - * \brief Load any kind of plugins - * \todo Currently it goes through the plugins folder and creates an instance for any plugin it may find - * In case an FSX and an X-Plane are in that folder, m_simulator will always point to X-Plane in the end. - */ - void loadPlugins(); + //! \brief find and catalog all simulator plugins + void findSimulatorPlugins(); + BlackMisc::Aviation::CAircraft m_ownAircraft; BlackCore::ISimulator *m_simulator; QTimer *m_updateTimer; QDir m_pluginsDir; + QSet m_simulatorFactories; }; } // namespace BlackCore