diff --git a/src/blackcore/context_simulator.h b/src/blackcore/context_simulator.h index 9a1a9204b..1c2855f1d 100644 --- a/src/blackcore/context_simulator.h +++ b/src/blackcore/context_simulator.h @@ -14,6 +14,7 @@ #include "blackcore/context_runtime.h" #include "blackmisc/avaircraft.h" #include "blacksim/simulatorinfo.h" +#include "blacksim/simulatorinfolist.h" #include 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; diff --git a/src/blackcore/context_simulator_impl.cpp b/src/blackcore/context_simulator_impl.cpp index 05e79a814..d1f8c785f 100644 --- a/src/blackcore/context_simulator_impl.cpp +++ b/src/blackcore/context_simulator_impl.cpp @@ -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); diff --git a/src/blackcore/context_simulator_impl.h b/src/blackcore/context_simulator_impl.h index 2d576c8d6..58ca7e132 100644 --- a/src/blackcore/context_simulator_impl.h +++ b/src/blackcore/context_simulator_impl.h @@ -10,6 +10,9 @@ #include "blackcore/context_network.h" #include "blackcore/simulator.h" +#include "blacksim/simulatorinfo.h" +#include "blacksim/simulatorinfolist.h" + #include #include @@ -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; diff --git a/src/blackcore/context_simulator_proxy.cpp b/src/blackcore/context_simulator_proxy.cpp index e733073c2..80326f7b9 100644 --- a/src/blackcore/context_simulator_proxy.cpp +++ b/src/blackcore/context_simulator_proxy.cpp @@ -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(QLatin1Literal("getAvailableSimulatorPlugins")); + } + bool CContextSimulatorProxy::isConnected() const { return m_dBusInterface->callDBusRet(QLatin1Literal("isConnected")); diff --git a/src/blackcore/context_simulator_proxy.h b/src/blackcore/context_simulator_proxy.h index 2dee782e2..e97d257cd 100644 --- a/src/blackcore/context_simulator_proxy.h +++ b/src/blackcore/context_simulator_proxy.h @@ -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; diff --git a/src/blacksim/simulatorinfolist.cpp b/src/blacksim/simulatorinfolist.cpp new file mode 100644 index 000000000..e5bb62e33 --- /dev/null +++ b/src/blacksim/simulatorinfolist.cpp @@ -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 diff --git a/src/blacksim/simulatorinfolist.h b/src/blacksim/simulatorinfolist.h new file mode 100644 index 000000000..d402c676a --- /dev/null +++ b/src/blacksim/simulatorinfolist.h @@ -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 + { + public: + CSimulatorInfoList(); + + //! \brief Construct from a base class object. + CSimulatorInfoList(const CSequence &other); + + //! \copydoc CValueObject::toQVariant + virtual QVariant toQVariant() const + { + return QVariant::fromValue(*this); + } + }; + +} + +Q_DECLARE_METATYPE(BlackSim::CSimulatorInfoList) +Q_DECLARE_METATYPE(BlackMisc::CCollection) +Q_DECLARE_METATYPE(BlackMisc::CSequence) + +#endif // BLACKSIM_SIMULATORINFOLIST_H