mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
refs #452, provider for data read via web services
This commit is contained in:
committed by
Mathew Sutcliffe
parent
ee3a4d7a2e
commit
ab8828f177
293
src/blackmisc/network/webdataservicesprovider.cpp
Normal file
293
src/blackmisc/network/webdataservicesprovider.cpp
Normal file
@@ -0,0 +1,293 @@
|
||||
/* 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;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
CWebDataServicesAware::~CWebDataServicesAware()
|
||||
{
|
||||
disconnectSignals();
|
||||
}
|
||||
|
||||
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::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();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
CAirlineIcaoCode CWebDataServicesAware::getAirlineIcaoCodeForDesignator(const QString &designator) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CAirlineIcaoCode(); }
|
||||
return this->m_webDataReaderProvider->getAirlineIcaoCodeForDesignator(designator);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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::asyncWriteModel(CAircraftModel &model) const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CStatusMessageList(); }
|
||||
return this->m_webDataReaderProvider->asyncWriteModel(model);
|
||||
}
|
||||
|
||||
void CWebDataServicesAware::setProvider(IWebDataServicesProvider *webDataReaderProvider)
|
||||
{
|
||||
Q_ASSERT_X(webDataReaderProvider, Q_FUNC_INFO, "missing provider");
|
||||
disconnectSignals();
|
||||
m_webDataReaderProvider = webDataReaderProvider;
|
||||
}
|
||||
|
||||
bool CWebDataServicesAware::hasProvider() const
|
||||
{
|
||||
return m_webDataReaderProvider ? true : false;
|
||||
}
|
||||
|
||||
void CWebDataServicesAware::gracefulShutdown()
|
||||
{
|
||||
disconnectSignals();
|
||||
this->m_webDataReaderProvider = nullptr;
|
||||
}
|
||||
|
||||
void CWebDataServicesAware::connectSwiftDatabaseSignals(QObject *receiver, std::function<void (CDbFlags::Entity, CDbFlags::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->connectSwiftDatabaseSignals(receiver, dataRead));
|
||||
}
|
||||
}
|
||||
|
||||
CDbFlags::Entity CWebDataServicesAware::triggerRead(CDbFlags::Entity whatToRead)
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return CDbFlags::NoEntity; }
|
||||
return this->m_webDataReaderProvider->triggerRead(whatToRead);
|
||||
}
|
||||
|
||||
bool CWebDataServicesAware::canConnectSwiftDb() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_webDataReaderProvider, Q_FUNC_INFO, "Missing provider");
|
||||
if (!hasProvider()) { return false; }
|
||||
return this->m_webDataReaderProvider->canConnectSwiftDb();
|
||||
}
|
||||
|
||||
void CWebDataServicesAware::disconnectSignals()
|
||||
{
|
||||
for (QMetaObject::Connection &c : m_swiftConnections)
|
||||
{
|
||||
QObject::disconnect(c);
|
||||
}
|
||||
m_swiftConnections.clear();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
327
src/blackmisc/network/webdataservicesprovider.h
Normal file
327
src/blackmisc/network/webdataservicesprovider.h
Normal file
@@ -0,0 +1,327 @@
|
||||
/* 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/dbflags.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/countrylist.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;
|
||||
|
||||
//! Liveries
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CLivery getLiveryForCombinedCode(const QString &combinedCode) 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;
|
||||
|
||||
//! 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::CAirlineIcaoCode getAirlineIcaoCodeForDesignator(const QString &designator) const = 0;
|
||||
|
||||
//! ICAO code for id
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CAirlineIcaoCode getAirlineIcaoCodeForDbKey(int id) 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;
|
||||
|
||||
//! Write directly to database
|
||||
virtual BlackMisc::CStatusMessageList asyncWriteModel(BlackMisc::Simulation::CAircraftModel &model) const = 0;
|
||||
|
||||
//! Relay signals for VATSIM 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> connectVatsimDataSignals(QObject *receiver, std::function<void(int)> bookingsRead, std::function<void(int)> dataFileRead) = 0;
|
||||
|
||||
//! Relay signals for swift data
|
||||
virtual QList<QMetaObject::Connection> connectSwiftDatabaseSignals(
|
||||
QObject *receiver,
|
||||
std::function<void(BlackMisc::Network::CDbFlags::Entity, BlackMisc::Network::CDbFlags::ReadState, int)> dataRead) = 0;
|
||||
|
||||
//! Trigger read of new data
|
||||
virtual BlackMisc::Network::CDbFlags::Entity triggerRead(BlackMisc::Network::CDbFlags::Entity whatToRead) = 0;
|
||||
|
||||
//! Can connect to swift DB?
|
||||
virtual bool canConnectSwiftDb() const = 0;
|
||||
};
|
||||
|
||||
//! Class which can be directly used to access an \sa IWebDataReaderProvider object
|
||||
class BLACKMISC_EXPORT CWebDataServicesAware
|
||||
{
|
||||
public:
|
||||
//! Destructor
|
||||
~CWebDataServicesAware();
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getVatsimFsdServers
|
||||
BlackMisc::Network::CServerList getVatsimFsdServers() const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getVatsimVoiceServers
|
||||
BlackMisc::Network::CServerList getVatsimVoiceServers() const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getUsersForCallsign
|
||||
BlackMisc::Network::CUserList getUsersForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getAtcStationsForCallsign
|
||||
BlackMisc::Aviation::CAtcStationList getAtcStationsForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getVoiceCapabilityForCallsign
|
||||
BlackMisc::Network::CVoiceCapabilities getVoiceCapabilityForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getDistributors
|
||||
BlackMisc::Simulation::CDistributorList getDistributors() const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::smartDistributorSelector
|
||||
BlackMisc::Simulation::CDistributor smartDistributorSelector(const BlackMisc::Simulation::CDistributor &distributor) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getDistributorsCount
|
||||
int getDistributorsCount() const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getLiveries
|
||||
BlackMisc::Aviation::CLiveryList getLiveries() const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getLiveries
|
||||
int getLiveriesCount() const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getLiveryForCombinedCode
|
||||
BlackMisc::Aviation::CLivery getLiveryForCombinedCode(const QString &combinedCode) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::smartLiverySelector
|
||||
BlackMisc::Aviation::CLivery smartLiverySelector(const Aviation::CLivery &livery) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getModels
|
||||
BlackMisc::Simulation::CAircraftModelList getModels() const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getModelsCount
|
||||
int getModelsCount() const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getModelsForAircraftDesignatorAndLiveryCombinedCode
|
||||
BlackMisc::Simulation::CAircraftModelList getModelsForAircraftDesignatorAndLiveryCombinedCode(const QString &aircraftDesignator, const QString &combinedCode) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getModelForModelString
|
||||
BlackMisc::Simulation::CAircraftModel getModelForModelString(const QString &modelString) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getAircraftIcaoCodes
|
||||
BlackMisc::Aviation::CAircraftIcaoCodeList getAircraftIcaoCodes() const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getAircraftIcaoCodesCount
|
||||
int getAircraftIcaoCodesCount() const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getAircraftIcaoCodeForDesignator
|
||||
BlackMisc::Aviation::CAircraftIcaoCode getAircraftIcaoCodeForDesignator(const QString &designator) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getAircraftIcaoCodeForId
|
||||
BlackMisc::Aviation::CAircraftIcaoCode getAircraftIcaoCodeForDbKey(int id) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getAirlineIcaoCodes
|
||||
BlackMisc::Aviation::CAirlineIcaoCodeList getAirlineIcaoCodes() const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getAirlineIcaoCodesCount
|
||||
int getAirlineIcaoCodesCount() const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getAirlineIcaoCodeForDesignator
|
||||
BlackMisc::Aviation::CAirlineIcaoCode getAirlineIcaoCodeForDesignator(const QString &designator) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getAirlineIcaoCodeForId
|
||||
BlackMisc::Aviation::CAirlineIcaoCode getAirlineIcaoCodeForDbKey(int id) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::smartAircraftIcaoSelector
|
||||
BlackMisc::Aviation::CAircraftIcaoCode smartAircraftIcaoSelector(const BlackMisc::Aviation::CAircraftIcaoCode &icao) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getCountries
|
||||
BlackMisc::CCountryList getCountries() const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getCountriesCount
|
||||
int getCountriesCount() const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getCountryForIsoCode
|
||||
BlackMisc::CCountry getCountryForIsoCode(const QString &iso) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::getCountryForName
|
||||
BlackMisc::CCountry getCountryForName(const QString &name) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::updateWithWebData
|
||||
void updateWithVatsimDataFileData(BlackMisc::Simulation::CSimulatedAircraft &aircraftToBeUdpated) const;
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::asyncWriteModel
|
||||
BlackMisc::CStatusMessageList asyncWriteModel(BlackMisc::Simulation::CAircraftModel &model) 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 IWebDataReaderProvider::connectSwiftDatabaseSignals
|
||||
void connectSwiftDatabaseSignals(
|
||||
QObject *receiver,
|
||||
std::function<void(BlackMisc::Network::CDbFlags::Entity, BlackMisc::Network::CDbFlags::ReadState, int)> dataRead);
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::triggerRead
|
||||
BlackMisc::Network::CDbFlags::Entity triggerRead(BlackMisc::Network::CDbFlags::Entity whatToRead);
|
||||
|
||||
//! \copydoc IWebDataReaderProvider::canConnectSwiftDb
|
||||
bool canConnectSwiftDb() const;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CWebDataServicesAware(IWebDataServicesProvider *webDataReaderProvider = nullptr) : m_webDataReaderProvider(webDataReaderProvider) { }
|
||||
|
||||
private:
|
||||
IWebDataServicesProvider *m_webDataReaderProvider = nullptr; //!< access to object
|
||||
QList<QMetaObject::Connection> 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