mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
refs #602, emoved web service provider
* webservices now directly accessible via sGui * interface no longer needed * no init of provider (setProvider) needed anymore
This commit is contained in:
committed by
Mathew Sutcliffe
parent
a0cfa2e687
commit
79f95845b2
@@ -1,359 +0,0 @@
|
||||
/* 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 "webdataservicesprovider.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Weather;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
CWebDataServicesAware::~CWebDataServicesAware()
|
||||
{
|
||||
this->m_swiftConnections.disconnectAll();
|
||||
}
|
||||
|
||||
CServerList CWebDataServicesAware::getVatsimFsdServers() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CServerList(); }
|
||||
return this->m_webDataReaderProvider->getVatsimFsdServers();
|
||||
}
|
||||
|
||||
CServerList CWebDataServicesAware::getVatsimVoiceServers() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CServerList(); }
|
||||
return this->m_webDataReaderProvider->getVatsimFsdServers();
|
||||
}
|
||||
|
||||
CUserList CWebDataServicesAware::getUsersForCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CUserList(); }
|
||||
return this->m_webDataReaderProvider->getUsersForCallsign(callsign);
|
||||
}
|
||||
|
||||
CAtcStationList CWebDataServicesAware::getAtcStationsForCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CAtcStationList(); }
|
||||
return this->m_webDataReaderProvider->getAtcStationsForCallsign(callsign);
|
||||
}
|
||||
|
||||
CVoiceCapabilities CWebDataServicesAware::getVoiceCapabilityForCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CVoiceCapabilities(); }
|
||||
return this->m_webDataReaderProvider->getVoiceCapabilityForCallsign(callsign);
|
||||
}
|
||||
|
||||
CDistributorList CWebDataServicesAware::getDistributors() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CDistributorList(); }
|
||||
return this->m_webDataReaderProvider->getDistributors();
|
||||
}
|
||||
|
||||
CDistributor CWebDataServicesAware::smartDistributorSelector(const CDistributor &distributor) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CDistributor(); }
|
||||
return this->m_webDataReaderProvider->smartDistributorSelector(distributor);
|
||||
}
|
||||
|
||||
int CWebDataServicesAware::getDistributorsCount() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return 0; }
|
||||
return this->m_webDataReaderProvider->getDistributorsCount();
|
||||
}
|
||||
|
||||
CLiveryList CWebDataServicesAware::getLiveries() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CLiveryList(); }
|
||||
return this->m_webDataReaderProvider->getLiveries();
|
||||
}
|
||||
|
||||
int CWebDataServicesAware::getLiveriesCount() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return 0; }
|
||||
return this->m_webDataReaderProvider->getLiveriesCount();
|
||||
}
|
||||
|
||||
CLivery CWebDataServicesAware::getLiveryForCombinedCode(const QString &combinedCode) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CLivery(); }
|
||||
return this->m_webDataReaderProvider->getLiveryForCombinedCode(combinedCode);
|
||||
}
|
||||
|
||||
CLivery CWebDataServicesAware::getStdLiveryForAirlineCode(const CAirlineIcaoCode &icao) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CLivery(); }
|
||||
return this->m_webDataReaderProvider->getStdLiveryForAirlineCode(icao);
|
||||
}
|
||||
|
||||
CLivery CWebDataServicesAware::smartLiverySelector(const CLivery &livery) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CLivery(); }
|
||||
return this->m_webDataReaderProvider->smartLiverySelector(livery);
|
||||
}
|
||||
|
||||
CAircraftModelList CWebDataServicesAware::getModels() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CAircraftModelList(); }
|
||||
return this->m_webDataReaderProvider->getModels();
|
||||
}
|
||||
|
||||
int CWebDataServicesAware::getModelsCount() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return 0; }
|
||||
return this->m_webDataReaderProvider->getModelsCount();
|
||||
}
|
||||
|
||||
QList<int> CWebDataServicesAware::getModelDbKeys() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return QList<int>(); }
|
||||
return this->m_webDataReaderProvider->getModelDbKeys();
|
||||
}
|
||||
|
||||
QStringList CWebDataServicesAware::getModelStrings() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return QStringList(); }
|
||||
return this->m_webDataReaderProvider->getModelStrings();
|
||||
}
|
||||
|
||||
CAircraftModel CWebDataServicesAware::getModelForModelString(const QString &modelString) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CAircraftModel(); }
|
||||
return this->m_webDataReaderProvider->getModelForModelString(modelString);
|
||||
}
|
||||
|
||||
CAircraftModelList CWebDataServicesAware::getModelsForAircraftDesignatorAndLiveryCombinedCode(const QString &aircraftDesignator, const QString &combinedCode) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CAircraftModelList(); }
|
||||
return this->m_webDataReaderProvider->getModelsForAircraftDesignatorAndLiveryCombinedCode(aircraftDesignator, combinedCode);
|
||||
}
|
||||
|
||||
CAircraftIcaoCodeList CWebDataServicesAware::getAircraftIcaoCodes() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CAircraftIcaoCodeList(); }
|
||||
return this->m_webDataReaderProvider->getAircraftIcaoCodes();
|
||||
}
|
||||
|
||||
int CWebDataServicesAware::getAircraftIcaoCodesCount() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return 0; }
|
||||
return this->m_webDataReaderProvider->getAircraftIcaoCodesCount();
|
||||
}
|
||||
|
||||
CAircraftIcaoCode CWebDataServicesAware::getAircraftIcaoCodeForDesignator(const QString &designator) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CAircraftIcaoCode(); }
|
||||
return this->m_webDataReaderProvider->getAircraftIcaoCodeForDesignator(designator);
|
||||
}
|
||||
|
||||
CAircraftIcaoCode CWebDataServicesAware::getAircraftIcaoCodeForDbKey(int id) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "missing provider");
|
||||
if (!hasProvider()) { return CAircraftIcaoCode(); }
|
||||
return this->m_webDataReaderProvider->getAircraftIcaoCodeForDbKey(id);
|
||||
}
|
||||
|
||||
CAircraftIcaoCode CWebDataServicesAware::smartAircraftIcaoSelector(const CAircraftIcaoCode &icao) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CAircraftIcaoCode(); }
|
||||
return this->m_webDataReaderProvider->smartAircraftIcaoSelector(icao);
|
||||
}
|
||||
|
||||
CAirlineIcaoCodeList CWebDataServicesAware::getAirlineIcaoCodes() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
return this->m_webDataReaderProvider->getAirlineIcaoCodes();
|
||||
}
|
||||
|
||||
int CWebDataServicesAware::getAirlineIcaoCodesCount() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return 0; }
|
||||
return this->m_webDataReaderProvider->getAirlineIcaoCodesCount();
|
||||
}
|
||||
|
||||
CAirlineIcaoCodeList CWebDataServicesAware::getAirlineIcaoCodesForDesignator(const QString &designator) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CAirlineIcaoCodeList(); }
|
||||
return this->m_webDataReaderProvider->getAirlineIcaoCodeForDesignator(designator);
|
||||
}
|
||||
|
||||
CAirlineIcaoCode CWebDataServicesAware::smartAirlineIcaoSelector(const CAirlineIcaoCode &code) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CAirlineIcaoCode(); }
|
||||
return this->m_webDataReaderProvider->smartAirlineIcaoSelector(code);
|
||||
}
|
||||
|
||||
CAirlineIcaoCode CWebDataServicesAware::getAirlineIcaoCodeForDbKey(int id) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CAirlineIcaoCode(); }
|
||||
return this->m_webDataReaderProvider->getAirlineIcaoCodeForDbKey(id);
|
||||
}
|
||||
|
||||
CCountryList CWebDataServicesAware::getCountries() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CCountryList(); }
|
||||
return this->m_webDataReaderProvider->getCountries();
|
||||
}
|
||||
|
||||
int CWebDataServicesAware::getCountriesCount() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return 0; }
|
||||
return this->m_webDataReaderProvider->getCountriesCount();
|
||||
}
|
||||
|
||||
CCountry CWebDataServicesAware::getCountryForName(const QString &name) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CCountry(); }
|
||||
return this->m_webDataReaderProvider->getCountryForName(name);
|
||||
}
|
||||
|
||||
CMetarSet CWebDataServicesAware::getMetars() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CMetarSet(); }
|
||||
return this->m_webDataReaderProvider->getMetars();
|
||||
}
|
||||
|
||||
Weather::CMetar CWebDataServicesAware::getMetarForAirport(const CAirportIcaoCode &icao) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CMetar(); }
|
||||
return this->m_webDataReaderProvider->getMetarForAirport(icao);
|
||||
}
|
||||
|
||||
int CWebDataServicesAware::getMetarsCount() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return 0; }
|
||||
return this->m_webDataReaderProvider->getMetarsCount();
|
||||
}
|
||||
|
||||
CCountry CWebDataServicesAware::getCountryForIsoCode(const QString &iso) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CCountry(); }
|
||||
return this->m_webDataReaderProvider->getCountryForIsoCode(iso);
|
||||
}
|
||||
|
||||
void CWebDataServicesAware::updateWithVatsimDataFileData(CSimulatedAircraft &aircraftToBeUdpated) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return; }
|
||||
return this->m_webDataReaderProvider->updateWithVatsimDataFileData(aircraftToBeUdpated);
|
||||
}
|
||||
|
||||
CStatusMessageList CWebDataServicesAware::asyncPublishModels(const CAircraftModelList &models) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CStatusMessageList(); }
|
||||
return this->m_webDataReaderProvider->asyncPublishModels(models);
|
||||
}
|
||||
|
||||
void CWebDataServicesAware::setProvider(IWebDataServicesProvider *webDataReaderProvider)
|
||||
{
|
||||
Q_ASSERT_X(webDataReaderProvider, Q_FUNC_INFO, "missing provider");
|
||||
this->m_swiftConnections.disconnectAll();
|
||||
m_webDataReaderProvider = webDataReaderProvider;
|
||||
}
|
||||
|
||||
bool CWebDataServicesAware::hasProvider() const
|
||||
{
|
||||
return m_webDataReaderProvider ? true : false;
|
||||
}
|
||||
|
||||
void CWebDataServicesAware::gracefulShutdown()
|
||||
{
|
||||
this->m_swiftConnections.disconnectAll();
|
||||
this->m_webDataReaderProvider = nullptr;
|
||||
}
|
||||
|
||||
void CWebDataServicesAware::connectDataReadSignal(QObject *receiver, std::function<void (CEntityFlags::Entity, CEntityFlags::ReadState, int)> dataRead)
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return; }
|
||||
if (receiver)
|
||||
{
|
||||
this->m_swiftConnections.append(this->m_webDataReaderProvider->connectDataReadSignal(receiver, dataRead));
|
||||
}
|
||||
}
|
||||
|
||||
void CWebDataServicesAware::connectDataPublishSignal(QObject *receiver, std::function<void (const CAircraftModelList &, const CAircraftModelList &, const CStatusMessageList &)> dataPublished)
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return; }
|
||||
if (receiver)
|
||||
{
|
||||
this->m_swiftConnections.append(this->m_webDataReaderProvider->connectDataPublishSignal(receiver, dataPublished));
|
||||
}
|
||||
}
|
||||
|
||||
CEntityFlags::Entity CWebDataServicesAware::triggerRead(CEntityFlags::Entity whatToRead, const QDateTime &newerThan)
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CEntityFlags::NoEntity; }
|
||||
return this->m_webDataReaderProvider->triggerRead(whatToRead, newerThan);
|
||||
}
|
||||
|
||||
bool CWebDataServicesAware::canConnectSwiftDb() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return false; }
|
||||
return this->m_webDataReaderProvider->canConnectSwiftDb();
|
||||
}
|
||||
|
||||
bool CWebDataServicesAware::writeDbDataToDisk(const QString &dir) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return false; }
|
||||
return this->m_webDataReaderProvider->writeDbDataToDisk(dir);
|
||||
}
|
||||
|
||||
bool CWebDataServicesAware::readDbDataFromDisk(const QString &dir, bool inBackround)
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return false; }
|
||||
return this->m_webDataReaderProvider->readDbDataFromDisk(dir, inBackround);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
@@ -1,401 +0,0 @@
|
||||
/* 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_NETWORK_WEBDATASERVICESPROVIDER_H
|
||||
#define BLACKMISC_NETWORK_WEBDATASERVICESPROVIDER_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/aviation/aircrafticaocodelist.h"
|
||||
#include "blackmisc/aviation/airlineicaocodelist.h"
|
||||
#include "blackmisc/aviation/liverylist.h"
|
||||
#include "blackmisc/aviation/atcstationlist.h"
|
||||
#include "blackmisc/network/entityflags.h"
|
||||
#include "blackmisc/network/serverlist.h"
|
||||
#include "blackmisc/network/userlist.h"
|
||||
#include "blackmisc/network/voicecapabilities.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/distributorlist.h"
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/weather/metarset.h"
|
||||
#include "blackmisc/countrylist.h"
|
||||
#include "blackmisc/connectionguard.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
//! Direct thread safe in memory access to objects read via web services
|
||||
//! \note Can not be derived from QObject (as for the signals), as this would create multiple
|
||||
//! inheritance. Hence Q_DECLARE_INTERFACE is used.
|
||||
//! \ingroup webdatareaderprovider
|
||||
class BLACKMISC_EXPORT IWebDataServicesProvider
|
||||
{
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~IWebDataServicesProvider() {}
|
||||
|
||||
//! FSD servers
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Network::CServerList getVatsimFsdServers() const = 0;
|
||||
|
||||
//! Voice servers
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Network::CServerList getVatsimVoiceServers() const = 0;
|
||||
|
||||
//! Users by callsign
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Network::CUserList getUsersForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const = 0;
|
||||
|
||||
//! ATC stations by callsign
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CAtcStationList getAtcStationsForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const = 0;
|
||||
|
||||
//! Voice capabilities for given callsign
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Network::CVoiceCapabilities getVoiceCapabilityForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const = 0;
|
||||
|
||||
//! Update with web data
|
||||
//! \threadsafe
|
||||
virtual void updateWithVatsimDataFileData(BlackMisc::Simulation::CSimulatedAircraft &aircraftToBeUdpated) const = 0;
|
||||
|
||||
//! Distributors
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Simulation::CDistributorList getDistributors() const = 0;
|
||||
|
||||
//! Distributors count
|
||||
//! \threadsafe
|
||||
virtual int getDistributorsCount() const = 0;
|
||||
|
||||
//! Use distributor object to select the best complete distributor from DB
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Simulation::CDistributor smartDistributorSelector(const BlackMisc::Simulation::CDistributor &distributor) const = 0;
|
||||
|
||||
//! Liveries
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CLiveryList getLiveries() const = 0;
|
||||
|
||||
//! Liveries count
|
||||
//! \threadsafe
|
||||
virtual int getLiveriesCount() const = 0;
|
||||
|
||||
//! Livery for its combined code
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CLivery getLiveryForCombinedCode(const QString &combinedCode) const = 0;
|
||||
|
||||
//! Standard livery for airline code
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CLivery getStdLiveryForAirlineCode(const BlackMisc::Aviation::CAirlineIcaoCode &icao) const = 0;
|
||||
|
||||
//! Livery for id
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CLivery getLiveryForDbKey(int id) const = 0;
|
||||
|
||||
//! Use a livery as template and select the best complete livery from DB for it
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CLivery smartLiverySelector(const BlackMisc::Aviation::CLivery &livery) const = 0;
|
||||
|
||||
//! Models
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getModels() const = 0;
|
||||
|
||||
//! Models count
|
||||
//! \threadsafe
|
||||
virtual int getModelsCount() const = 0;
|
||||
|
||||
//! Model keys
|
||||
//! \threadsafe
|
||||
virtual QList<int> getModelDbKeys() const = 0;
|
||||
|
||||
//! Model strings
|
||||
//! \threadsafe
|
||||
virtual QStringList getModelStrings() const = 0;
|
||||
|
||||
//! Models for combined code and aircraft designator
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getModelsForAircraftDesignatorAndLiveryCombinedCode(const QString &aircraftDesignator, const QString &combinedCode) const = 0;
|
||||
|
||||
//! Model for key if any
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Simulation::CAircraftModel getModelForModelString(const QString &modelKey) const = 0;
|
||||
|
||||
//! Aircraft ICAO codes
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CAircraftIcaoCodeList getAircraftIcaoCodes() const = 0;
|
||||
|
||||
//! Aircraft ICAO codes count
|
||||
//! \threadsafe
|
||||
virtual int getAircraftIcaoCodesCount() const = 0;
|
||||
|
||||
//! ICAO code for designator
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CAircraftIcaoCode getAircraftIcaoCodeForDesignator(const QString &designator) const = 0;
|
||||
|
||||
//! ICAO code for id
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CAircraftIcaoCode getAircraftIcaoCodeForDbKey(int id) const = 0;
|
||||
|
||||
//! Use an ICAO object to select the best complete ICAO object from DB for it
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CAircraftIcaoCode smartAircraftIcaoSelector(const BlackMisc::Aviation::CAircraftIcaoCode &icao) const = 0;
|
||||
|
||||
//! Airline ICAO codes
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CAirlineIcaoCodeList getAirlineIcaoCodes() const = 0;
|
||||
|
||||
//! Airline ICAO codes count
|
||||
//! \threadsafe
|
||||
virtual int getAirlineIcaoCodesCount() const = 0;
|
||||
|
||||
//! ICAO code for designator
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CAirlineIcaoCodeList getAirlineIcaoCodeForDesignator(const QString &designator) const = 0;
|
||||
|
||||
//! ICAO code for id
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CAirlineIcaoCode getAirlineIcaoCodeForDbKey(int id) const = 0;
|
||||
|
||||
//! Smart airline selector
|
||||
//! \threadsafe
|
||||
virtual Aviation::CAirlineIcaoCode smartAirlineIcaoSelector(const BlackMisc::Aviation::CAirlineIcaoCode &code) const = 0;
|
||||
|
||||
//! Countries
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::CCountryList getCountries() const = 0;
|
||||
|
||||
//! Country count
|
||||
//! \threadsafe
|
||||
virtual int getCountriesCount() const = 0;
|
||||
|
||||
//! Country by ISO code (GB, US...)
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::CCountry getCountryForIsoCode(const QString &iso) const = 0;
|
||||
|
||||
//! Country by name (France, China ..)
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::CCountry getCountryForName(const QString &name) const = 0;
|
||||
|
||||
//! Get METARs
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Weather::CMetarSet getMetars() const = 0;
|
||||
|
||||
//! Get METAR for airport
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Weather::CMetar getMetarForAirport(const BlackMisc::Aviation::CAirportIcaoCode &icao) const = 0;
|
||||
|
||||
//! Get METARs count
|
||||
//! \threadsafe
|
||||
virtual int getMetarsCount() const = 0;
|
||||
|
||||
//! Publish models to database
|
||||
virtual BlackMisc::CStatusMessageList asyncPublishModels(const BlackMisc::Simulation::CAircraftModelList &models) const = 0;
|
||||
|
||||
//! Relay signals for read swift data
|
||||
//! Connect signals to slot receiver. As the interface is no QObject, slots can not be connected directly.
|
||||
//! In order to disconnect a list of connections is provided, which have to be disconnected manually.
|
||||
//! \note receiver is required for connection type
|
||||
virtual QList<QMetaObject::Connection> connectDataReadSignal(
|
||||
QObject *receiver,
|
||||
std::function<void(BlackMisc::Network::CEntityFlags::Entity, BlackMisc::Network::CEntityFlags::ReadState, int)> dataRead) = 0;
|
||||
|
||||
//! Relay signals for published swift data
|
||||
//! Connect signals to slot receiver. As the interface is no QObject, slots can not be connected directly.
|
||||
//! In order to disconnect a list of connections is provided, which have to be disconnected manually.
|
||||
//! \note receiver is required for connection type
|
||||
virtual QList<QMetaObject::Connection> connectDataPublishSignal(
|
||||
QObject *receiver,
|
||||
std::function<void(const BlackMisc::Simulation::CAircraftModelList &, const BlackMisc::Simulation::CAircraftModelList &, const BlackMisc::CStatusMessageList &)> dataPublished) = 0;
|
||||
|
||||
//! Trigger read of new data
|
||||
virtual BlackMisc::Network::CEntityFlags::Entity triggerRead(BlackMisc::Network::CEntityFlags::Entity whatToRead, const QDateTime &dateTime = QDateTime()) = 0;
|
||||
|
||||
//! Can connect to swift DB?
|
||||
virtual bool canConnectSwiftDb() const = 0;
|
||||
|
||||
//! Write data to disk (mainly for testing scenarios)
|
||||
virtual bool writeDbDataToDisk(const QString &dir) const = 0;
|
||||
|
||||
//! Load DB data from disk (mainly for testing scenarios)
|
||||
virtual bool readDbDataFromDisk(const QString &dir, bool inBackground) = 0;
|
||||
};
|
||||
|
||||
//! Class which can be directly used to access an \sa IWebDataReaderProvider object
|
||||
class BLACKMISC_EXPORT CWebDataServicesAware
|
||||
{
|
||||
public:
|
||||
//! Destructor
|
||||
~CWebDataServicesAware();
|
||||
|
||||
public:
|
||||
//! \copydoc IWebDataServicesProvider::getMetarForAirport
|
||||
BlackMisc::Weather::CMetar getMetarForAirport(const BlackMisc::Aviation::CAirportIcaoCode &icao) const;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CWebDataServicesAware(IWebDataServicesProvider *webDataReaderProvider = nullptr) : m_webDataReaderProvider(webDataReaderProvider) { }
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getVatsimFsdServers
|
||||
BlackMisc::Network::CServerList getVatsimFsdServers() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getVatsimVoiceServers
|
||||
BlackMisc::Network::CServerList getVatsimVoiceServers() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getUsersForCallsign
|
||||
BlackMisc::Network::CUserList getUsersForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getAtcStationsForCallsign
|
||||
BlackMisc::Aviation::CAtcStationList getAtcStationsForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getVoiceCapabilityForCallsign
|
||||
BlackMisc::Network::CVoiceCapabilities getVoiceCapabilityForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getDistributors
|
||||
BlackMisc::Simulation::CDistributorList getDistributors() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::smartDistributorSelector
|
||||
BlackMisc::Simulation::CDistributor smartDistributorSelector(const BlackMisc::Simulation::CDistributor &distributor) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getDistributorsCount
|
||||
int getDistributorsCount() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getLiveries
|
||||
BlackMisc::Aviation::CLiveryList getLiveries() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getLiveries
|
||||
int getLiveriesCount() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getLiveryForCombinedCode
|
||||
BlackMisc::Aviation::CLivery getLiveryForCombinedCode(const QString &combinedCode) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getStdLiveryForAirlineCode
|
||||
BlackMisc::Aviation::CLivery getStdLiveryForAirlineCode(const BlackMisc::Aviation::CAirlineIcaoCode &icao) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::smartLiverySelector
|
||||
BlackMisc::Aviation::CLivery smartLiverySelector(const Aviation::CLivery &livery) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getModels
|
||||
BlackMisc::Simulation::CAircraftModelList getModels() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getModelsCount
|
||||
int getModelsCount() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getModelDbKeys
|
||||
QList<int> getModelDbKeys() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getModelStrings
|
||||
QStringList getModelStrings() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getModelsForAircraftDesignatorAndLiveryCombinedCode
|
||||
BlackMisc::Simulation::CAircraftModelList getModelsForAircraftDesignatorAndLiveryCombinedCode(const QString &aircraftDesignator, const QString &combinedCode) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getModelForModelString
|
||||
BlackMisc::Simulation::CAircraftModel getModelForModelString(const QString &modelString) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getAircraftIcaoCodes
|
||||
BlackMisc::Aviation::CAircraftIcaoCodeList getAircraftIcaoCodes() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getAircraftIcaoCodesCount
|
||||
int getAircraftIcaoCodesCount() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getAircraftIcaoCodeForDesignator
|
||||
BlackMisc::Aviation::CAircraftIcaoCode getAircraftIcaoCodeForDesignator(const QString &designator) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getAircraftIcaoCodeForDbKey
|
||||
BlackMisc::Aviation::CAircraftIcaoCode getAircraftIcaoCodeForDbKey(int id) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getAirlineIcaoCodes
|
||||
BlackMisc::Aviation::CAirlineIcaoCodeList getAirlineIcaoCodes() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getAirlineIcaoCodesCount
|
||||
int getAirlineIcaoCodesCount() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getAirlineIcaoCodeForDesignator
|
||||
Aviation::CAirlineIcaoCodeList getAirlineIcaoCodesForDesignator(const QString &designator) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::smartAirlineIcaoSelector
|
||||
Aviation::CAirlineIcaoCode smartAirlineIcaoSelector(const BlackMisc::Aviation::CAirlineIcaoCode &code) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getAirlineIcaoCodeForDbKey
|
||||
BlackMisc::Aviation::CAirlineIcaoCode getAirlineIcaoCodeForDbKey(int id) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::smartAircraftIcaoSelector
|
||||
BlackMisc::Aviation::CAircraftIcaoCode smartAircraftIcaoSelector(const BlackMisc::Aviation::CAircraftIcaoCode &icao) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getCountries
|
||||
BlackMisc::CCountryList getCountries() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getCountriesCount
|
||||
int getCountriesCount() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getCountryForIsoCode
|
||||
BlackMisc::CCountry getCountryForIsoCode(const QString &iso) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getCountryForName
|
||||
BlackMisc::CCountry getCountryForName(const QString &name) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getMetars
|
||||
BlackMisc::Weather::CMetarSet getMetars() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::getMetarsCount
|
||||
int getMetarsCount() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::updateWithVatsimDataFileData
|
||||
void updateWithVatsimDataFileData(BlackMisc::Simulation::CSimulatedAircraft &aircraftToBeUdpated) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::asyncPublishModels
|
||||
BlackMisc::CStatusMessageList asyncPublishModels(const BlackMisc::Simulation::CAircraftModelList &models) const;
|
||||
|
||||
//! Set the provider
|
||||
virtual void setProvider(IWebDataServicesProvider *webDataReaderProvider);
|
||||
|
||||
//! Is provider avialable?
|
||||
bool hasProvider() const;
|
||||
|
||||
//! Called when provider should no longer be used
|
||||
void gracefulShutdown();
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::connectDataReadSignal
|
||||
void connectDataReadSignal(
|
||||
QObject *receiver,
|
||||
std::function<void(BlackMisc::Network::CEntityFlags::Entity, BlackMisc::Network::CEntityFlags::ReadState, int)> dataRead);
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::connectDataPublishSignal
|
||||
virtual void connectDataPublishSignal(
|
||||
QObject *receiver,
|
||||
std::function<void(const BlackMisc::Simulation::CAircraftModelList &, const BlackMisc::Simulation::CAircraftModelList &, const BlackMisc::CStatusMessageList &)> dataPublished);
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::triggerRead
|
||||
BlackMisc::Network::CEntityFlags::Entity triggerRead(BlackMisc::Network::CEntityFlags::Entity whatToRead, const QDateTime &newerThan);
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::canConnectSwiftDb
|
||||
bool canConnectSwiftDb() const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::writeDbDataToDisk
|
||||
bool writeDbDataToDisk(const QString &dir) const;
|
||||
|
||||
//! \copydoc IWebDataServicesProvider::readDbDataFromDisk
|
||||
bool readDbDataFromDisk(const QString &dir, bool inBackround);
|
||||
|
||||
private:
|
||||
IWebDataServicesProvider *m_webDataReaderProvider = nullptr; //!< access to object
|
||||
BlackMisc::CConnectionGuard m_swiftConnections; //!< signal connection with swift
|
||||
|
||||
//! Disconnect all signals
|
||||
void disconnectSignals();
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_INTERFACE(BlackMisc::Network::IWebDataServicesProvider, "BlackMisc::Network::IWebDataServicesProvider")
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user