mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
refs #614, removed IModelMappingsProvider + adjustments
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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 "modelmappingsprovidervpilot.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
namespace FsCommon
|
||||
{
|
||||
CModelMappingsProviderVPilot::CModelMappingsProviderVPilot(bool standardDirectory, QObject *parent) :
|
||||
IModelMappingsProvider(parent),
|
||||
m_vPilotReader(new CVPilotRulesReader(standardDirectory, this))
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
bool CModelMappingsProviderVPilot::read()
|
||||
{
|
||||
Q_ASSERT_X(this->m_vPilotReader, Q_FUNC_INFO, "missing reader");
|
||||
bool success = this->m_vPilotReader->read(false);
|
||||
if (success)
|
||||
{
|
||||
this->m_mappingModels = this->m_vPilotReader->getAsModels();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
@@ -1,51 +0,0 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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_FSCOMMON_VPILOTMODELMAPPINGS_H
|
||||
#define BLACKMISC_SIMULATION_FSCOMMON_VPILOTMODELMAPPINGS_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/simulation/modelmappingsprovider.h"
|
||||
#include "blackmisc/simulation/fscommon/vpilotrulesreader.h"
|
||||
#include <QStringList>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
namespace FsCommon
|
||||
{
|
||||
//! Model mappings
|
||||
class BLACKMISC_EXPORT CModelMappingsProviderVPilot : public IModelMappingsProvider
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CModelMappingsProviderVPilot(bool standardDirectory, QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CModelMappingsProviderVPilot() {}
|
||||
|
||||
//! \copydoc IModelMappingsProvider::getMatchingModels
|
||||
virtual CAircraftModelList getMatchingModels() const override { return this->m_mappingModels; }
|
||||
|
||||
public slots:
|
||||
//! Load data
|
||||
virtual bool read() override;
|
||||
|
||||
private:
|
||||
QScopedPointer<CVPilotRulesReader> m_vPilotReader; //!< used vPilot model reader
|
||||
BlackMisc::Simulation::CAircraftModelList m_mappingModels; //!< models
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
#endif // guard
|
||||
@@ -1,37 +0,0 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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 "modelmappingsprovider.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
IModelMappingsProvider::IModelMappingsProvider(QObject *parent) : QObject(parent) {}
|
||||
|
||||
CachedModelSetProvider::CachedModelSetProvider(const CSimulatorInfo &simulator, QObject *parent) :
|
||||
IModelMappingsProvider(parent), m_simulator(simulator)
|
||||
{ }
|
||||
|
||||
CAircraftModelList CachedModelSetProvider::getMatchingModels() const
|
||||
{
|
||||
return this->m_modelSets.getModels(this->m_simulator);
|
||||
}
|
||||
|
||||
bool CachedModelSetProvider::read()
|
||||
{
|
||||
this->m_modelSets.syncronize(this->m_simulator);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
@@ -1,66 +0,0 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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_MODELMAPPINGS_H
|
||||
#define BLACKMISC_SIMULATION_MODELMAPPINGS_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/simulation/data/modelcaches.h"
|
||||
#include <QObject>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
//! Model mappings interface, different mapping readers (e.g. from database, from vPilot data files)
|
||||
//! can implement this, but provide the same mapping list.
|
||||
class BLACKMISC_EXPORT IModelMappingsProvider : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
IModelMappingsProvider(QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~IModelMappingsProvider() {}
|
||||
|
||||
//! Load data
|
||||
virtual bool read() = 0;
|
||||
|
||||
//! Get list of models used
|
||||
virtual CAircraftModelList getMatchingModels() const = 0;
|
||||
|
||||
protected:
|
||||
BlackMisc::Simulation::CAircraftModelList m_mappingModels; //!< models
|
||||
};
|
||||
|
||||
//! Implementation of a provider based on the model set cache
|
||||
class BLACKMISC_EXPORT CachedModelSetProvider : public IModelMappingsProvider
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CachedModelSetProvider(const BlackMisc::Simulation::CSimulatorInfo &simulator, QObject *parent = nullptr);
|
||||
|
||||
//! \copydoc IModelMappingsProvider::getMatchingModels
|
||||
virtual CAircraftModelList getMatchingModels() const override;
|
||||
|
||||
//! \copydoc IModelMappingsProvider::read
|
||||
virtual bool read() override;
|
||||
|
||||
private:
|
||||
BlackMisc::Simulation::Data::CModelSetCaches m_modelSets { this };
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulator;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user