mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 23:45:35 +08:00
refs #452, interface for a model loader.
This will allow to load aircraft models in the mapping tool independent from a driver
This commit is contained in:
committed by
Mathew Sutcliffe
parent
fce5fd4515
commit
ee3a4d7a2e
60
src/blackmisc/simulation/aircraftmodelloader.cpp
Normal file
60
src/blackmisc/simulation/aircraftmodelloader.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "aircraftmodelloader.h"
|
||||
#include "blackmisc/simulation/fscommon/aircraftcfgparser.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
IAircraftModelLoader::IAircraftModelLoader(const CSimulatorInfo &info) :
|
||||
m_simulatorInfo(info)
|
||||
{ }
|
||||
|
||||
IAircraftModelLoader::~IAircraftModelLoader()
|
||||
{
|
||||
this->gracefulShutdown();
|
||||
}
|
||||
|
||||
const CSimulatorInfo &IAircraftModelLoader::supportedSimulators() const
|
||||
{
|
||||
return m_simulatorInfo;
|
||||
}
|
||||
|
||||
QString IAircraftModelLoader::supportedSimulatorsAsString() const
|
||||
{
|
||||
return m_simulatorInfo.toQString();
|
||||
}
|
||||
|
||||
bool IAircraftModelLoader::supportsSimulator(const CSimulatorInfo &info)
|
||||
{
|
||||
return supportedSimulators().matchesAny(info);
|
||||
}
|
||||
|
||||
void IAircraftModelLoader::cancelLoading()
|
||||
{
|
||||
m_cancelLoading = true;
|
||||
}
|
||||
|
||||
void IAircraftModelLoader::gracefulShutdown()
|
||||
{
|
||||
this->cancelLoading();
|
||||
}
|
||||
|
||||
IAircraftModelLoader *IAircraftModelLoader::createModelLoader(const CSimulatorInfo &info)
|
||||
{
|
||||
//! \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;
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
90
src/blackmisc/simulation/aircraftmodelloader.h
Normal file
90
src/blackmisc/simulation/aircraftmodelloader.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_SIMULATION_IAIRCRAFTMODELLOADER_H
|
||||
#define BLACKMISC_SIMULATION_IAIRCRAFTMODELLOADER_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/pixmap.h"
|
||||
#include <QObject>
|
||||
#include <atomic>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
/*!
|
||||
* Load the aircraft for a simulator
|
||||
*/
|
||||
class BLACKMISC_EXPORT IAircraftModelLoader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Parser mode
|
||||
enum LoadMode
|
||||
{
|
||||
ModeBlocking,
|
||||
ModeBackground
|
||||
};
|
||||
|
||||
//! Destructor
|
||||
virtual ~IAircraftModelLoader();
|
||||
|
||||
//! Start the loading process
|
||||
virtual void startLoading(LoadMode mode = ModeBackground) = 0;
|
||||
|
||||
//! Loading finished?
|
||||
virtual bool isLoadingFinished() const = 0;
|
||||
|
||||
//! The models loaded
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getAircraftModels() const = 0;
|
||||
|
||||
//! A representive pixmap for given model
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelName, BlackMisc::CStatusMessage &statusMessage) const = 0;
|
||||
|
||||
//! Which simulators are supported by that very loader
|
||||
const BlackMisc::Simulation::CSimulatorInfo &supportedSimulators() const;
|
||||
|
||||
//! Supported simulators as string
|
||||
QString supportedSimulatorsAsString() const;
|
||||
|
||||
//! Is the given simulator supported?
|
||||
bool supportsSimulator(const BlackMisc::Simulation::CSimulatorInfo &info);
|
||||
|
||||
//! Cancel read
|
||||
void cancelLoading();
|
||||
|
||||
//! Shutdown
|
||||
void gracefulShutdown();
|
||||
|
||||
//! Create a loader
|
||||
//! \todo just a hack, needs to be replaced
|
||||
static IAircraftModelLoader *createModelLoader(const BlackMisc::Simulation::CSimulatorInfo &info);
|
||||
|
||||
signals:
|
||||
//! Parsing is finished
|
||||
void loadingFinished(bool success);
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
IAircraftModelLoader(const CSimulatorInfo &info = CSimulatorInfo());
|
||||
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulatorInfo; //!< Corresponding simulator
|
||||
std::atomic<bool> m_cancelLoading { false }; //!< flag
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user