Add methods to load and unload specific simulator plugins

refs #215
fixes #208
This commit is contained in:
Roland Winklmeier
2014-04-26 15:01:33 +02:00
parent 04906e4bfc
commit 87ff9c9ae8
8 changed files with 98 additions and 9 deletions

View File

@@ -3,11 +3,11 @@
* 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 "blacksim/fsx/fsxsimulatorsetup.h"
#include "simulator_fsx.h"
#include "simconnect_datadefinition.h"
#include "simconnect_exception.h"
#include "blacksim/fsx/fsxsimulatorsetup.h"
#include "blacksim/simulatorinfo.h"
#include <QTimer>
using namespace BlackMisc::Aviation;
@@ -25,6 +25,11 @@ namespace BlackSimPlugin
return new Fsx::CSimulatorFsx(parent);
}
BlackSim::CSimulatorInfo CSimulatorFsxFactory::getSimulatorInfo() const
{
return CSimulatorInfo::FSX();
}
CSimulatorFsx::CSimulatorFsx(QObject *parent) :
ISimulator(parent),
m_isConnected(false),
@@ -39,6 +44,11 @@ namespace BlackSimPlugin
this->m_simulatorInfo.setSimulatorSetup(setup.getSettings());
}
CSimulatorFsx::~CSimulatorFsx()
{
disconnectFrom();
}
bool CSimulatorFsx::isConnected() const
{
return m_isConnected;
@@ -65,11 +75,21 @@ namespace BlackSimPlugin
bool CSimulatorFsx::disconnectFrom()
{
SimConnect_Close(m_hSimConnect);
killTimer(m_simconnectTimerId);
m_isConnected = false;
if (!m_isConnected)
return true;
emit connectionChanged(false);
if (m_hSimConnect)
SimConnect_Close(m_hSimConnect);
if (m_simconnectTimerId)
killTimer(m_simconnectTimerId);
m_hSimConnect = nullptr;
m_simconnectTimerId = -1;
m_isConnected = false;
return true;
}

View File

@@ -35,6 +35,9 @@ namespace BlackSimPlugin
public:
//! \copydoc BlackCore::ISimulatorFactory::create()
virtual BlackCore::ISimulator *create(QObject *parent) override;
//! Simulator info
virtual BlackSim::CSimulatorInfo getSimulatorInfo() const override;
};
//! \brief SimConnect Event ID's
@@ -58,6 +61,8 @@ namespace BlackSimPlugin
//! \brief Constructor
CSimulatorFsx(QObject *parent = nullptr);
virtual ~CSimulatorFsx();
//! \copydoc ISimulator::isConnected()
virtual bool isConnected() const override;