mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
refs #487 Finish IAircraftModelLoader::createModelLoader factory method
This commit is contained in:
committed by
Mathew Sutcliffe
parent
35cb4e2067
commit
94901b7846
@@ -83,8 +83,7 @@ namespace BlackGui
|
|||||||
// unload old
|
// unload old
|
||||||
if (this->m_modelLoader) { this->m_modelLoader->cancelLoading(); }
|
if (this->m_modelLoader) { this->m_modelLoader->cancelLoading(); }
|
||||||
|
|
||||||
//! \todo appropriate model loader or loaders via factory?
|
this->m_modelLoader = IAircraftModelLoader::createModelLoader(simInfo);
|
||||||
this->m_modelLoader.reset(IAircraftModelLoader::createModelLoader(simInfo));
|
|
||||||
if (!this->m_modelLoader || !this->m_modelLoader->supportsSimulator(simInfo))
|
if (!this->m_modelLoader || !this->m_modelLoader->supportsSimulator(simInfo))
|
||||||
{
|
{
|
||||||
CLogMessage(this).error("Failed to init model loader %1") << simInfo.toQString();
|
CLogMessage(this).error("Failed to init model loader %1") << simInfo.toQString();
|
||||||
@@ -93,7 +92,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool c = connect(this->m_modelLoader.data(), &IAircraftModelLoader::loadingFinished, this, &CDbMappingComponent::ps_onInstalledModelLoadingFinished);
|
bool c = connect(this->m_modelLoader.get(), &IAircraftModelLoader::loadingFinished, this, &CDbMappingComponent::ps_onInstalledModelLoadingFinished);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect for model loader");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect for model loader");
|
||||||
Q_UNUSED(c);
|
Q_UNUSED(c);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ namespace BlackGui
|
|||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CDbMappingComponent> ui;
|
QScopedPointer<Ui::CDbMappingComponent> ui;
|
||||||
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader;
|
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader;
|
||||||
QScopedPointer<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader;
|
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader;
|
||||||
bool m_withVPilot = false;
|
bool m_withVPilot = false;
|
||||||
|
|
||||||
//! Consolidated aircraft model
|
//! Consolidated aircraft model
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#include "aircraftmodelloader.h"
|
#include "aircraftmodelloader.h"
|
||||||
#include "blackmisc/simulation/fscommon/aircraftcfgparser.h"
|
#include "blackmisc/simulation/fscommon/aircraftcfgparser.h"
|
||||||
|
|
||||||
|
using namespace BlackMisc::Simulation::FsCommon;
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
namespace Simulation
|
namespace Simulation
|
||||||
@@ -48,13 +50,17 @@ namespace BlackMisc
|
|||||||
this->cancelLoading();
|
this->cancelLoading();
|
||||||
}
|
}
|
||||||
|
|
||||||
IAircraftModelLoader *IAircraftModelLoader::createModelLoader(const CSimulatorInfo &info)
|
std::unique_ptr<IAircraftModelLoader> IAircraftModelLoader::createModelLoader(const CSimulatorInfo &simInfo)
|
||||||
{
|
{
|
||||||
//! \todo hack, remove later and replace by factory
|
if (simInfo.xplane())
|
||||||
IAircraftModelLoader *ml = BlackMisc::Simulation::FsCommon::CAircraftCfgParser::createModelLoader(info);
|
{
|
||||||
if (ml) { return ml; }
|
Q_ASSERT_X(false, Q_FUNC_INFO, "Not yet implemented.");
|
||||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No model model loader for simulator");
|
return nullptr;
|
||||||
return nullptr;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return CAircraftCfgParser::createModelLoader(simInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ namespace BlackMisc
|
|||||||
void gracefulShutdown();
|
void gracefulShutdown();
|
||||||
|
|
||||||
//! Create a loader
|
//! Create a loader
|
||||||
//! \todo just a hack, needs to be replaced
|
static std::unique_ptr<IAircraftModelLoader> createModelLoader(const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||||
static IAircraftModelLoader *createModelLoader(const BlackMisc::Simulation::CSimulatorInfo &info);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Parsing is finished
|
//! Parsing is finished
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "aircraftcfgparser.h"
|
#include "aircraftcfgparser.h"
|
||||||
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
#include "blackmisc/simulation/fscommon/fscommonutil.h"
|
#include "blackmisc/simulation/fscommon/fscommonutil.h"
|
||||||
#include "blackmisc/predicates.h"
|
#include "blackmisc/predicates.h"
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
@@ -31,33 +32,31 @@ namespace BlackMisc
|
|||||||
m_excludedDirectories(exludes)
|
m_excludedDirectories(exludes)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
CAircraftCfgParser *CAircraftCfgParser::createModelLoader(const CSimulatorInfo &simInfo)
|
std::unique_ptr<CAircraftCfgParser> CAircraftCfgParser::createModelLoader(const CSimulatorInfo &simInfo)
|
||||||
{
|
{
|
||||||
if (simInfo.fsx())
|
if (simInfo.fsx())
|
||||||
{
|
{
|
||||||
return new CAircraftCfgParser(
|
return make_unique<CAircraftCfgParser>(
|
||||||
CSimulatorInfo(CSimulatorInfo::FSX),
|
CSimulatorInfo(CSimulatorInfo::FSX),
|
||||||
CFsCommonUtil::fsxSimObjectsDir(),
|
CFsCommonUtil::fsxSimObjectsDir(),
|
||||||
CFsCommonUtil::fsxSimObjectsExcludeDirectories());
|
CFsCommonUtil::fsxSimObjectsExcludeDirectories());
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (simInfo.fs9())
|
else if (simInfo.fs9())
|
||||||
{
|
{
|
||||||
return new CAircraftCfgParser(
|
return make_unique<CAircraftCfgParser>(
|
||||||
CSimulatorInfo(CSimulatorInfo::FS9),
|
CSimulatorInfo(CSimulatorInfo::FS9),
|
||||||
CFsCommonUtil::fs9AircraftDir(),
|
CFsCommonUtil::fs9AircraftDir(),
|
||||||
CFsCommonUtil::fs9AircraftObjectsExcludeDirectories());
|
CFsCommonUtil::fs9AircraftObjectsExcludeDirectories());
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (simInfo.p3d())
|
else if (simInfo.p3d())
|
||||||
{
|
{
|
||||||
return new CAircraftCfgParser(
|
return make_unique<CAircraftCfgParser>(
|
||||||
CSimulatorInfo(CSimulatorInfo::P3D),
|
CSimulatorInfo(CSimulatorInfo::P3D),
|
||||||
CFsCommonUtil::p3dSimObjectsDir(),
|
CFsCommonUtil::p3dSimObjectsDir(),
|
||||||
CFsCommonUtil::p3dSimObjectsExcludeDirectories());
|
CFsCommonUtil::p3dSimObjectsExcludeDirectories());
|
||||||
}
|
}
|
||||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Illegal simulator info");
|
Q_ASSERT_X(false, Q_FUNC_INFO, "Illegal simulator info");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftCfgParser::~CAircraftCfgParser()
|
CAircraftCfgParser::~CAircraftCfgParser()
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace BlackMisc
|
|||||||
virtual BlackMisc::Simulation::CAircraftModelList getAircraftModels() const override;
|
virtual BlackMisc::Simulation::CAircraftModelList getAircraftModels() const override;
|
||||||
|
|
||||||
//! Create an parser object for given simulator
|
//! Create an parser object for given simulator
|
||||||
static CAircraftCfgParser *createModelLoader(const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
static std::unique_ptr<CAircraftCfgParser> createModelLoader(const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Parsed or injected entires
|
//! Parsed or injected entires
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace BlackSimPlugin
|
|||||||
auto modelMappingsProvider = std::unique_ptr<IModelMappingsProvider> { BlackMisc::make_unique<CModelMappingsProviderVPilot>(true) };
|
auto modelMappingsProvider = std::unique_ptr<IModelMappingsProvider> { BlackMisc::make_unique<CModelMappingsProviderVPilot>(true) };
|
||||||
m_modelMatcher.setModelMappingProvider(std::move(modelMappingsProvider));
|
m_modelMatcher.setModelMappingProvider(std::move(modelMappingsProvider));
|
||||||
|
|
||||||
bool c = connect(m_aircraftCfgParser.data(), &CAircraftCfgParser::loadingFinished, this, &CSimulatorFsCommon::ps_aircraftCfgParsingFinished);
|
bool c = connect(m_aircraftCfgParser.get(), &CAircraftCfgParser::loadingFinished, this, &CSimulatorFsCommon::ps_aircraftCfgParsingFinished);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect signal");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Cannot connect signal");
|
||||||
Q_UNUSED(c);
|
Q_UNUSED(c);
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace BlackSimPlugin
|
|||||||
BlackMisc::Aviation::CTransponder m_simTransponder; //!< cockpit xpdr state in simulator
|
BlackMisc::Aviation::CTransponder m_simTransponder; //!< cockpit xpdr state in simulator
|
||||||
|
|
||||||
// parser / matcher
|
// parser / matcher
|
||||||
QScopedPointer<BlackMisc::Simulation::FsCommon::CAircraftCfgParser> m_aircraftCfgParser; //!< aircraft.cfg parser
|
std::unique_ptr<BlackMisc::Simulation::FsCommon::CAircraftCfgParser> m_aircraftCfgParser; //!< aircraft.cfg parser
|
||||||
BlackMisc::Simulation::CAircraftMatcher m_modelMatcher; //!< Model matcher
|
BlackMisc::Simulation::CAircraftMatcher m_modelMatcher; //!< Model matcher
|
||||||
|
|
||||||
//! Set own model
|
//! Set own model
|
||||||
|
|||||||
Reference in New Issue
Block a user