mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T701, IAircraftModelSetProvider 1st version
* added to matcher * and simulator context * in facade changed init order, as we need getCContextOwnAircraft() / getCContextSimulator() Remark: Need 2 contexts is not ideal, but accepted for the moment
This commit is contained in:
committed by
Mat Sutcliffe
parent
9ac457edb3
commit
0767deb41d
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "blackcore/webdataservicesms.h"
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackmisc/simulation/aircraftmodelsetprovider.h"
|
||||
#include "blackmisc/simulation/aircraftmatchersetup.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/matchingscriptmisc.h"
|
||||
@@ -42,9 +43,12 @@ namespace BlackCore
|
||||
//! Matcher for all models.
|
||||
//! \details Reads the model set (ie the models the user wants to use).
|
||||
//! Also Allows to reverse lookup a model (from network to DB data).
|
||||
class BLACKCORE_EXPORT CAircraftMatcher : public QObject
|
||||
class BLACKCORE_EXPORT CAircraftMatcher :
|
||||
public QObject,
|
||||
public BlackMisc::Simulation::IAircraftModelSetProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(BlackMisc::Simulation::IAircraftModelSetProvider)
|
||||
|
||||
public:
|
||||
//! Log categories
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace BlackCore
|
||||
CContextNetwork::CContextNetwork(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) :
|
||||
IContextNetwork(mode, runtime)
|
||||
{
|
||||
//! \fixme KB 2019-07 bad style we implicitly depend on 2 other contexts
|
||||
Q_ASSERT(this->getRuntime());
|
||||
Q_ASSERT(this->getIContextOwnAircraft());
|
||||
Q_ASSERT(this->getIContextOwnAircraft()->isUsingImplementingObject());
|
||||
@@ -85,7 +86,11 @@ namespace BlackCore
|
||||
|
||||
// 3. Airspace contents
|
||||
Q_ASSERT_X(this->getRuntime()->getCContextOwnAircraft(), Q_FUNC_INFO, "this and own aircraft context must be local");
|
||||
m_airspace = new CAirspaceMonitor(this->getRuntime()->getCContextOwnAircraft(), m_network, this);
|
||||
Q_ASSERT_X(this->getRuntime()->getCContextSimulator(), Q_FUNC_INFO, "this and own simulator context must be local");
|
||||
m_airspace = new CAirspaceMonitor(
|
||||
this->getRuntime()->getCContextOwnAircraft(),
|
||||
this->getRuntime()->getCContextSimulator(),
|
||||
m_network, this);
|
||||
m_network->setClientProvider(m_airspace);
|
||||
connect(m_airspace, &CAirspaceMonitor::changedAtcStationsOnline, this, &CContextNetwork::changedAtcStationsOnline, Qt::QueuedConnection);
|
||||
connect(m_airspace, &CAirspaceMonitor::changedAtcStationsBooked, this, &CContextNetwork::changedAtcStationsBooked, Qt::QueuedConnection);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "blackmisc/simulation/settings/modelmatchersettings.h"
|
||||
#include "blackmisc/simulation/settings/simulatorsettings.h"
|
||||
#include "blackmisc/simulation/settings/interpolationrenderingsetupsettings.h"
|
||||
#include "blackmisc/simulation/aircraftmodelsetprovider.h"
|
||||
#include "blackmisc/simulation/backgroundvalidation.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/interpolationsetuplist.h"
|
||||
@@ -62,10 +63,12 @@ namespace BlackCore
|
||||
//! Network simulator concrete implementation
|
||||
class BLACKCORE_EXPORT CContextSimulator :
|
||||
public IContextSimulator,
|
||||
public BlackMisc::Simulation::IAircraftModelSetProvider,
|
||||
public BlackMisc::Simulation::CRemoteAircraftAware, // gain access to in memory remote aircraft data
|
||||
public BlackMisc::CIdentifiable
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(BlackMisc::Simulation::IAircraftModelSetProvider)
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTSIMULATOR_INTERFACENAME)
|
||||
friend class BlackCore::CCoreFacade;
|
||||
friend class IContextSimulator;
|
||||
@@ -84,7 +87,6 @@ namespace BlackCore
|
||||
virtual int getSimulatorStatus() const override;
|
||||
virtual BlackMisc::Simulation::CSimulatorInternals getSimulatorInternals() const override;
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange(bool recalculateDistance) const override;
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getModelSet() const override;
|
||||
virtual BlackMisc::Simulation::CSimulatorInfo getModelSetLoaderSimulator() const override;
|
||||
virtual void setModelSetLoaderSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||
virtual BlackMisc::Simulation::CSimulatorInfo simulatorsWithInitializedModelSet() const override;
|
||||
@@ -92,7 +94,6 @@ namespace BlackCore
|
||||
virtual QStringList getModelSetStrings() const override;
|
||||
virtual QStringList getModelSetCompleterStrings(bool sorted) const override;
|
||||
virtual bool isKnownModelInSet(const QString &modelString) const override;
|
||||
virtual int getModelSetCount() const override;
|
||||
virtual void disableModelsForMatching(const BlackMisc::Simulation::CAircraftModelList &removedModels, bool incremental) override;
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getDisabledModelsForMatching() const override;
|
||||
virtual void restoreDisabledModels() override;
|
||||
@@ -125,6 +126,10 @@ namespace BlackCore
|
||||
virtual void setMatchingSetup(const BlackMisc::Simulation::CAircraftMatcherSetup &setup) override;
|
||||
virtual BlackMisc::Simulation::CAircraftMatcherSetup getMatchingSetup() const override;
|
||||
virtual BlackMisc::CStatusMessageList copyFsxTerrainProbe(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||
|
||||
// also in IAircraftModelSetProvider
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getModelSet() const override;
|
||||
virtual int getModelSetCount() const override;
|
||||
//! @}
|
||||
|
||||
//! \addtogroup swiftdotcommands
|
||||
|
||||
@@ -117,14 +117,15 @@ namespace BlackCore
|
||||
m_contextOwnAircraft = IContextOwnAircraft::create(this, m_config.getModeOwnAircraft(), m_dbusServer, m_dbusConnection);
|
||||
times.insert("Own aircraft", time.restart());
|
||||
|
||||
if (m_contextNetwork) { m_contextNetwork->deleteLater(); }
|
||||
m_contextNetwork = IContextNetwork::create(this, m_config.getModeNetwork(), m_dbusServer, m_dbusConnection);
|
||||
times.insert("Network", time.restart());
|
||||
|
||||
if (m_contextSimulator) { m_contextSimulator->deleteLater(); }
|
||||
m_contextSimulator = IContextSimulator::create(this, m_config.getModeSimulator(), m_dbusServer, m_dbusConnection);
|
||||
times.insert("Simulator", time.restart());
|
||||
|
||||
// depends on own aircraft and simulator context, which is bad style
|
||||
if (m_contextNetwork) { m_contextNetwork->deleteLater(); }
|
||||
m_contextNetwork = IContextNetwork::create(this, m_config.getModeNetwork(), m_dbusServer, m_dbusConnection);
|
||||
times.insert("Network", time.restart());
|
||||
|
||||
// checks --------------
|
||||
// 1. own aircraft and simulator should reside in same location
|
||||
Q_ASSERT(!m_contextSimulator || (m_contextOwnAircraft->isUsingImplementingObject() == m_contextSimulator->isUsingImplementingObject()));
|
||||
|
||||
32
src/blackmisc/simulation/aircraftmodelsetprovider.cpp
Normal file
32
src/blackmisc/simulation/aircraftmodelsetprovider.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Copyright (C) 2019
|
||||
* 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. 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 "aircraftmodelsetprovider.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
// pin vtables to this file
|
||||
void CAircraftModelSetAware::anchor()
|
||||
{ }
|
||||
|
||||
CAircraftModelList CAircraftModelSetAware::getModelSet() const
|
||||
{
|
||||
if (!this->hasProvider()) { return CAircraftModelList(); }
|
||||
return this->provider()->getModelSet();
|
||||
}
|
||||
|
||||
int CAircraftModelSetAware::getModelSetCount() const
|
||||
{
|
||||
if (!this->hasProvider()) { return -1; }
|
||||
return this->provider()->getModelSetCount();
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
61
src/blackmisc/simulation/aircraftmodelsetprovider.h
Normal file
61
src/blackmisc/simulation/aircraftmodelsetprovider.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* Copyright (C) 2019
|
||||
* 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. 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_AIRCRAFTMODELSETPROVIDER_H
|
||||
#define BLACKMISC_SIMULATION_AIRCRAFTMODELSETPROVIDER_H
|
||||
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/provider.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
//! Value object encapsulating a list of aircraft models
|
||||
class BLACKMISC_EXPORT IAircraftModelSetProvider : public IProvider
|
||||
{
|
||||
public:
|
||||
//! Get the model set models
|
||||
virtual CAircraftModelList getModelSet() const = 0;
|
||||
|
||||
//! Get the model set models count
|
||||
virtual int getModelSetCount() const = 0;
|
||||
|
||||
//! Constructor
|
||||
IAircraftModelSetProvider() = default;
|
||||
};
|
||||
|
||||
//! Delegating class which can be directly used to access an \sa IAircraftModelSetProvider instance
|
||||
class BLACKMISC_EXPORT CAircraftModelSetAware : public IProviderAware<IAircraftModelSetProvider>
|
||||
{
|
||||
virtual void anchor();
|
||||
|
||||
public:
|
||||
//! Set the provider
|
||||
void setOwnAircraftProvider(IAircraftModelSetProvider *provider) { this->setProvider(provider); }
|
||||
|
||||
//! \copydoc IAircraftModelSetProvider::getModelSet
|
||||
CAircraftModelList getModelSet() const;
|
||||
|
||||
//! \copydoc IAircraftModelSetProvider::getModelSetCount
|
||||
int getModelSetCount() const;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CAircraftModelSetAware(IAircraftModelSetProvider *modelSetProvider) : IProviderAware(modelSetProvider) { Q_ASSERT(modelSetProvider); }
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Q_DECLARE_INTERFACE(BlackMisc::Simulation::IAircraftModelSetProvider, "org.swift-project.blackmisc.simulation.iaircraftmodelsetprovider")
|
||||
|
||||
#endif //guard
|
||||
Reference in New Issue
Block a user