Find and catalog all plugins in findSimulatorPlugins

refs #215
This commit is contained in:
Roland Winklmeier
2014-04-21 22:44:27 +02:00
parent 7a2d957349
commit 04906e4bfc
2 changed files with 9 additions and 11 deletions

View File

@@ -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<ISimulatorFactory *>(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;
}
}

View File

@@ -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<ISimulatorFactory*> m_simulatorFactories;
};
} // namespace BlackCore