mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 13:55:36 +08:00
refs #409 Rename ISimulatorModelMappings to IModelMappingsProvider
The reason is that the previous name sounded more like a value object. But instead it does read the mappings from somwhere.
This commit is contained in:
@@ -25,11 +25,11 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
CAircraftMapper::CAircraftMapper(QObject *parent) : QObject(parent) { }
|
CAircraftMapper::CAircraftMapper(QObject *parent) : QObject(parent) { }
|
||||||
|
|
||||||
CAircraftMapper::CAircraftMapper(std::unique_ptr<ISimulatorModelMappings> mappings, QObject *parent) :
|
CAircraftMapper::CAircraftMapper(std::unique_ptr<IModelMappingsProvider> mappings, QObject *parent) :
|
||||||
QObject(parent), m_mappings(mappings.release())
|
QObject(parent), m_mappings(mappings.release())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
CAircraftMapper::CAircraftMapper(std::unique_ptr<ISimulatorModelMappings> mappings, const QString &simObjectsDir, QObject *parent) :
|
CAircraftMapper::CAircraftMapper(std::unique_ptr<IModelMappingsProvider> mappings, const QString &simObjectsDir, QObject *parent) :
|
||||||
QObject(parent), m_mappings(mappings.release())
|
QObject(parent), m_mappings(mappings.release())
|
||||||
{
|
{
|
||||||
this->m_entries.changeDirectory(simObjectsDir);
|
this->m_entries.changeDirectory(simObjectsDir);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "blackmisc/blackmiscexport.h"
|
#include "blackmisc/blackmiscexport.h"
|
||||||
#include "aircraftcfgentrieslist.h"
|
#include "aircraftcfgentrieslist.h"
|
||||||
#include "../simulatormodelmappings.h"
|
#include "blackmisc/simulation/modelmappingsprovider.h"
|
||||||
#include "blackmisc/worker.h"
|
#include "blackmisc/worker.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
@@ -51,10 +51,10 @@ namespace BlackMisc
|
|||||||
CAircraftMapper(QObject *parent = nullptr);
|
CAircraftMapper(QObject *parent = nullptr);
|
||||||
|
|
||||||
//! Constructor, handing over ownership or mappings object
|
//! Constructor, handing over ownership or mappings object
|
||||||
CAircraftMapper(std::unique_ptr<ISimulatorModelMappings> mappings, QObject *parent = nullptr);
|
CAircraftMapper(std::unique_ptr<IModelMappingsProvider> mappings, QObject *parent = nullptr);
|
||||||
|
|
||||||
//! Constructor, handing over ownership or mappings object
|
//! Constructor, handing over ownership or mappings object
|
||||||
CAircraftMapper(std::unique_ptr<ISimulatorModelMappings> mappings, const QString &simObjectsDir, QObject *parent = nullptr);
|
CAircraftMapper(std::unique_ptr<IModelMappingsProvider> mappings, const QString &simObjectsDir, QObject *parent = nullptr);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~CAircraftMapper();
|
~CAircraftMapper();
|
||||||
@@ -109,7 +109,7 @@ namespace BlackMisc
|
|||||||
static const BlackMisc::Simulation::CAircraftModel &getDefaultModel();
|
static const BlackMisc::Simulation::CAircraftModel &getDefaultModel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<BlackMisc::Simulation::ISimulatorModelMappings> m_mappings; //!< all mapping definitions
|
QScopedPointer<BlackMisc::Simulation::IModelMappingsProvider> m_mappings; //!< all mapping definitions
|
||||||
CAircraftCfgEntriesList m_entries; //!< all entries
|
CAircraftCfgEntriesList m_entries; //!< all entries
|
||||||
bool m_init = false;
|
bool m_init = false;
|
||||||
bool m_initInProgress = false;
|
bool m_initInProgress = false;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* contained in the LICENSE file.
|
* contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "vpilotmodelmappings.h"
|
#include "modelmappingsprovidervpilot.h"
|
||||||
#include "blackmisc/network/aircraftmapping.h"
|
#include "blackmisc/network/aircraftmapping.h"
|
||||||
|
|
||||||
#include <QtXml/QDomElement>
|
#include <QtXml/QDomElement>
|
||||||
@@ -24,19 +24,19 @@ namespace BlackMisc
|
|||||||
namespace FsCommon
|
namespace FsCommon
|
||||||
{
|
{
|
||||||
|
|
||||||
CVPilotModelMappings::CVPilotModelMappings(bool standardDirectory, QObject *parent) :
|
CModelMappingsProviderVPilot::CModelMappingsProviderVPilot(bool standardDirectory, QObject *parent) :
|
||||||
ISimulatorModelMappings(parent)
|
IModelMappingsProvider(parent)
|
||||||
{
|
{
|
||||||
if (standardDirectory) { this->addDirectory(CVPilotModelMappings::standardMappingsDirectory()); }
|
if (standardDirectory) { this->addDirectory(CModelMappingsProviderVPilot::standardMappingsDirectory()); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVPilotModelMappings::addFilename(const QString &fileName)
|
void CModelMappingsProviderVPilot::addFilename(const QString &fileName)
|
||||||
{
|
{
|
||||||
if (this->m_fileList.contains(fileName)) return;
|
if (this->m_fileList.contains(fileName)) return;
|
||||||
this->m_fileList.append(fileName);
|
this->m_fileList.append(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVPilotModelMappings::addDirectory(const QString &directory)
|
void CModelMappingsProviderVPilot::addDirectory(const QString &directory)
|
||||||
{
|
{
|
||||||
QDir dir(directory);
|
QDir dir(directory);
|
||||||
if (!dir.exists()) return;
|
if (!dir.exists()) return;
|
||||||
@@ -48,7 +48,7 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &CVPilotModelMappings::standardMappingsDirectory()
|
const QString &CModelMappingsProviderVPilot::standardMappingsDirectory()
|
||||||
{
|
{
|
||||||
static QString directory;
|
static QString directory;
|
||||||
if (directory.isEmpty())
|
if (directory.isEmpty())
|
||||||
@@ -60,7 +60,7 @@ namespace BlackMisc
|
|||||||
return directory;
|
return directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CVPilotModelMappings::read()
|
bool CModelMappingsProviderVPilot::read()
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
this->m_loadedFiles = 0;
|
this->m_loadedFiles = 0;
|
||||||
@@ -75,7 +75,7 @@ namespace BlackMisc
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CVPilotModelMappings::loadFile(const QString &fileName)
|
bool CModelMappingsProviderVPilot::loadFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
QFile f(fileName);
|
QFile f(fileName);
|
||||||
if (!f.exists()) { return false; }
|
if (!f.exists()) { return false; }
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
#define BLACKMISC_SIMULATION_FSCOMMON_VPILOTMODELMAPPINGS_H
|
#define BLACKMISC_SIMULATION_FSCOMMON_VPILOTMODELMAPPINGS_H
|
||||||
|
|
||||||
#include "blackmisc/blackmiscexport.h"
|
#include "blackmisc/blackmiscexport.h"
|
||||||
#include "../simulatormodelmappings.h"
|
#include "blackmisc/simulation/modelmappingsprovider.h"
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
@@ -23,14 +23,14 @@ namespace BlackMisc
|
|||||||
namespace FsCommon
|
namespace FsCommon
|
||||||
{
|
{
|
||||||
//! Model mappings
|
//! Model mappings
|
||||||
class BLACKMISC_EXPORT CVPilotModelMappings : public ISimulatorModelMappings
|
class BLACKMISC_EXPORT CModelMappingsProviderVPilot : public IModelMappingsProvider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CVPilotModelMappings(bool standardDirectory, QObject *parent = nullptr);
|
CModelMappingsProviderVPilot(bool standardDirectory, QObject *parent = nullptr);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~CVPilotModelMappings() {}
|
virtual ~CModelMappingsProviderVPilot() {}
|
||||||
|
|
||||||
//! File names
|
//! File names
|
||||||
void addFilename(const QString &fileName);
|
void addFilename(const QString &fileName);
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
* contained in the LICENSE file.
|
* contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "simulatormodelmappings.h"
|
#include "modelmappingsprovider.h"
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
@@ -17,24 +17,24 @@ namespace BlackMisc
|
|||||||
namespace Simulation
|
namespace Simulation
|
||||||
{
|
{
|
||||||
|
|
||||||
ISimulatorModelMappings::ISimulatorModelMappings(QObject *parent) : QObject(parent) {}
|
IModelMappingsProvider::IModelMappingsProvider(QObject *parent) : QObject(parent) {}
|
||||||
|
|
||||||
int ISimulatorModelMappings::size() const
|
int IModelMappingsProvider::size() const
|
||||||
{
|
{
|
||||||
return this->m_mappings.size();
|
return this->m_mappings.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ISimulatorModelMappings::isEmpty() const
|
bool IModelMappingsProvider::isEmpty() const
|
||||||
{
|
{
|
||||||
return this->m_mappings.isEmpty();
|
return this->m_mappings.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
const CAircraftMappingList &ISimulatorModelMappings::getMappingList() const
|
const CAircraftMappingList &IModelMappingsProvider::getMappingList() const
|
||||||
{
|
{
|
||||||
return this->m_mappings;
|
return this->m_mappings;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ISimulatorModelMappings::synchronizeWithExistingModels(const QStringList &modelNames, Qt::CaseSensitivity cs)
|
int IModelMappingsProvider::synchronizeWithExistingModels(const QStringList &modelNames, Qt::CaseSensitivity cs)
|
||||||
{
|
{
|
||||||
if (modelNames.isEmpty() || this->m_mappings.isEmpty()) { return this->m_mappings.size(); }
|
if (modelNames.isEmpty() || this->m_mappings.isEmpty()) { return this->m_mappings.size(); }
|
||||||
CAircraftMappingList newList;
|
CAircraftMappingList newList;
|
||||||
@@ -22,16 +22,16 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
//! Model mappings interface, different mapping readers (e.g. from database, from vPilot data files)
|
//! Model mappings interface, different mapping readers (e.g. from database, from vPilot data files)
|
||||||
//! can implement this, but provide the same mapping list.
|
//! can implement this, but provide the same mapping list.
|
||||||
class BLACKMISC_EXPORT ISimulatorModelMappings : public QObject
|
class BLACKMISC_EXPORT IModelMappingsProvider : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
ISimulatorModelMappings(QObject *parent = nullptr);
|
IModelMappingsProvider(QObject *parent = nullptr);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~ISimulatorModelMappings() {}
|
virtual ~IModelMappingsProvider() {}
|
||||||
|
|
||||||
//! Load data
|
//! Load data
|
||||||
virtual bool read() = 0;
|
virtual bool read() = 0;
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "simulator_fscommon.h"
|
#include "simulator_fscommon.h"
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
#include "blackmisc/simulation/fscommon/vpilotmodelmappings.h"
|
#include "blackmisc/simulation/fscommon/modelmappingsprovidervpilot.h"
|
||||||
#include "blackmisc/simulation/fscommon/fscommonutil.h"
|
#include "blackmisc/simulation/fscommon/fscommonutil.h"
|
||||||
|
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
@@ -112,12 +112,12 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
CAircraftMapper *CSimulatorFsCommon::mapperInstance()
|
CAircraftMapper *CSimulatorFsCommon::mapperInstance()
|
||||||
{
|
{
|
||||||
static CVPilotModelMappings *mappings = new CVPilotModelMappings(true);
|
static CModelMappingsProviderVPilot *mappings = new CModelMappingsProviderVPilot(true);
|
||||||
|
|
||||||
// tries to access simObjectsDir, if this is an mapped remote directory
|
// tries to access simObjectsDir, if this is an mapped remote directory
|
||||||
// init might hang for a while
|
// init might hang for a while
|
||||||
static CAircraftMapper *mapper = new CAircraftMapper(
|
static CAircraftMapper *mapper = new CAircraftMapper(
|
||||||
std::unique_ptr<CVPilotModelMappings>(mappings), // currently hard wired
|
std::unique_ptr<CModelMappingsProviderVPilot>(mappings), // currently hard wired
|
||||||
simObjectsDir()
|
simObjectsDir()
|
||||||
);
|
);
|
||||||
return mapper;
|
return mapper;
|
||||||
|
|||||||
Reference in New Issue
Block a user