mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +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
|
||||
if (this->m_modelLoader) { this->m_modelLoader->cancelLoading(); }
|
||||
|
||||
//! \todo appropriate model loader or loaders via factory?
|
||||
this->m_modelLoader.reset(IAircraftModelLoader::createModelLoader(simInfo));
|
||||
this->m_modelLoader = IAircraftModelLoader::createModelLoader(simInfo);
|
||||
if (!this->m_modelLoader || !this->m_modelLoader->supportsSimulator(simInfo))
|
||||
{
|
||||
CLogMessage(this).error("Failed to init model loader %1") << simInfo.toQString();
|
||||
@@ -93,7 +92,7 @@ namespace BlackGui
|
||||
}
|
||||
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_UNUSED(c);
|
||||
return true;
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace BlackGui
|
||||
private:
|
||||
QScopedPointer<Ui::CDbMappingComponent> ui;
|
||||
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader;
|
||||
QScopedPointer<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader;
|
||||
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader;
|
||||
bool m_withVPilot = false;
|
||||
|
||||
//! Consolidated aircraft model
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "aircraftmodelloader.h"
|
||||
#include "blackmisc/simulation/fscommon/aircraftcfgparser.h"
|
||||
|
||||
using namespace BlackMisc::Simulation::FsCommon;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
@@ -48,13 +50,17 @@ namespace BlackMisc
|
||||
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
|
||||
IAircraftModelLoader *ml = BlackMisc::Simulation::FsCommon::CAircraftCfgParser::createModelLoader(info);
|
||||
if (ml) { return ml; }
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No model model loader for simulator");
|
||||
return nullptr;
|
||||
if (simInfo.xplane())
|
||||
{
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Not yet implemented.");
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return CAircraftCfgParser::createModelLoader(simInfo);
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -69,8 +69,7 @@ namespace BlackMisc
|
||||
void gracefulShutdown();
|
||||
|
||||
//! Create a loader
|
||||
//! \todo just a hack, needs to be replaced
|
||||
static IAircraftModelLoader *createModelLoader(const BlackMisc::Simulation::CSimulatorInfo &info);
|
||||
static std::unique_ptr<IAircraftModelLoader> createModelLoader(const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||
|
||||
signals:
|
||||
//! Parsing is finished
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "aircraftcfgparser.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/simulation/fscommon/fscommonutil.h"
|
||||
#include "blackmisc/predicates.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
@@ -31,33 +32,31 @@ namespace BlackMisc
|
||||
m_excludedDirectories(exludes)
|
||||
{ }
|
||||
|
||||
CAircraftCfgParser *CAircraftCfgParser::createModelLoader(const CSimulatorInfo &simInfo)
|
||||
std::unique_ptr<CAircraftCfgParser> CAircraftCfgParser::createModelLoader(const CSimulatorInfo &simInfo)
|
||||
{
|
||||
if (simInfo.fsx())
|
||||
{
|
||||
return new CAircraftCfgParser(
|
||||
return make_unique<CAircraftCfgParser>(
|
||||
CSimulatorInfo(CSimulatorInfo::FSX),
|
||||
CFsCommonUtil::fsxSimObjectsDir(),
|
||||
CFsCommonUtil::fsxSimObjectsExcludeDirectories());
|
||||
|
||||
}
|
||||
else if (simInfo.fs9())
|
||||
{
|
||||
return new CAircraftCfgParser(
|
||||
return make_unique<CAircraftCfgParser>(
|
||||
CSimulatorInfo(CSimulatorInfo::FS9),
|
||||
CFsCommonUtil::fs9AircraftDir(),
|
||||
CFsCommonUtil::fs9AircraftObjectsExcludeDirectories());
|
||||
|
||||
}
|
||||
else if (simInfo.p3d())
|
||||
{
|
||||
return new CAircraftCfgParser(
|
||||
return make_unique<CAircraftCfgParser>(
|
||||
CSimulatorInfo(CSimulatorInfo::P3D),
|
||||
CFsCommonUtil::p3dSimObjectsDir(),
|
||||
CFsCommonUtil::p3dSimObjectsExcludeDirectories());
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Illegal simulator info");
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
|
||||
CAircraftCfgParser::~CAircraftCfgParser()
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace BlackMisc
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getAircraftModels() const override;
|
||||
|
||||
//! 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:
|
||||
//! Parsed or injected entires
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace BlackSimPlugin
|
||||
auto modelMappingsProvider = std::unique_ptr<IModelMappingsProvider> { BlackMisc::make_unique<CModelMappingsProviderVPilot>(true) };
|
||||
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_UNUSED(c);
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace BlackSimPlugin
|
||||
BlackMisc::Aviation::CTransponder m_simTransponder; //!< cockpit xpdr state in simulator
|
||||
|
||||
// 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
|
||||
|
||||
//! Set own model
|
||||
|
||||
Reference in New Issue
Block a user