Browse Source

replaced qt namespace with services namespace

QGC4.4
jennerl 4 years ago committed by Don Gagne
parent
commit
dde832208e
  1. 14
      src/Airmap/AirMapManager.cc
  2. 16
      src/Airmap/AirMapManager.h
  3. 20
      src/Airmap/AirMapSharedState.h
  4. 10
      src/Airmap/services/advisory.cpp
  5. 2
      src/Airmap/services/advisory.h
  6. 10
      src/Airmap/services/aircrafts.cpp
  7. 2
      src/Airmap/services/aircrafts.h
  8. 8
      src/Airmap/services/airspaces.cpp
  9. 2
      src/Airmap/services/airspaces.h
  10. 10
      src/Airmap/services/authenticator.cpp
  11. 2
      src/Airmap/services/authenticator.h
  12. 76
      src/Airmap/services/client.cpp
  13. 6
      src/Airmap/services/client.h
  14. 20
      src/Airmap/services/dispatcher.cpp
  15. 2
      src/Airmap/services/dispatcher.h
  16. 16
      src/Airmap/services/flight_plans.cpp
  17. 2
      src/Airmap/services/flight_plans.h
  18. 22
      src/Airmap/services/flights.cpp
  19. 2
      src/Airmap/services/flights.h
  20. 22
      src/Airmap/services/logger.cpp
  21. 2
      src/Airmap/services/logger.h
  22. 22
      src/Airmap/services/pilots.cpp
  23. 2
      src/Airmap/services/pilots.h
  24. 14
      src/Airmap/services/rulesets.cpp
  25. 2
      src/Airmap/services/rulesets.h
  26. 10
      src/Airmap/services/status.cpp
  27. 2
      src/Airmap/services/status.h
  28. 6
      src/Airmap/services/telemetry.cpp
  29. 2
      src/Airmap/services/telemetry.h
  30. 16
      src/Airmap/services/traffic.cpp
  31. 2
      src/Airmap/services/traffic.h
  32. 2
      src/Airmap/services/types.cpp
  33. 2
      src/Airmap/services/types.h

14
src/Airmap/AirMapManager.cc

@ -41,12 +41,12 @@ AirMapManager::AirMapManager(QGCApplication* app, QGCToolbox* toolbox)
: AirspaceManager(app, toolbox) : AirspaceManager(app, toolbox)
, _authStatus(Unknown) , _authStatus(Unknown)
{ {
_logger = std::make_shared<qt::Logger>(); _logger = std::make_shared<services::Logger>();
qt::register_types(); // TODO: still needed? services::register_types(); // TODO: still needed?
_logger->logging_category().setEnabled(QtDebugMsg, false); _logger->logging_category().setEnabled(QtDebugMsg, false);
_logger->logging_category().setEnabled(QtInfoMsg, false); _logger->logging_category().setEnabled(QtInfoMsg, false);
_logger->logging_category().setEnabled(QtWarningMsg, false); _logger->logging_category().setEnabled(QtWarningMsg, false);
_dispatchingLogger = std::make_shared<qt::DispatchingLogger>(_logger); _dispatchingLogger = std::make_shared<services::DispatchingLogger>(_logger);
connect(&_shared, &AirMapSharedState::error, this, &AirMapManager::_error); connect(&_shared, &AirMapSharedState::error, this, &AirMapManager::_error);
connect(&_shared, &AirMapSharedState::authStatus, this, &AirMapManager::_authStatusChanged); connect(&_shared, &AirMapSharedState::authStatus, this, &AirMapManager::_authStatusChanged);
} }
@ -170,9 +170,9 @@ AirMapManager::_settingsTimeout()
auto configuration = Client::default_production_configuration(credentials); auto configuration = Client::default_production_configuration(credentials);
configuration.telemetry.host = _telemetryHost; configuration.telemetry.host = _telemetryHost;
configuration.telemetry.port = _telemetryPort; configuration.telemetry.port = _telemetryPort;
qt::Client::create(configuration, _dispatchingLogger, this, [this](const qt::Client::CreateResult& result) { services::Client::create(configuration, _dispatchingLogger, this, [this](const services::Client::CreateResult& result) {
if (result) { if (result) {
qCDebug(AirMapManagerLog) << "Successfully created airmap::qt::Client instance"; qCDebug(AirMapManagerLog) << "Successfully created airmap::services::Client instance";
_shared.setClient(result.value()); _shared.setClient(result.value());
emit connectedChanged(); emit connectedChanged();
_connectStatus = tr("AirMap Enabled"); _connectStatus = tr("AirMap Enabled");
@ -180,10 +180,10 @@ AirMapManager::_settingsTimeout()
//-- Now test authentication //-- Now test authentication
_shared.login(); _shared.login();
} else { } else {
qWarning("Failed to create airmap::qt::Client instance"); qWarning("Failed to create airmap::services::Client instance");
QString description = QString::fromStdString(result.error().description() ? result.error().description().get() : ""); QString description = QString::fromStdString(result.error().description() ? result.error().description().get() : "");
QString error = QString::fromStdString(result.error().message()); QString error = QString::fromStdString(result.error().message());
_error(tr("Failed to create airmap::qt::Client instance"), _error(tr("Failed to create airmap::services::Client instance"),
error, description); error, description);
_connectStatus = error; _connectStatus = error;
if(!description.isEmpty()) { if(!description.isEmpty()) {

16
src/Airmap/AirMapManager.h

@ -60,14 +60,14 @@ private slots:
void _authStatusChanged (AirspaceManager::AuthStatus status); void _authStatusChanged (AirspaceManager::AuthStatus status);
private: private:
QString _connectStatus; QString _connectStatus;
QTimer _settingsTimer; QTimer _settingsTimer;
AirMapSharedState _shared; AirMapSharedState _shared;
std::shared_ptr<airmap::qt::Logger> _logger; std::shared_ptr<airmap::services::Logger> _logger;
std::shared_ptr<airmap::qt::DispatchingLogger> _dispatchingLogger; std::shared_ptr<airmap::services::DispatchingLogger> _dispatchingLogger;
AirspaceManager::AuthStatus _authStatus; AirspaceManager::AuthStatus _authStatus;
const std::string _telemetryHost = "telemetry.airmap.com"; const std::string _telemetryHost = "telemetry.airmap.com";
const uint16_t _telemetryPort = 16060; const uint16_t _telemetryPort = 16060;
}; };

20
src/Airmap/AirMapSharedState.h

@ -35,7 +35,7 @@ public:
void setSettings (const Settings& settings); void setSettings (const Settings& settings);
const Settings& settings () const { return _settings; } const Settings& settings () const { return _settings; }
void setClient (airmap::qt::Client* client) { _client = client; } void setClient (airmap::services::Client* client) { _client = client; }
QString pilotID () { return _pilotID; } QString pilotID () { return _pilotID; }
void setPilotID (const QString& pilotID) { _pilotID = pilotID; } void setPilotID (const QString& pilotID) { _pilotID = pilotID; }
@ -44,9 +44,9 @@ public:
* Get the current client instance. It can be NULL. If not NULL, it implies * Get the current client instance. It can be NULL. If not NULL, it implies
* there's an API key set. * there's an API key set.
*/ */
airmap::qt::Client* client () const { return _client; } airmap::services::Client* client () const { return _client; }
bool hasAPIKey () const { return _settings.apiKey != ""; } bool hasAPIKey () const { return _settings.apiKey != ""; }
bool isLoggedIn () const { return _loginToken != ""; } bool isLoggedIn () const { return _loginToken != ""; }
using Callback = std::function<void(const QString& /* login_token */)>; using Callback = std::function<void(const QString& /* login_token */)>;
@ -67,11 +67,11 @@ private:
void _processPendingRequests (); void _processPendingRequests ();
private: private:
bool _isLoginInProgress = false; bool _isLoginInProgress = false;
QString _loginToken; ///< login token: empty when not logged in QString _loginToken; ///< login token: empty when not logged in
QString _pilotID; QString _pilotID;
airmap::qt::Client* _client = nullptr; airmap::services::Client* _client = nullptr;
Settings _settings; Settings _settings;
QQueue<Callback> _pendingRequests; ///< pending requests that are processed after a successful login QQueue<Callback> _pendingRequests; ///< pending requests that are processed after a successful login
}; };

10
src/Airmap/services/advisory.cpp

@ -1,16 +1,16 @@
#include <Airmap/services/advisory.h> #include <Airmap/services/advisory.h>
std::shared_ptr<airmap::qt::Advisory> airmap::qt::Advisory::create(const std::shared_ptr<Dispatcher>& dispatcher, std::shared_ptr<airmap::services::Advisory> airmap::services::Advisory::create(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) { const std::shared_ptr<airmap::Client>& client) {
return std::shared_ptr<Advisory>{new Advisory{dispatcher, client}}; return std::shared_ptr<Advisory>{new Advisory{dispatcher, client}};
} }
airmap::qt::Advisory::Advisory(const std::shared_ptr<Dispatcher>& dispatcher, airmap::services::Advisory::Advisory(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) const std::shared_ptr<airmap::Client>& client)
: dispatcher_{dispatcher}, client_{client} { : dispatcher_{dispatcher}, client_{client} {
} }
void airmap::qt::Advisory::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) { void airmap::services::Advisory::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->advisory().for_id(parameters, [this, sp, cb](const auto& result) { sp->client_->advisory().for_id(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -18,7 +18,7 @@ void airmap::qt::Advisory::for_id(const ForId::Parameters& parameters, const For
}); });
} }
void airmap::qt::Advisory::search(const Search::Parameters& parameters, const Search::Callback& cb) { void airmap::services::Advisory::search(const Search::Parameters& parameters, const Search::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->advisory().search(parameters, [this, sp, cb](const auto& result) { sp->client_->advisory().search(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -26,7 +26,7 @@ void airmap::qt::Advisory::search(const Search::Parameters& parameters, const Se
}); });
} }
void airmap::qt::Advisory::report_weather(const ReportWeather::Parameters& parameters, void airmap::services::Advisory::report_weather(const ReportWeather::Parameters& parameters,
const ReportWeather::Callback& cb) { const ReportWeather::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->advisory().report_weather(parameters, [this, sp, cb](const auto& result) { sp->client_->advisory().report_weather(parameters, [this, sp, cb](const auto& result) {

2
src/Airmap/services/advisory.h

@ -6,7 +6,7 @@
#include "dispatcher.h" #include "dispatcher.h"
namespace airmap { namespace airmap {
namespace qt { namespace services {
class Advisory : public airmap::Advisory, public std::enable_shared_from_this<Advisory> { class Advisory : public airmap::Advisory, public std::enable_shared_from_this<Advisory> {
public: public:

10
src/Airmap/services/aircrafts.cpp

@ -1,16 +1,16 @@
#include <Airmap/services/aircrafts.h> #include <Airmap/services/aircrafts.h>
std::shared_ptr<airmap::qt::Aircrafts> airmap::qt::Aircrafts::create(const std::shared_ptr<Dispatcher>& dispatcher, std::shared_ptr<airmap::services::Aircrafts> airmap::services::Aircrafts::create(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) { const std::shared_ptr<airmap::Client>& client) {
return std::shared_ptr<Aircrafts>{new Aircrafts{dispatcher, client}}; return std::shared_ptr<Aircrafts>{new Aircrafts{dispatcher, client}};
} }
airmap::qt::Aircrafts::Aircrafts(const std::shared_ptr<Dispatcher>& dispatcher, airmap::services::Aircrafts::Aircrafts(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) const std::shared_ptr<airmap::Client>& client)
: dispatcher_{dispatcher}, client_{client} { : dispatcher_{dispatcher}, client_{client} {
} }
void airmap::qt::Aircrafts::manufacturers(const Manufacturers::Parameters& parameters, void airmap::services::Aircrafts::manufacturers(const Manufacturers::Parameters& parameters,
const Manufacturers::Callback& cb) { const Manufacturers::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->aircrafts().manufacturers(parameters, [this, sp, cb](const auto& result) { sp->client_->aircrafts().manufacturers(parameters, [this, sp, cb](const auto& result) {
@ -19,7 +19,7 @@ void airmap::qt::Aircrafts::manufacturers(const Manufacturers::Parameters& param
}); });
} }
void airmap::qt::Aircrafts::models(const Models::Parameters& parameters, const Models::Callback& cb) { void airmap::services::Aircrafts::models(const Models::Parameters& parameters, const Models::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->aircrafts().models(parameters, [this, sp, cb](const auto& result) { sp->client_->aircrafts().models(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -27,7 +27,7 @@ void airmap::qt::Aircrafts::models(const Models::Parameters& parameters, const M
}); });
} }
void airmap::qt::Aircrafts::model_for_id(const ModelForId::Parameters& parameters, const ModelForId::Callback& cb) { void airmap::services::Aircrafts::model_for_id(const ModelForId::Parameters& parameters, const ModelForId::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->aircrafts().model_for_id(parameters, [this, sp, cb](const auto& result) { sp->client_->aircrafts().model_for_id(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });

2
src/Airmap/services/aircrafts.h

@ -9,7 +9,7 @@
#include <string> #include <string>
namespace airmap { namespace airmap {
namespace qt { namespace services {
class Aircrafts : public airmap::Aircrafts, public std::enable_shared_from_this<Aircrafts> { class Aircrafts : public airmap::Aircrafts, public std::enable_shared_from_this<Aircrafts> {
public: public:

8
src/Airmap/services/airspaces.cpp

@ -1,16 +1,16 @@
#include <Airmap/services/airspaces.h> #include <Airmap/services/airspaces.h>
std::shared_ptr<airmap::qt::Airspaces> airmap::qt::Airspaces::create(const std::shared_ptr<Dispatcher>& dispatcher, std::shared_ptr<airmap::services::Airspaces> airmap::services::Airspaces::create(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) { const std::shared_ptr<airmap::Client>& client) {
return std::shared_ptr<Airspaces>{new Airspaces{dispatcher, client}}; return std::shared_ptr<Airspaces>{new Airspaces{dispatcher, client}};
} }
airmap::qt::Airspaces::Airspaces(const std::shared_ptr<Dispatcher>& dispatcher, airmap::services::Airspaces::Airspaces(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) const std::shared_ptr<airmap::Client>& client)
: dispatcher_{dispatcher}, client_{client} { : dispatcher_{dispatcher}, client_{client} {
} }
void airmap::qt::Airspaces::search(const Search::Parameters& parameters, const Search::Callback& cb) { void airmap::services::Airspaces::search(const Search::Parameters& parameters, const Search::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->airspaces().search(parameters, [this, sp, cb](const auto& result) { sp->client_->airspaces().search(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -18,7 +18,7 @@ void airmap::qt::Airspaces::search(const Search::Parameters& parameters, const S
}); });
} }
void airmap::qt::Airspaces::for_ids(const ForIds::Parameters& parameters, const ForIds::Callback& cb) { void airmap::services::Airspaces::for_ids(const ForIds::Parameters& parameters, const ForIds::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->airspaces().for_ids(parameters, [this, sp, cb](const auto& result) { sp->client_->airspaces().for_ids(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });

2
src/Airmap/services/airspaces.h

@ -8,7 +8,7 @@
#include <memory> #include <memory>
namespace airmap { namespace airmap {
namespace qt { namespace services {
class Airspaces : public airmap::Airspaces, public std::enable_shared_from_this<Airspaces> { class Airspaces : public airmap::Airspaces, public std::enable_shared_from_this<Airspaces> {
public: public:

10
src/Airmap/services/authenticator.cpp

@ -1,16 +1,16 @@
#include <Airmap/services/authenticator.h> #include <Airmap/services/authenticator.h>
std::shared_ptr<airmap::qt::Authenticator> airmap::qt::Authenticator::create( std::shared_ptr<airmap::services::Authenticator> airmap::services::Authenticator::create(
const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client) { const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client) {
return std::shared_ptr<Authenticator>{new Authenticator{dispatcher, client}}; return std::shared_ptr<Authenticator>{new Authenticator{dispatcher, client}};
} }
airmap::qt::Authenticator::Authenticator(const std::shared_ptr<Dispatcher>& dispatcher, airmap::services::Authenticator::Authenticator(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) const std::shared_ptr<airmap::Client>& client)
: dispatcher_{dispatcher}, client_{client} { : dispatcher_{dispatcher}, client_{client} {
} }
void airmap::qt::Authenticator::authenticate_with_password(const AuthenticateWithPassword::Params& parameters, void airmap::services::Authenticator::authenticate_with_password(const AuthenticateWithPassword::Params& parameters,
const AuthenticateWithPassword::Callback& cb) { const AuthenticateWithPassword::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->authenticator().authenticate_with_password(parameters, [this, sp, cb](const auto& result) { sp->client_->authenticator().authenticate_with_password(parameters, [this, sp, cb](const auto& result) {
@ -19,7 +19,7 @@ void airmap::qt::Authenticator::authenticate_with_password(const AuthenticateWit
}); });
} }
void airmap::qt::Authenticator::authenticate_anonymously(const AuthenticateAnonymously::Params& parameters, void airmap::services::Authenticator::authenticate_anonymously(const AuthenticateAnonymously::Params& parameters,
const AuthenticateAnonymously::Callback& cb) { const AuthenticateAnonymously::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->authenticator().authenticate_anonymously(parameters, [this, sp, cb](const auto& result) { sp->client_->authenticator().authenticate_anonymously(parameters, [this, sp, cb](const auto& result) {
@ -28,7 +28,7 @@ void airmap::qt::Authenticator::authenticate_anonymously(const AuthenticateAnony
}); });
} }
void airmap::qt::Authenticator::renew_authentication(const RenewAuthentication::Params& parameters, void airmap::services::Authenticator::renew_authentication(const RenewAuthentication::Params& parameters,
const RenewAuthentication::Callback& cb) { const RenewAuthentication::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->authenticator().renew_authentication(parameters, [this, sp, cb](const auto& result) { sp->client_->authenticator().renew_authentication(parameters, [this, sp, cb](const auto& result) {

2
src/Airmap/services/authenticator.h

@ -8,7 +8,7 @@
#include <memory> #include <memory>
namespace airmap { namespace airmap {
namespace qt { namespace services {
class Authenticator : public airmap::Authenticator, public std::enable_shared_from_this<Authenticator> { class Authenticator : public airmap::Authenticator, public std::enable_shared_from_this<Authenticator> {
public: public:

76
src/Airmap/services/client.cpp

@ -46,24 +46,24 @@ class ContextRunner {
} // namespace } // namespace
struct airmap::qt::Client::Private { struct airmap::services::Client::Private {
explicit Private(const Client::Configuration& configuration, const std::shared_ptr<ContextRunner>& context_runner, explicit Private(const Client::Configuration& configuration, const std::shared_ptr<ContextRunner>& context_runner,
const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client) const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client)
: configuration_{configuration}, : configuration_{configuration},
context_runner_{context_runner}, context_runner_{context_runner},
dispatcher_{dispatcher}, dispatcher_{dispatcher},
client_{client}, client_{client},
advisory_{airmap::qt::Advisory::create(dispatcher_, client_)}, advisory_{airmap::services::Advisory::create(dispatcher_, client_)},
aircrafts_{airmap::qt::Aircrafts::create(dispatcher_, client_)}, aircrafts_{airmap::services::Aircrafts::create(dispatcher_, client_)},
airspaces_{airmap::qt::Airspaces::create(dispatcher_, client_)}, airspaces_{airmap::services::Airspaces::create(dispatcher_, client_)},
authenticator_{airmap::qt::Authenticator::create(dispatcher_, client_)}, authenticator_{airmap::services::Authenticator::create(dispatcher_, client_)},
flight_plans_{airmap::qt::FlightPlans::create(dispatcher_, client_)}, flight_plans_{airmap::services::FlightPlans::create(dispatcher_, client_)},
flights_{airmap::qt::Flights::create(dispatcher_, client_)}, flights_{airmap::services::Flights::create(dispatcher_, client_)},
pilots_{airmap::qt::Pilots::create(dispatcher_, client_)}, pilots_{airmap::services::Pilots::create(dispatcher_, client_)},
rulesets_{airmap::qt::RuleSets::create(dispatcher_, client_)}, rulesets_{airmap::services::RuleSets::create(dispatcher_, client_)},
status_{airmap::qt::Status::create(dispatcher_, client_)}, status_{airmap::services::Status::create(dispatcher_, client_)},
telemetry_{airmap::qt::Telemetry::create(dispatcher_, client_)}, telemetry_{airmap::services::Telemetry::create(dispatcher_, client_)},
traffic_{airmap::qt::Traffic::create(dispatcher_, client_)} { traffic_{airmap::services::Traffic::create(dispatcher_, client_)} {
} }
~Private() { ~Private() {
@ -72,22 +72,22 @@ struct airmap::qt::Client::Private {
Client::Configuration configuration_; Client::Configuration configuration_;
std::shared_ptr<ContextRunner> context_runner_; std::shared_ptr<ContextRunner> context_runner_;
std::shared_ptr<airmap::qt::Dispatcher> dispatcher_; std::shared_ptr<airmap::services::Dispatcher> dispatcher_;
std::shared_ptr<airmap::Client> client_; std::shared_ptr<airmap::Client> client_;
std::shared_ptr<airmap::qt::Advisory> advisory_; std::shared_ptr<airmap::services::Advisory> advisory_;
std::shared_ptr<airmap::qt::Aircrafts> aircrafts_; std::shared_ptr<airmap::services::Aircrafts> aircrafts_;
std::shared_ptr<airmap::qt::Airspaces> airspaces_; std::shared_ptr<airmap::services::Airspaces> airspaces_;
std::shared_ptr<airmap::qt::Authenticator> authenticator_; std::shared_ptr<airmap::services::Authenticator> authenticator_;
std::shared_ptr<airmap::qt::FlightPlans> flight_plans_; std::shared_ptr<airmap::services::FlightPlans> flight_plans_;
std::shared_ptr<airmap::qt::Flights> flights_; std::shared_ptr<airmap::services::Flights> flights_;
std::shared_ptr<airmap::qt::Pilots> pilots_; std::shared_ptr<airmap::services::Pilots> pilots_;
std::shared_ptr<airmap::qt::RuleSets> rulesets_; std::shared_ptr<airmap::services::RuleSets> rulesets_;
std::shared_ptr<airmap::qt::Status> status_; std::shared_ptr<airmap::services::Status> status_;
std::shared_ptr<airmap::qt::Telemetry> telemetry_; std::shared_ptr<airmap::services::Telemetry> telemetry_;
std::shared_ptr<airmap::qt::Traffic> traffic_; std::shared_ptr<airmap::services::Traffic> traffic_;
}; };
void airmap::qt::Client::create(const Client::Configuration& configuration, const std::shared_ptr<Logger>& logger, void airmap::services::Client::create(const Client::Configuration& configuration, const std::shared_ptr<Logger>& logger,
QObject* parent, const CreateCallback& cb) { QObject* parent, const CreateCallback& cb) {
register_types(); register_types();
@ -115,52 +115,52 @@ void airmap::qt::Client::create(const Client::Configuration& configuration, cons
} }
} }
airmap::qt::Client::Client(std::unique_ptr<Private>&& d, QObject* parent) : QObject{parent}, d_{std::move(d)} { airmap::services::Client::Client(std::unique_ptr<Private>&& d, QObject* parent) : QObject{parent}, d_{std::move(d)} {
} }
airmap::qt::Client::~Client() = default; airmap::services::Client::~Client() = default;
// From airmap::Client // From airmap::Client
airmap::Authenticator& airmap::qt::Client::authenticator() { airmap::Authenticator& airmap::services::Client::authenticator() {
return *d_->authenticator_; return *d_->authenticator_;
} }
airmap::Advisory& airmap::qt::Client::advisory() { airmap::Advisory& airmap::services::Client::advisory() {
return *d_->advisory_; return *d_->advisory_;
} }
airmap::Aircrafts& airmap::qt::Client::aircrafts() { airmap::Aircrafts& airmap::services::Client::aircrafts() {
return *d_->aircrafts_; return *d_->aircrafts_;
} }
airmap::Airspaces& airmap::qt::Client::airspaces() { airmap::Airspaces& airmap::services::Client::airspaces() {
return *d_->airspaces_; return *d_->airspaces_;
} }
airmap::FlightPlans& airmap::qt::Client::flight_plans() { airmap::FlightPlans& airmap::services::Client::flight_plans() {
return *d_->flight_plans_; return *d_->flight_plans_;
} }
airmap::Flights& airmap::qt::Client::flights() { airmap::Flights& airmap::services::Client::flights() {
return *d_->flights_; return *d_->flights_;
} }
airmap::Pilots& airmap::qt::Client::pilots() { airmap::Pilots& airmap::services::Client::pilots() {
return *d_->pilots_; return *d_->pilots_;
} }
airmap::RuleSets& airmap::qt::Client::rulesets() { airmap::RuleSets& airmap::services::Client::rulesets() {
return *d_->rulesets_; return *d_->rulesets_;
} }
airmap::Status& airmap::qt::Client::status() { airmap::Status& airmap::services::Client::status() {
return *d_->status_; return *d_->status_;
} }
airmap::Telemetry& airmap::qt::Client::telemetry() { airmap::Telemetry& airmap::services::Client::telemetry() {
return *d_->telemetry_; return *d_->telemetry_;
} }
airmap::Traffic& airmap::qt::Client::traffic() { airmap::Traffic& airmap::services::Client::traffic() {
return *d_->traffic_; return *d_->traffic_;
} }

6
src/Airmap/services/client.h

@ -11,9 +11,9 @@
#include <QObject> #include <QObject>
namespace airmap { namespace airmap {
/// @namespace namespace qt bundles up types and functions that help with integrating AirMap functionality /// @namespace namespace services bundles up types and functions that help with integrating AirMap functionality
/// into Qt-based applications and libraries. /// into Qt-based applications and libraries.
namespace qt { namespace services {
/// Client implements the airmap::Client interface, bridging over between /// Client implements the airmap::Client interface, bridging over between
/// the Qt event loop and the native event loop of the airmap::Client. /// the Qt event loop and the native event loop of the airmap::Client.
@ -60,6 +60,6 @@ class AIRMAP_EXPORT Client : public QObject, public airmap::Client {
} // namespace airmap } // namespace airmap
/// @example qt/client.cpp /// @example qt/client.cpp
/// Illustrates how to use airmap::qt::Client, airmap::qt::DispatchingLogger and airmap::qt::Logger. /// Illustrates how to use airmap::services::Client, airmap::services::DispatchingLogger and airmap::services::Logger.
#endif // AIRMAP_QT_CLIENT_H_ #endif // AIRMAP_QT_CLIENT_H_

20
src/Airmap/services/dispatcher.cpp

@ -5,32 +5,32 @@
#include <cassert> #include <cassert>
QEvent::Type airmap::qt::Dispatcher::Event::registered_type() { QEvent::Type airmap::services::Dispatcher::Event::registered_type() {
static const Type rt = static_cast<Type>(registerEventType()); static const Type rt = static_cast<Type>(registerEventType());
return rt; return rt;
} }
airmap::qt::Dispatcher::Event::Event(const std::function<void()>& task) : QEvent{registered_type()}, task_{task} { airmap::services::Dispatcher::Event::Event(const std::function<void()>& task) : QEvent{registered_type()}, task_{task} {
} }
void airmap::qt::Dispatcher::Event::dispatch() { void airmap::services::Dispatcher::Event::dispatch() {
task_(); task_();
} }
std::shared_ptr<airmap::qt::Dispatcher::ToQt> airmap::qt::Dispatcher::ToQt::create() { std::shared_ptr<airmap::services::Dispatcher::ToQt> airmap::services::Dispatcher::ToQt::create() {
return std::shared_ptr<ToQt>{new ToQt{}}; return std::shared_ptr<ToQt>{new ToQt{}};
} }
airmap::qt::Dispatcher::ToQt::ToQt() { airmap::services::Dispatcher::ToQt::ToQt() {
} }
void airmap::qt::Dispatcher::ToQt::dispatch(const Task& task) { void airmap::services::Dispatcher::ToQt::dispatch(const Task& task) {
auto sp = shared_from_this(); auto sp = shared_from_this();
QCoreApplication::postEvent(this, new Event{[sp, task]() { task(); }}); QCoreApplication::postEvent(this, new Event{[sp, task]() { task(); }});
} }
bool airmap::qt::Dispatcher::ToQt::event(QEvent* event) { bool airmap::services::Dispatcher::ToQt::event(QEvent* event) {
assert(QCoreApplication::instance()); assert(QCoreApplication::instance());
assert(QThread::currentThread() == QCoreApplication::instance()->thread()); assert(QThread::currentThread() == QCoreApplication::instance()->thread());
@ -47,15 +47,15 @@ bool airmap::qt::Dispatcher::ToQt::event(QEvent* event) {
return false; return false;
} }
airmap::qt::Dispatcher::Dispatcher(const std::shared_ptr<Context>& context) airmap::services::Dispatcher::Dispatcher(const std::shared_ptr<Context>& context)
: to_qt_{ToQt::create()}, context_{context} { : to_qt_{ToQt::create()}, context_{context} {
} }
void airmap::qt::Dispatcher::dispatch_to_qt(const std::function<void()>& task) { void airmap::services::Dispatcher::dispatch_to_qt(const std::function<void()>& task) {
to_qt_->dispatch(task); to_qt_->dispatch(task);
} }
void airmap::qt::Dispatcher::dispatch_to_airmap(const std::function<void()>& task) { void airmap::services::Dispatcher::dispatch_to_airmap(const std::function<void()>& task) {
context_->schedule_in(task); context_->schedule_in(task);
} }

2
src/Airmap/services/dispatcher.h

@ -9,7 +9,7 @@
#include <functional> #include <functional>
#include <memory> #include <memory>
namespace airmap { namespace airmap {
namespace qt { namespace services {
class Dispatcher : public QObject { class Dispatcher : public QObject {
public: public:

16
src/Airmap/services/flight_plans.cpp

@ -1,16 +1,16 @@
#include <Airmap/services/flight_plans.h> #include <Airmap/services/flight_plans.h>
std::shared_ptr<airmap::qt::FlightPlans> airmap::qt::FlightPlans::create( std::shared_ptr<airmap::services::FlightPlans> airmap::services::FlightPlans::create(
const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client) { const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client) {
return std::shared_ptr<FlightPlans>{new FlightPlans{dispatcher, client}}; return std::shared_ptr<FlightPlans>{new FlightPlans{dispatcher, client}};
} }
airmap::qt::FlightPlans::FlightPlans(const std::shared_ptr<Dispatcher>& dispatcher, airmap::services::FlightPlans::FlightPlans(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) const std::shared_ptr<airmap::Client>& client)
: dispatcher_{dispatcher}, client_{client} { : dispatcher_{dispatcher}, client_{client} {
} }
void airmap::qt::FlightPlans::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) { void airmap::services::FlightPlans::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flight_plans().for_id(parameters, [this, sp, cb](const auto& result) { sp->client_->flight_plans().for_id(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -18,7 +18,7 @@ void airmap::qt::FlightPlans::for_id(const ForId::Parameters& parameters, const
}); });
} }
void airmap::qt::FlightPlans::create_by_polygon(const Create::Parameters& parameters, const Create::Callback& cb) { void airmap::services::FlightPlans::create_by_polygon(const Create::Parameters& parameters, const Create::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flight_plans().create_by_polygon(parameters, [this, sp, cb](const auto& result) { sp->client_->flight_plans().create_by_polygon(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -26,7 +26,7 @@ void airmap::qt::FlightPlans::create_by_polygon(const Create::Parameters& parame
}); });
} }
void airmap::qt::FlightPlans::update(const Update::Parameters& parameters, const Update::Callback& cb) { void airmap::services::FlightPlans::update(const Update::Parameters& parameters, const Update::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flight_plans().update(parameters, [this, sp, cb](const auto& result) { sp->client_->flight_plans().update(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -34,7 +34,7 @@ void airmap::qt::FlightPlans::update(const Update::Parameters& parameters, const
}); });
} }
void airmap::qt::FlightPlans::delete_(const Delete::Parameters& parameters, const Delete::Callback& cb) { void airmap::services::FlightPlans::delete_(const Delete::Parameters& parameters, const Delete::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flight_plans().delete_(parameters, [this, sp, cb](const auto& result) { sp->client_->flight_plans().delete_(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -42,7 +42,7 @@ void airmap::qt::FlightPlans::delete_(const Delete::Parameters& parameters, cons
}); });
} }
void airmap::qt::FlightPlans::render_briefing(const RenderBriefing::Parameters& parameters, void airmap::services::FlightPlans::render_briefing(const RenderBriefing::Parameters& parameters,
const RenderBriefing::Callback& cb) { const RenderBriefing::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flight_plans().render_briefing(parameters, [this, sp, cb](const auto& result) { sp->client_->flight_plans().render_briefing(parameters, [this, sp, cb](const auto& result) {
@ -51,7 +51,7 @@ void airmap::qt::FlightPlans::render_briefing(const RenderBriefing::Parameters&
}); });
} }
void airmap::qt::FlightPlans::submit(const Submit::Parameters& parameters, const Submit::Callback& cb) { void airmap::services::FlightPlans::submit(const Submit::Parameters& parameters, const Submit::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flight_plans().submit(parameters, [this, sp, cb](const auto& result) { sp->client_->flight_plans().submit(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });

2
src/Airmap/services/flight_plans.h

@ -8,7 +8,7 @@
#include <memory> #include <memory>
namespace airmap { namespace airmap {
namespace qt { namespace services {
/// FlightPlans provides functionality for managing flight plans. /// FlightPlans provides functionality for managing flight plans.
class FlightPlans : public airmap::FlightPlans, public std::enable_shared_from_this<FlightPlans> { class FlightPlans : public airmap::FlightPlans, public std::enable_shared_from_this<FlightPlans> {

22
src/Airmap/services/flights.cpp

@ -1,16 +1,16 @@
#include <Airmap/services/flights.h> #include <Airmap/services/flights.h>
std::shared_ptr<airmap::qt::Flights> airmap::qt::Flights::create(const std::shared_ptr<Dispatcher>& dispatcher, std::shared_ptr<airmap::services::Flights> airmap::services::Flights::create(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) { const std::shared_ptr<airmap::Client>& client) {
return std::shared_ptr<Flights>{new Flights{dispatcher, client}}; return std::shared_ptr<Flights>{new Flights{dispatcher, client}};
} }
airmap::qt::Flights::Flights(const std::shared_ptr<Dispatcher>& dispatcher, airmap::services::Flights::Flights(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) const std::shared_ptr<airmap::Client>& client)
: dispatcher_{dispatcher}, client_{client} { : dispatcher_{dispatcher}, client_{client} {
} }
void airmap::qt::Flights::search(const Search::Parameters& parameters, const Search::Callback& cb) { void airmap::services::Flights::search(const Search::Parameters& parameters, const Search::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flights().search(parameters, [this, sp, cb](const auto& result) { sp->client_->flights().search(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -18,7 +18,7 @@ void airmap::qt::Flights::search(const Search::Parameters& parameters, const Sea
}); });
} }
void airmap::qt::Flights::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) { void airmap::services::Flights::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flights().for_id(parameters, [this, sp, cb](const auto& result) { sp->client_->flights().for_id(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -26,7 +26,7 @@ void airmap::qt::Flights::for_id(const ForId::Parameters& parameters, const ForI
}); });
} }
void airmap::qt::Flights::create_flight_by_point(const CreateFlight::Parameters& parameters, void airmap::services::Flights::create_flight_by_point(const CreateFlight::Parameters& parameters,
const CreateFlight::Callback& cb) { const CreateFlight::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flights().create_flight_by_point(parameters, [this, sp, cb](const auto& result) { sp->client_->flights().create_flight_by_point(parameters, [this, sp, cb](const auto& result) {
@ -35,7 +35,7 @@ void airmap::qt::Flights::create_flight_by_point(const CreateFlight::Parameters&
}); });
} }
void airmap::qt::Flights::create_flight_by_path(const CreateFlight::Parameters& parameters, void airmap::services::Flights::create_flight_by_path(const CreateFlight::Parameters& parameters,
const CreateFlight::Callback& cb) { const CreateFlight::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flights().create_flight_by_path(parameters, [this, sp, cb](const auto& result) { sp->client_->flights().create_flight_by_path(parameters, [this, sp, cb](const auto& result) {
@ -44,7 +44,7 @@ void airmap::qt::Flights::create_flight_by_path(const CreateFlight::Parameters&
}); });
} }
void airmap::qt::Flights::create_flight_by_polygon(const CreateFlight::Parameters& parameters, void airmap::services::Flights::create_flight_by_polygon(const CreateFlight::Parameters& parameters,
const CreateFlight::Callback& cb) { const CreateFlight::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flights().create_flight_by_polygon(parameters, [this, sp, cb](const auto& result) { sp->client_->flights().create_flight_by_polygon(parameters, [this, sp, cb](const auto& result) {
@ -53,7 +53,7 @@ void airmap::qt::Flights::create_flight_by_polygon(const CreateFlight::Parameter
}); });
} }
void airmap::qt::Flights::end_flight(const EndFlight::Parameters& parameters, const EndFlight::Callback& cb) { void airmap::services::Flights::end_flight(const EndFlight::Parameters& parameters, const EndFlight::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flights().end_flight(parameters, [this, sp, cb](const auto& result) { sp->client_->flights().end_flight(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -61,7 +61,7 @@ void airmap::qt::Flights::end_flight(const EndFlight::Parameters& parameters, co
}); });
} }
void airmap::qt::Flights::delete_flight(const DeleteFlight::Parameters& parameters, const DeleteFlight::Callback& cb) { void airmap::services::Flights::delete_flight(const DeleteFlight::Parameters& parameters, const DeleteFlight::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flights().delete_flight(parameters, [this, sp, cb](const auto& result) { sp->client_->flights().delete_flight(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -69,7 +69,7 @@ void airmap::qt::Flights::delete_flight(const DeleteFlight::Parameters& paramete
}); });
} }
void airmap::qt::Flights::start_flight_communications(const StartFlightCommunications::Parameters& parameters, void airmap::services::Flights::start_flight_communications(const StartFlightCommunications::Parameters& parameters,
const StartFlightCommunications::Callback& cb) { const StartFlightCommunications::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flights().start_flight_communications(parameters, [this, sp, cb](const auto& result) { sp->client_->flights().start_flight_communications(parameters, [this, sp, cb](const auto& result) {
@ -78,7 +78,7 @@ void airmap::qt::Flights::start_flight_communications(const StartFlightCommunica
}); });
} }
void airmap::qt::Flights::end_flight_communications(const EndFlightCommunications::Parameters& parameters, void airmap::services::Flights::end_flight_communications(const EndFlightCommunications::Parameters& parameters,
const EndFlightCommunications::Callback& cb) { const EndFlightCommunications::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->flights().end_flight_communications(parameters, [this, sp, cb](const auto& result) { sp->client_->flights().end_flight_communications(parameters, [this, sp, cb](const auto& result) {

2
src/Airmap/services/flights.h

@ -8,7 +8,7 @@
#include <memory> #include <memory>
namespace airmap { namespace airmap {
namespace qt { namespace services {
class Flights : public airmap::Flights, public std::enable_shared_from_this<Flights> { class Flights : public airmap::Flights, public std::enable_shared_from_this<Flights> {
public: public:

22
src/Airmap/services/logger.cpp

@ -2,26 +2,26 @@
#include <Airmap/services/dispatcher.h> #include <Airmap/services/dispatcher.h>
struct airmap::qt::Logger::Private { struct airmap::services::Logger::Private {
QLoggingCategory logging_category{"airmap"}; QLoggingCategory logging_category{"airmap"};
}; };
struct airmap::qt::DispatchingLogger::Private { struct airmap::services::DispatchingLogger::Private {
std::shared_ptr<airmap::Logger> next; std::shared_ptr<airmap::Logger> next;
std::shared_ptr<Dispatcher::ToQt> dispatcher; std::shared_ptr<Dispatcher::ToQt> dispatcher;
}; };
airmap::qt::Logger::Logger() : d_{new Private{}} { airmap::services::Logger::Logger() : d_{new Private{}} {
} }
airmap::qt::Logger::~Logger() { airmap::services::Logger::~Logger() {
} }
QLoggingCategory& airmap::qt::Logger::logging_category() { QLoggingCategory& airmap::services::Logger::logging_category() {
static QLoggingCategory lc{"airmap"}; static QLoggingCategory lc{"airmap"};
return lc; return lc;
} }
void airmap::qt::Logger::log(Severity severity, const char* message, const char*) { void airmap::services::Logger::log(Severity severity, const char* message, const char*) {
switch (severity) { switch (severity) {
case Severity::debug: case Severity::debug:
qCDebug(logging_category(), "%s", message); qCDebug(logging_category(), "%s", message);
@ -37,7 +37,7 @@ void airmap::qt::Logger::log(Severity severity, const char* message, const char*
} }
} }
bool airmap::qt::Logger::should_log(Severity severity, const char*, const char*) { bool airmap::services::Logger::should_log(Severity severity, const char*, const char*) {
switch (severity) { switch (severity) {
case Severity::debug: case Severity::debug:
return logging_category().isDebugEnabled(); return logging_category().isDebugEnabled();
@ -52,14 +52,14 @@ bool airmap::qt::Logger::should_log(Severity severity, const char*, const char*)
return true; return true;
} }
airmap::qt::DispatchingLogger::DispatchingLogger(const std::shared_ptr<airmap::Logger>& next) airmap::services::DispatchingLogger::DispatchingLogger(const std::shared_ptr<airmap::Logger>& next)
: d_{new Private{next, Dispatcher::ToQt::create()}} { : d_{new Private{next, Dispatcher::ToQt::create()}} {
} }
airmap::qt::DispatchingLogger::~DispatchingLogger() { airmap::services::DispatchingLogger::~DispatchingLogger() {
} }
void airmap::qt::DispatchingLogger::log(Severity severity, const char* message, const char* component) { void airmap::services::DispatchingLogger::log(Severity severity, const char* message, const char* component) {
std::string cmessage{message}; std::string cmessage{message};
std::string ccomponent{component}; std::string ccomponent{component};
auto cnext{d_->next}; auto cnext{d_->next};
@ -70,7 +70,7 @@ void airmap::qt::DispatchingLogger::log(Severity severity, const char* message,
}); });
} }
bool airmap::qt::DispatchingLogger::should_log(Severity, const char*, const char*) { bool airmap::services::DispatchingLogger::should_log(Severity, const char*, const char*) {
// We have to accept all incoming log messages and postpone // We have to accept all incoming log messages and postpone
// the actual evaluation of should_log in the context of next until we // the actual evaluation of should_log in the context of next until we
// run on the correct thread. // run on the correct thread.

2
src/Airmap/services/logger.h

@ -9,7 +9,7 @@
#include <memory> #include <memory>
namespace airmap { namespace airmap {
namespace qt { namespace services {
/// Logger is an airmap::Logger implementation that uses to /// Logger is an airmap::Logger implementation that uses to
/// Qt's logging facilities. /// Qt's logging facilities.

22
src/Airmap/services/pilots.cpp

@ -1,15 +1,15 @@
#include <Airmap/services/pilots.h> #include <Airmap/services/pilots.h>
std::shared_ptr<airmap::qt::Pilots> airmap::qt::Pilots::create(const std::shared_ptr<Dispatcher>& dispatcher, std::shared_ptr<airmap::services::Pilots> airmap::services::Pilots::create(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) { const std::shared_ptr<airmap::Client>& client) {
return std::shared_ptr<Pilots>{new Pilots{dispatcher, client}}; return std::shared_ptr<Pilots>{new Pilots{dispatcher, client}};
} }
airmap::qt::Pilots::Pilots(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client) airmap::services::Pilots::Pilots(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client)
: dispatcher_{dispatcher}, client_{client} { : dispatcher_{dispatcher}, client_{client} {
} }
void airmap::qt::Pilots::authenticated(const Authenticated::Parameters& parameters, const Authenticated::Callback& cb) { void airmap::services::Pilots::authenticated(const Authenticated::Parameters& parameters, const Authenticated::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->pilots().authenticated(parameters, [this, sp, cb](const auto& result) { sp->client_->pilots().authenticated(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -17,7 +17,7 @@ void airmap::qt::Pilots::authenticated(const Authenticated::Parameters& paramete
}); });
} }
void airmap::qt::Pilots::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) { void airmap::services::Pilots::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->pilots().for_id(parameters, [this, sp, cb](const auto& result) { sp->client_->pilots().for_id(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -25,7 +25,7 @@ void airmap::qt::Pilots::for_id(const ForId::Parameters& parameters, const ForId
}); });
} }
void airmap::qt::Pilots::update_for_id(const UpdateForId::Parameters& parameters, const UpdateForId::Callback& cb) { void airmap::services::Pilots::update_for_id(const UpdateForId::Parameters& parameters, const UpdateForId::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->pilots().update_for_id(parameters, [this, sp, cb](const auto& result) { sp->client_->pilots().update_for_id(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -33,7 +33,7 @@ void airmap::qt::Pilots::update_for_id(const UpdateForId::Parameters& parameters
}); });
} }
void airmap::qt::Pilots::start_verify_pilot_phone_for_id(const StartVerifyPilotPhoneForId::Parameters& parameters, void airmap::services::Pilots::start_verify_pilot_phone_for_id(const StartVerifyPilotPhoneForId::Parameters& parameters,
const StartVerifyPilotPhoneForId::Callback& cb) { const StartVerifyPilotPhoneForId::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->pilots().start_verify_pilot_phone_for_id(parameters, [this, sp, cb](const auto& result) { sp->client_->pilots().start_verify_pilot_phone_for_id(parameters, [this, sp, cb](const auto& result) {
@ -42,7 +42,7 @@ void airmap::qt::Pilots::start_verify_pilot_phone_for_id(const StartVerifyPilotP
}); });
} }
void airmap::qt::Pilots::finish_verify_pilot_phone_for_id(const FinishVerifyPilotPhoneForId::Parameters& parameters, void airmap::services::Pilots::finish_verify_pilot_phone_for_id(const FinishVerifyPilotPhoneForId::Parameters& parameters,
const FinishVerifyPilotPhoneForId::Callback& cb) { const FinishVerifyPilotPhoneForId::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->pilots().finish_verify_pilot_phone_for_id(parameters, [this, sp, cb](const auto& result) { sp->client_->pilots().finish_verify_pilot_phone_for_id(parameters, [this, sp, cb](const auto& result) {
@ -51,7 +51,7 @@ void airmap::qt::Pilots::finish_verify_pilot_phone_for_id(const FinishVerifyPilo
}); });
} }
void airmap::qt::Pilots::aircrafts(const Aircrafts::Parameters& parameters, const Aircrafts::Callback& cb) { void airmap::services::Pilots::aircrafts(const Aircrafts::Parameters& parameters, const Aircrafts::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->pilots().aircrafts(parameters, [this, sp, cb](const auto& result) { sp->client_->pilots().aircrafts(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -59,7 +59,7 @@ void airmap::qt::Pilots::aircrafts(const Aircrafts::Parameters& parameters, cons
}); });
} }
void airmap::qt::Pilots::add_aircraft(const AddAircraft::Parameters& parameters, const AddAircraft::Callback& cb) { void airmap::services::Pilots::add_aircraft(const AddAircraft::Parameters& parameters, const AddAircraft::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->pilots().add_aircraft(parameters, [this, sp, cb](const auto& result) { sp->client_->pilots().add_aircraft(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -67,7 +67,7 @@ void airmap::qt::Pilots::add_aircraft(const AddAircraft::Parameters& parameters,
}); });
} }
void airmap::qt::Pilots::delete_aircraft(const DeleteAircraft::Parameters& parameters, void airmap::services::Pilots::delete_aircraft(const DeleteAircraft::Parameters& parameters,
const DeleteAircraft::Callback& cb) { const DeleteAircraft::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->pilots().delete_aircraft(parameters, [this, sp, cb](const auto& result) { sp->client_->pilots().delete_aircraft(parameters, [this, sp, cb](const auto& result) {
@ -76,7 +76,7 @@ void airmap::qt::Pilots::delete_aircraft(const DeleteAircraft::Parameters& param
}); });
} }
void airmap::qt::Pilots::update_aircraft(const UpdateAircraft::Parameters& parameters, void airmap::services::Pilots::update_aircraft(const UpdateAircraft::Parameters& parameters,
const UpdateAircraft::Callback& cb) { const UpdateAircraft::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->pilots().update_aircraft(parameters, [this, sp, cb](const auto& result) { sp->client_->pilots().update_aircraft(parameters, [this, sp, cb](const auto& result) {

2
src/Airmap/services/pilots.h

@ -9,7 +9,7 @@
#include <memory> #include <memory>
namespace airmap { namespace airmap {
namespace qt { namespace services {
class Pilots : public airmap::Pilots, public std::enable_shared_from_this<Pilots> { class Pilots : public airmap::Pilots, public std::enable_shared_from_this<Pilots> {
public: public:

14
src/Airmap/services/rulesets.cpp

@ -1,16 +1,16 @@
#include <Airmap/services/rulesets.h> #include <Airmap/services/rulesets.h>
std::shared_ptr<airmap::qt::RuleSets> airmap::qt::RuleSets::create(const std::shared_ptr<Dispatcher>& dispatcher, std::shared_ptr<airmap::services::RuleSets> airmap::services::RuleSets::create(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) { const std::shared_ptr<airmap::Client>& client) {
return std::shared_ptr<RuleSets>{new RuleSets{dispatcher, client}}; return std::shared_ptr<RuleSets>{new RuleSets{dispatcher, client}};
} }
airmap::qt::RuleSets::RuleSets(const std::shared_ptr<Dispatcher>& dispatcher, airmap::services::RuleSets::RuleSets(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) const std::shared_ptr<airmap::Client>& client)
: dispatcher_{dispatcher}, client_{client} { : dispatcher_{dispatcher}, client_{client} {
} }
void airmap::qt::RuleSets::search(const Search::Parameters& parameters, const Search::Callback& cb) { void airmap::services::RuleSets::search(const Search::Parameters& parameters, const Search::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->rulesets().search(parameters, [this, sp, cb](const auto& result) { sp->client_->rulesets().search(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -18,7 +18,7 @@ void airmap::qt::RuleSets::search(const Search::Parameters& parameters, const Se
}); });
} }
void airmap::qt::RuleSets::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) { void airmap::services::RuleSets::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->rulesets().for_id(parameters, [this, sp, cb](const auto& result) { sp->client_->rulesets().for_id(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -26,7 +26,7 @@ void airmap::qt::RuleSets::for_id(const ForId::Parameters& parameters, const For
}); });
} }
void airmap::qt::RuleSets::fetch_rules(const FetchRules::Parameters& parameters, const FetchRules::Callback& cb) { void airmap::services::RuleSets::fetch_rules(const FetchRules::Parameters& parameters, const FetchRules::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->rulesets().fetch_rules(parameters, [this, sp, cb](const auto& result) { sp->client_->rulesets().fetch_rules(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -34,7 +34,7 @@ void airmap::qt::RuleSets::fetch_rules(const FetchRules::Parameters& parameters,
}); });
} }
void airmap::qt::RuleSets::evaluate_rulesets(const EvaluateRules::Parameters& parameters, void airmap::services::RuleSets::evaluate_rulesets(const EvaluateRules::Parameters& parameters,
const EvaluateRules::Callback& cb) { const EvaluateRules::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->rulesets().evaluate_rulesets(parameters, [this, sp, cb](const auto& result) { sp->client_->rulesets().evaluate_rulesets(parameters, [this, sp, cb](const auto& result) {
@ -43,7 +43,7 @@ void airmap::qt::RuleSets::evaluate_rulesets(const EvaluateRules::Parameters& pa
}); });
} }
void airmap::qt::RuleSets::evaluate_flight_plan(const EvaluateFlightPlan::Parameters& parameters, void airmap::services::RuleSets::evaluate_flight_plan(const EvaluateFlightPlan::Parameters& parameters,
const EvaluateFlightPlan::Callback& cb) { const EvaluateFlightPlan::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->rulesets().evaluate_flight_plan(parameters, [this, sp, cb](const auto& result) { sp->client_->rulesets().evaluate_flight_plan(parameters, [this, sp, cb](const auto& result) {

2
src/Airmap/services/rulesets.h

@ -6,7 +6,7 @@
#include <airmap/rulesets.h> #include <airmap/rulesets.h>
namespace airmap { namespace airmap {
namespace qt { namespace services {
class RuleSets : public airmap::RuleSets, public std::enable_shared_from_this<RuleSets> { class RuleSets : public airmap::RuleSets, public std::enable_shared_from_this<RuleSets> {
public: public:

10
src/Airmap/services/status.cpp

@ -1,15 +1,15 @@
#include <Airmap/services/status.h> #include <Airmap/services/status.h>
std::shared_ptr<airmap::qt::Status> airmap::qt::Status::create(const std::shared_ptr<Dispatcher>& dispatcher, std::shared_ptr<airmap::services::Status> airmap::services::Status::create(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) { const std::shared_ptr<airmap::Client>& client) {
return std::shared_ptr<Status>{new Status{dispatcher, client}}; return std::shared_ptr<Status>{new Status{dispatcher, client}};
} }
airmap::qt::Status::Status(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client) airmap::services::Status::Status(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client)
: dispatcher_{dispatcher}, client_{client} { : dispatcher_{dispatcher}, client_{client} {
} }
void airmap::qt::Status::get_status_by_point(const GetStatus::Parameters& parameters, const GetStatus::Callback& cb) { void airmap::services::Status::get_status_by_point(const GetStatus::Parameters& parameters, const GetStatus::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->status().get_status_by_point(parameters, [this, sp, cb](const auto& result) { sp->client_->status().get_status_by_point(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -17,7 +17,7 @@ void airmap::qt::Status::get_status_by_point(const GetStatus::Parameters& parame
}); });
} }
void airmap::qt::Status::get_status_by_path(const GetStatus::Parameters& parameters, const GetStatus::Callback& cb) { void airmap::services::Status::get_status_by_path(const GetStatus::Parameters& parameters, const GetStatus::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->status().get_status_by_path(parameters, [this, sp, cb](const auto& result) { sp->client_->status().get_status_by_path(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });
@ -25,7 +25,7 @@ void airmap::qt::Status::get_status_by_path(const GetStatus::Parameters& paramet
}); });
} }
void airmap::qt::Status::get_status_by_polygon(const GetStatus::Parameters& parameters, const GetStatus::Callback& cb) { void airmap::services::Status::get_status_by_polygon(const GetStatus::Parameters& parameters, const GetStatus::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->status().get_status_by_polygon(parameters, [this, sp, cb](const auto& result) { sp->client_->status().get_status_by_polygon(parameters, [this, sp, cb](const auto& result) {
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); });

2
src/Airmap/services/status.h

@ -8,7 +8,7 @@
#include <memory> #include <memory>
namespace airmap { namespace airmap {
namespace qt { namespace services {
class Status : public airmap::Status, public std::enable_shared_from_this<Status> { class Status : public airmap::Status, public std::enable_shared_from_this<Status> {
public: public:

6
src/Airmap/services/telemetry.cpp

@ -2,17 +2,17 @@
#include <airmap/flight.h> #include <airmap/flight.h>
std::shared_ptr<airmap::qt::Telemetry> airmap::qt::Telemetry::create(const std::shared_ptr<Dispatcher>& dispatcher, std::shared_ptr<airmap::services::Telemetry> airmap::services::Telemetry::create(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) { const std::shared_ptr<airmap::Client>& client) {
return std::shared_ptr<Telemetry>{new Telemetry{dispatcher, client}}; return std::shared_ptr<Telemetry>{new Telemetry{dispatcher, client}};
} }
airmap::qt::Telemetry::Telemetry(const std::shared_ptr<Dispatcher>& dispatcher, airmap::services::Telemetry::Telemetry(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) const std::shared_ptr<airmap::Client>& client)
: dispatcher_{dispatcher}, client_{client} { : dispatcher_{dispatcher}, client_{client} {
} }
void airmap::qt::Telemetry::submit_updates(const Flight& flight, const std::string& key, void airmap::services::Telemetry::submit_updates(const Flight& flight, const std::string& key,
const std::initializer_list<Update>& updates) { const std::initializer_list<Update>& updates) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), flight, key, updates]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), flight, key, updates]() {
sp->client_->telemetry().submit_updates(flight, key, updates); sp->client_->telemetry().submit_updates(flight, key, updates);

2
src/Airmap/services/telemetry.h

@ -8,7 +8,7 @@
#include <memory> #include <memory>
namespace airmap { namespace airmap {
namespace qt { namespace services {
class Telemetry : public airmap::Telemetry, public std::enable_shared_from_this<Telemetry> { class Telemetry : public airmap::Telemetry, public std::enable_shared_from_this<Telemetry> {
public: public:

16
src/Airmap/services/traffic.cpp

@ -1,42 +1,42 @@
#include <Airmap/services/traffic.h> #include <Airmap/services/traffic.h>
std::shared_ptr<airmap::qt::Traffic::Monitor> airmap::qt::Traffic::Monitor::create( std::shared_ptr<airmap::services::Traffic::Monitor> airmap::services::Traffic::Monitor::create(
const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Traffic::Monitor>& native) { const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Traffic::Monitor>& native) {
return std::shared_ptr<Monitor>{new Monitor{dispatcher, native}}; return std::shared_ptr<Monitor>{new Monitor{dispatcher, native}};
} }
airmap::qt::Traffic::Monitor::Monitor(const std::shared_ptr<Dispatcher>& dispatcher, airmap::services::Traffic::Monitor::Monitor(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Traffic::Monitor>& native) const std::shared_ptr<airmap::Traffic::Monitor>& native)
: dispatcher_{dispatcher}, native_{native} { : dispatcher_{dispatcher}, native_{native} {
} }
void airmap::qt::Traffic::Monitor::subscribe(const std::shared_ptr<airmap::Traffic::Monitor::Subscriber>& subscriber) { void airmap::services::Traffic::Monitor::subscribe(const std::shared_ptr<airmap::Traffic::Monitor::Subscriber>& subscriber) {
dispatcher_->dispatch_to_qt([this, sp = shared_from_this(), subscriber] { sp->subscribers_.insert(subscriber); }); dispatcher_->dispatch_to_qt([this, sp = shared_from_this(), subscriber] { sp->subscribers_.insert(subscriber); });
} }
void airmap::qt::Traffic::Monitor::unsubscribe( void airmap::services::Traffic::Monitor::unsubscribe(
const std::shared_ptr<airmap::Traffic::Monitor::Subscriber>& subscriber) { const std::shared_ptr<airmap::Traffic::Monitor::Subscriber>& subscriber) {
dispatcher_->dispatch_to_qt([this, sp = shared_from_this(), subscriber] { sp->subscribers_.erase(subscriber); }); dispatcher_->dispatch_to_qt([this, sp = shared_from_this(), subscriber] { sp->subscribers_.erase(subscriber); });
} }
void airmap::qt::Traffic::Monitor::handle_update(Update::Type type, const std::vector<Update>& update) { void airmap::services::Traffic::Monitor::handle_update(Update::Type type, const std::vector<Update>& update) {
dispatcher_->dispatch_to_qt([this, sp = shared_from_this(), type, update]() { dispatcher_->dispatch_to_qt([this, sp = shared_from_this(), type, update]() {
for (const auto& subscriber : sp->subscribers_) for (const auto& subscriber : sp->subscribers_)
subscriber->handle_update(type, update); subscriber->handle_update(type, update);
}); });
} }
std::shared_ptr<airmap::qt::Traffic> airmap::qt::Traffic::create(const std::shared_ptr<Dispatcher>& dispatcher, std::shared_ptr<airmap::services::Traffic> airmap::services::Traffic::create(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) { const std::shared_ptr<airmap::Client>& client) {
return std::shared_ptr<Traffic>{new Traffic{dispatcher, client}}; return std::shared_ptr<Traffic>{new Traffic{dispatcher, client}};
} }
airmap::qt::Traffic::Traffic(const std::shared_ptr<Dispatcher>& dispatcher, airmap::services::Traffic::Traffic(const std::shared_ptr<Dispatcher>& dispatcher,
const std::shared_ptr<airmap::Client>& client) const std::shared_ptr<airmap::Client>& client)
: dispatcher_{dispatcher}, client_{client} { : dispatcher_{dispatcher}, client_{client} {
} }
void airmap::qt::Traffic::monitor(const Monitor::Params& parameters, const Monitor::Callback& cb) { void airmap::services::Traffic::monitor(const Monitor::Params& parameters, const Monitor::Callback& cb) {
dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() { dispatcher_->dispatch_to_airmap([this, sp = shared_from_this(), parameters, cb]() {
sp->client_->traffic().monitor(parameters, [this, sp, parameters, cb](const auto& result) { sp->client_->traffic().monitor(parameters, [this, sp, parameters, cb](const auto& result) {
if (result) { if (result) {

2
src/Airmap/services/traffic.h

@ -9,7 +9,7 @@
#include <set> #include <set>
namespace airmap { namespace airmap {
namespace qt { namespace services {
class Traffic : public airmap::Traffic, public std::enable_shared_from_this<Traffic> { class Traffic : public airmap::Traffic, public std::enable_shared_from_this<Traffic> {
public: public:

2
src/Airmap/services/types.cpp

@ -16,7 +16,7 @@ inline void register_type_once() {
} // namespace } // namespace
void airmap::qt::register_types() { void airmap::services::register_types() {
register_type_once<Aircraft>("Aircraft"); register_type_once<Aircraft>("Aircraft");
register_type_once<Airspace>("Airspace"); register_type_once<Airspace>("Airspace");
register_type_once<Credentials>("Credentials"); register_type_once<Credentials>("Credentials");

2
src/Airmap/services/types.h

@ -53,7 +53,7 @@ Q_DECLARE_METATYPE(airmap::Traffic::Update)
Q_DECLARE_METATYPE(airmap::Version) Q_DECLARE_METATYPE(airmap::Version)
namespace airmap { namespace airmap {
namespace qt { namespace services {
/// register_types makes airmap::* types known to the Qt type system. /// register_types makes airmap::* types known to the Qt type system.
/// ///

Loading…
Cancel
Save