Add method to retrieve a list of available simulator plugins

refs #215
This commit is contained in:
Roland Winklmeier
2014-04-21 22:56:26 +02:00
parent 87ff9c9ae8
commit fd035fe5cc
7 changed files with 85 additions and 0 deletions

View File

@@ -14,6 +14,7 @@
#include "blackcore/context_runtime.h"
#include "blackmisc/avaircraft.h"
#include "blacksim/simulatorinfo.h"
#include "blacksim/simulatorinfolist.h"
#include <QObject>
namespace BlackCore
@@ -48,6 +49,9 @@ namespace BlackCore
public slots:
//! Return list of available simulator plugins
virtual BlackSim::CSimulatorInfoList getAvailableSimulatorPlugins() const = 0;
//! Returns true when simulator is connected and available
virtual bool isConnected() const = 0;

View File

@@ -33,6 +33,16 @@ namespace BlackCore
unloadSimulatorPlugin();
}
CSimulatorInfoList CContextSimulator::getAvailableSimulatorPlugins() const
{
CSimulatorInfoList simulatorPlugins;
foreach(ISimulatorFactory *factory, m_simulatorFactories)
{
simulatorPlugins.push_back(factory->getSimulatorInfo());
}
return simulatorPlugins;
}
bool CContextSimulator::isConnected() const
{
if (this->getRuntime()->isSlotLogForSimulatorEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);

View File

@@ -10,6 +10,9 @@
#include "blackcore/context_network.h"
#include "blackcore/simulator.h"
#include "blacksim/simulatorinfo.h"
#include "blacksim/simulatorinfolist.h"
#include <QTimer>
#include <QDir>
@@ -30,6 +33,9 @@ namespace BlackCore
public slots:
//! \copydoc IContextSimulator::getSimulatorPluginList()
virtual BlackSim::CSimulatorInfoList getAvailableSimulatorPlugins() const override;
//! \copydoc IContextSimulator::isConnected()
virtual bool isConnected() const override;

View File

@@ -12,6 +12,7 @@ using namespace BlackMisc;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Geo;
using namespace BlackSim;
namespace BlackCore
{
@@ -27,6 +28,11 @@ namespace BlackCore
void CContextSimulatorProxy::relaySignals(const QString &/*serviceName*/, QDBusConnection &/*connection*/)
{ }
CSimulatorInfoList CContextSimulatorProxy::getAvailableSimulatorPlugins() const
{
return m_dBusInterface->callDBusRet<CSimulatorInfoList>(QLatin1Literal("getAvailableSimulatorPlugins"));
}
bool CContextSimulatorProxy::isConnected() const
{
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isConnected"));

View File

@@ -35,6 +35,9 @@ namespace BlackCore
CContextSimulatorProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
public slots:
//! \copydoc IContextSimulator::getSimulatorPluginList()
virtual BlackSim::CSimulatorInfoList getAvailableSimulatorPlugins() const override;
//! \copydoc IContextSimulator::isConnected()
virtual bool isConnected() const override;

View File

@@ -0,0 +1,15 @@
/* Copyright (C) 2013 VATSIM Community / authors
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "simulatorinfolist.h"
namespace BlackSim
{
CSimulatorInfoList::CSimulatorInfoList()
{
}
} // namespace BlackSim

View File

@@ -0,0 +1,41 @@
/* Copyright (C) 2013 VATSIM Community / authors
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*!
\file
*/
#ifndef BLACKSIM_SIMULATORINFOLIST_H
#define BLACKSIM_SIMULATORINFOLIST_H
#include "simulatorinfo.h"
#include "blackmisc/sequence.h"
#include "blackmisc/collection.h"
namespace BlackSim
{
//! \brief Value object encapsulating a list of SimulatorInfos.
class CSimulatorInfoList : public BlackMisc::CSequence<CSimulatorInfo>
{
public:
CSimulatorInfoList();
//! \brief Construct from a base class object.
CSimulatorInfoList(const CSequence<CSimulatorInfo> &other);
//! \copydoc CValueObject::toQVariant
virtual QVariant toQVariant() const
{
return QVariant::fromValue(*this);
}
};
}
Q_DECLARE_METATYPE(BlackSim::CSimulatorInfoList)
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackSim::CSimulatorInfo>)
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackSim::CSimulatorInfo>)
#endif // BLACKSIM_SIMULATORINFOLIST_H