34 changed files with 1971 additions and 7 deletions
@ -0,0 +1,48 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/advisory.h> |
||||||
|
|
||||||
|
std::shared_ptr<airmap::qt::Advisory> airmap::qt::Advisory::create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) { |
||||||
|
return std::shared_ptr<Advisory>{new Advisory{dispatcher, client}}; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::Advisory::Advisory(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) |
||||||
|
: dispatcher_{dispatcher}, client_{client} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Advisory::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->advisory().for_id(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Advisory::search(const Search::Parameters& parameters, const Search::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->advisory().search(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Advisory::report_weather(const ReportWeather::Parameters& parameters, |
||||||
|
const ReportWeather::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->advisory().report_weather(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
@ -0,0 +1,41 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_ADVISORY_H_ |
||||||
|
#define AIRMAP_QT_ADVISORY_H_ |
||||||
|
|
||||||
|
#include <airmap/advisory.h> |
||||||
|
#include <airmap/client.h> |
||||||
|
#include "dispatcher.h" |
||||||
|
|
||||||
|
namespace airmap { |
||||||
|
namespace qt { |
||||||
|
|
||||||
|
class Advisory : public airmap::Advisory, public std::enable_shared_from_this<Advisory> { |
||||||
|
public: |
||||||
|
static std::shared_ptr<Advisory> create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
void for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) override; |
||||||
|
void search(const Search::Parameters& parameters, const Search::Callback& cb) override; |
||||||
|
void report_weather(const ReportWeather::Parameters& parameters, const ReportWeather::Callback& cb) override; |
||||||
|
|
||||||
|
private: |
||||||
|
explicit Advisory(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client); |
||||||
|
std::shared_ptr<Dispatcher> dispatcher_; |
||||||
|
std::shared_ptr<airmap::Client> client_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_ADVISORY_H_
|
@ -0,0 +1,48 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/aircrafts.h> |
||||||
|
|
||||||
|
std::shared_ptr<airmap::qt::Aircrafts> airmap::qt::Aircrafts::create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) { |
||||||
|
return std::shared_ptr<Aircrafts>{new Aircrafts{dispatcher, client}}; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::Aircrafts::Aircrafts(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) |
||||||
|
: dispatcher_{dispatcher}, client_{client} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Aircrafts::manufacturers(const Manufacturers::Parameters& parameters, |
||||||
|
const Manufacturers::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->aircrafts().manufacturers(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Aircrafts::models(const Models::Parameters& parameters, const Models::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->aircrafts().models(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Aircrafts::model_for_id(const ModelForId::Parameters& parameters, const ModelForId::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->aircrafts().model_for_id(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
@ -0,0 +1,44 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_AIRCRAFTS_H_ |
||||||
|
#define AIRMAP_QT_AIRCRAFTS_H_ |
||||||
|
|
||||||
|
#include <airmap/aircrafts.h> |
||||||
|
#include <airmap/client.h> |
||||||
|
#include <Airmap/qt/dispatcher.h> |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
#include <string> |
||||||
|
|
||||||
|
namespace airmap { |
||||||
|
namespace qt { |
||||||
|
|
||||||
|
class Aircrafts : public airmap::Aircrafts, public std::enable_shared_from_this<Aircrafts> { |
||||||
|
public: |
||||||
|
static std::shared_ptr<Aircrafts> create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
void manufacturers(const Manufacturers::Parameters& parameters, const Manufacturers::Callback& cb) override; |
||||||
|
void models(const Models::Parameters& parameters, const Models::Callback& cb) override; |
||||||
|
void model_for_id(const ModelForId::Parameters& parameters, const ModelForId::Callback& cb) override; |
||||||
|
|
||||||
|
private: |
||||||
|
explicit Aircrafts(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client); |
||||||
|
std::shared_ptr<Dispatcher> dispatcher_; |
||||||
|
std::shared_ptr<airmap::Client> client_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_AIRCRAFTS_H_
|
@ -0,0 +1,39 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/airspaces.h> |
||||||
|
|
||||||
|
std::shared_ptr<airmap::qt::Airspaces> airmap::qt::Airspaces::create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) { |
||||||
|
return std::shared_ptr<Airspaces>{new Airspaces{dispatcher, client}}; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::Airspaces::Airspaces(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) |
||||||
|
: dispatcher_{dispatcher}, client_{client} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Airspaces::search(const Search::Parameters& parameters, const Search::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->airspaces().search(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Airspaces::for_ids(const ForIds::Parameters& parameters, const ForIds::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->airspaces().for_ids(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_AIRSPACES_H_ |
||||||
|
#define AIRMAP_QT_AIRSPACES_H_ |
||||||
|
|
||||||
|
#include <airmap/airspaces.h> |
||||||
|
#include <airmap/client.h> |
||||||
|
#include <Airmap/qt/dispatcher.h> |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
|
||||||
|
namespace airmap { |
||||||
|
namespace qt { |
||||||
|
|
||||||
|
class Airspaces : public airmap::Airspaces, public std::enable_shared_from_this<Airspaces> { |
||||||
|
public: |
||||||
|
static std::shared_ptr<Airspaces> create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
void search(const Search::Parameters& parameters, const Search::Callback& cb) override; |
||||||
|
void for_ids(const ForIds::Parameters& parameters, const ForIds::Callback& cb) override; |
||||||
|
|
||||||
|
private: |
||||||
|
explicit Airspaces(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
std::shared_ptr<Dispatcher> dispatcher_; |
||||||
|
std::shared_ptr<airmap::Client> client_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_AIRSPACES_H_
|
@ -0,0 +1,50 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/authenticator.h> |
||||||
|
|
||||||
|
std::shared_ptr<airmap::qt::Authenticator> airmap::qt::Authenticator::create( |
||||||
|
const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client) { |
||||||
|
return std::shared_ptr<Authenticator>{new Authenticator{dispatcher, client}}; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::Authenticator::Authenticator(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) |
||||||
|
: dispatcher_{dispatcher}, client_{client} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Authenticator::authenticate_with_password(const AuthenticateWithPassword::Params& parameters, |
||||||
|
const AuthenticateWithPassword::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->authenticator().authenticate_with_password(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Authenticator::authenticate_anonymously(const AuthenticateAnonymously::Params& parameters, |
||||||
|
const AuthenticateAnonymously::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->authenticator().authenticate_anonymously(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Authenticator::renew_authentication(const RenewAuthentication::Params& parameters, |
||||||
|
const RenewAuthentication::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->authenticator().renew_authentication(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
@ -0,0 +1,49 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_AUTHENTICATOR_H_ |
||||||
|
#define AIRMAP_QT_AUTHENTICATOR_H_ |
||||||
|
|
||||||
|
#include <airmap/authenticator.h> |
||||||
|
#include <airmap/client.h> |
||||||
|
#include <Airmap/qt/dispatcher.h> |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
|
||||||
|
namespace airmap { |
||||||
|
namespace qt { |
||||||
|
|
||||||
|
class Authenticator : public airmap::Authenticator, public std::enable_shared_from_this<Authenticator> { |
||||||
|
public: |
||||||
|
static std::shared_ptr<Authenticator> create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
void authenticate_with_password(const AuthenticateWithPassword::Params& params, |
||||||
|
const AuthenticateWithPassword::Callback& cb) override; |
||||||
|
|
||||||
|
void authenticate_anonymously(const AuthenticateAnonymously::Params& params, |
||||||
|
const AuthenticateAnonymously::Callback& cb) override; |
||||||
|
|
||||||
|
void renew_authentication(const RenewAuthentication::Params& params, |
||||||
|
const RenewAuthentication::Callback& cb) override; |
||||||
|
|
||||||
|
private: |
||||||
|
explicit Authenticator(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
std::shared_ptr<Dispatcher> dispatcher_; |
||||||
|
std::shared_ptr<airmap::Client> client_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_AUTHENTICATOR_H_
|
@ -0,0 +1,178 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/client.h> |
||||||
|
|
||||||
|
#include <Airmap/qt/dispatcher.h> |
||||||
|
|
||||||
|
#include <Airmap/qt/advisory.h> |
||||||
|
#include <Airmap/qt/aircrafts.h> |
||||||
|
#include <Airmap/qt/airspaces.h> |
||||||
|
#include <Airmap/qt/authenticator.h> |
||||||
|
#include <Airmap/qt/flight_plans.h> |
||||||
|
#include <Airmap/qt/flights.h> |
||||||
|
#include <Airmap/qt/pilots.h> |
||||||
|
#include <Airmap/qt/rulesets.h> |
||||||
|
#include <Airmap/qt/status.h> |
||||||
|
#include <Airmap/qt/telemetry.h> |
||||||
|
#include <Airmap/qt/traffic.h> |
||||||
|
#include <Airmap/qt/types.h> |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
#include <thread> |
||||||
|
|
||||||
|
namespace { |
||||||
|
|
||||||
|
class ContextRunner { |
||||||
|
public: |
||||||
|
explicit ContextRunner(const std::shared_ptr<airmap::Context>& context) : context_{context} { |
||||||
|
} |
||||||
|
|
||||||
|
void start() { |
||||||
|
worker_ = std::thread{[this]() { context_->run(); }}; |
||||||
|
} |
||||||
|
|
||||||
|
void stop() { |
||||||
|
context_->stop(); |
||||||
|
if (worker_.joinable()) |
||||||
|
worker_.join(); |
||||||
|
} |
||||||
|
|
||||||
|
const std::shared_ptr<airmap::Context>& context() const { |
||||||
|
return context_; |
||||||
|
} |
||||||
|
|
||||||
|
private: |
||||||
|
std::shared_ptr<airmap::Context> context_; |
||||||
|
std::thread worker_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
struct airmap::qt::Client::Private { |
||||||
|
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) |
||||||
|
: configuration_{configuration}, |
||||||
|
context_runner_{context_runner}, |
||||||
|
dispatcher_{dispatcher}, |
||||||
|
client_{client}, |
||||||
|
advisory_{airmap::qt::Advisory::create(dispatcher_, client_)}, |
||||||
|
aircrafts_{airmap::qt::Aircrafts::create(dispatcher_, client_)}, |
||||||
|
airspaces_{airmap::qt::Airspaces::create(dispatcher_, client_)}, |
||||||
|
authenticator_{airmap::qt::Authenticator::create(dispatcher_, client_)}, |
||||||
|
flight_plans_{airmap::qt::FlightPlans::create(dispatcher_, client_)}, |
||||||
|
flights_{airmap::qt::Flights::create(dispatcher_, client_)}, |
||||||
|
pilots_{airmap::qt::Pilots::create(dispatcher_, client_)}, |
||||||
|
rulesets_{airmap::qt::RuleSets::create(dispatcher_, client_)}, |
||||||
|
status_{airmap::qt::Status::create(dispatcher_, client_)}, |
||||||
|
telemetry_{airmap::qt::Telemetry::create(dispatcher_, client_)}, |
||||||
|
traffic_{airmap::qt::Traffic::create(dispatcher_, client_)} { |
||||||
|
} |
||||||
|
|
||||||
|
~Private() { |
||||||
|
context_runner_->stop(); |
||||||
|
} |
||||||
|
|
||||||
|
Client::Configuration configuration_; |
||||||
|
std::shared_ptr<ContextRunner> context_runner_; |
||||||
|
std::shared_ptr<airmap::qt::Dispatcher> dispatcher_; |
||||||
|
std::shared_ptr<airmap::Client> client_; |
||||||
|
std::shared_ptr<airmap::qt::Advisory> advisory_; |
||||||
|
std::shared_ptr<airmap::qt::Aircrafts> aircrafts_; |
||||||
|
std::shared_ptr<airmap::qt::Airspaces> airspaces_; |
||||||
|
std::shared_ptr<airmap::qt::Authenticator> authenticator_; |
||||||
|
std::shared_ptr<airmap::qt::FlightPlans> flight_plans_; |
||||||
|
std::shared_ptr<airmap::qt::Flights> flights_; |
||||||
|
std::shared_ptr<airmap::qt::Pilots> pilots_; |
||||||
|
std::shared_ptr<airmap::qt::RuleSets> rulesets_; |
||||||
|
std::shared_ptr<airmap::qt::Status> status_; |
||||||
|
std::shared_ptr<airmap::qt::Telemetry> telemetry_; |
||||||
|
std::shared_ptr<airmap::qt::Traffic> traffic_; |
||||||
|
}; |
||||||
|
|
||||||
|
void airmap::qt::Client::create(const Client::Configuration& configuration, const std::shared_ptr<Logger>& logger, |
||||||
|
QObject* parent, const CreateCallback& cb) { |
||||||
|
register_types(); |
||||||
|
|
||||||
|
auto result = Context::create(logger); |
||||||
|
auto dispatcher = std::make_shared<Dispatcher>(result.value()); |
||||||
|
|
||||||
|
if (!result) { |
||||||
|
dispatcher->dispatch_to_qt([result, cb]() { cb(CreateResult{result.error()}); }); |
||||||
|
} else { |
||||||
|
auto cr = std::make_shared<ContextRunner>(result.value()); |
||||||
|
|
||||||
|
cr->context()->create_client_with_configuration( |
||||||
|
configuration, [dispatcher, configuration, parent, cr, cb](const auto& result) { |
||||||
|
dispatcher->dispatch_to_qt([dispatcher, configuration, parent, cr, result, cb]() { |
||||||
|
if (result) { |
||||||
|
cb(CreateResult{new Client{ |
||||||
|
std::unique_ptr<Private>{new Private{configuration, cr, dispatcher, result.value()}}, parent}}); |
||||||
|
} else { |
||||||
|
cb(CreateResult{result.error()}); |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
cr->start(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::Client::Client(std::unique_ptr<Private>&& d, QObject* parent) : QObject{parent}, d_{std::move(d)} { |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::Client::~Client() = default; |
||||||
|
|
||||||
|
// From airmap::Client
|
||||||
|
airmap::Authenticator& airmap::qt::Client::authenticator() { |
||||||
|
return *d_->authenticator_; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::Advisory& airmap::qt::Client::advisory() { |
||||||
|
return *d_->advisory_; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::Aircrafts& airmap::qt::Client::aircrafts() { |
||||||
|
return *d_->aircrafts_; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::Airspaces& airmap::qt::Client::airspaces() { |
||||||
|
return *d_->airspaces_; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::FlightPlans& airmap::qt::Client::flight_plans() { |
||||||
|
return *d_->flight_plans_; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::Flights& airmap::qt::Client::flights() { |
||||||
|
return *d_->flights_; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::Pilots& airmap::qt::Client::pilots() { |
||||||
|
return *d_->pilots_; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::RuleSets& airmap::qt::Client::rulesets() { |
||||||
|
return *d_->rulesets_; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::Status& airmap::qt::Client::status() { |
||||||
|
return *d_->status_; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::Telemetry& airmap::qt::Client::telemetry() { |
||||||
|
return *d_->telemetry_; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::Traffic& airmap::qt::Client::traffic() { |
||||||
|
return *d_->traffic_; |
||||||
|
} |
@ -0,0 +1,77 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_CLIENT_H_ |
||||||
|
#define AIRMAP_QT_CLIENT_H_ |
||||||
|
|
||||||
|
#include <airmap/client.h> |
||||||
|
#include <airmap/context.h> |
||||||
|
#include <airmap/error.h> |
||||||
|
#include <airmap/logger.h> |
||||||
|
#include <airmap/outcome.h> |
||||||
|
#include <airmap/visibility.h> |
||||||
|
|
||||||
|
#include <QObject> |
||||||
|
|
||||||
|
namespace airmap { |
||||||
|
/// @namespace namespace qt bundles up types and functions that help with integrating AirMap functionality
|
||||||
|
/// into Qt-based applications and libraries.
|
||||||
|
namespace qt { |
||||||
|
|
||||||
|
/// Client implements the airmap::Client interface, bridging over between
|
||||||
|
/// the Qt event loop and the native event loop of the native airmap::Client.
|
||||||
|
///
|
||||||
|
/// All callback invocations that might happen in the context of a Client instance
|
||||||
|
/// are dispatched to the Qt applications' main thread.
|
||||||
|
class AIRMAP_EXPORT Client : public QObject, public airmap::Client { |
||||||
|
public: |
||||||
|
using CreateResult = Outcome<Client*, Error>; |
||||||
|
using CreateCallback = std::function<void(const CreateResult&)>; |
||||||
|
|
||||||
|
/// create creates a new Client instance with parent 'parent', logging to 'logger', using the config
|
||||||
|
/// 'configuration'. The result of the request is reported to 'cb', on the thread that issued the create request.
|
||||||
|
///
|
||||||
|
/// Please note that this function must be called on Qt's main thread as event dispatching between different
|
||||||
|
/// event loops to the Qt world is set up here.
|
||||||
|
static void create(const Client::Configuration& configuration, const std::shared_ptr<Logger>& logger, QObject* parent, |
||||||
|
const CreateCallback& cb); |
||||||
|
|
||||||
|
~Client(); |
||||||
|
|
||||||
|
// From airmap::Client
|
||||||
|
Authenticator& authenticator() override; |
||||||
|
Advisory& advisory() override; |
||||||
|
Aircrafts& aircrafts() override; |
||||||
|
Airspaces& airspaces() override; |
||||||
|
FlightPlans& flight_plans() override; |
||||||
|
Flights& flights() override; |
||||||
|
Pilots& pilots() override; |
||||||
|
RuleSets& rulesets() override; |
||||||
|
Status& status() override; |
||||||
|
Telemetry& telemetry() override; |
||||||
|
Traffic& traffic() override; |
||||||
|
|
||||||
|
private: |
||||||
|
/// @cond
|
||||||
|
struct Private; |
||||||
|
Client(std::unique_ptr<Private>&& d, QObject* parent); |
||||||
|
std::unique_ptr<Private> d_; |
||||||
|
/// @endcond
|
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
/// @example qt/client.cpp
|
||||||
|
/// Illustrates how to use airmap::qt::Client, airmap::qt::DispatchingLogger and airmap::qt::Logger.
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_CLIENT_H_
|
@ -0,0 +1,86 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/dispatcher.h> |
||||||
|
|
||||||
|
#include <QCoreApplication> |
||||||
|
#include <QThread> |
||||||
|
|
||||||
|
#include <cassert> |
||||||
|
|
||||||
|
QEvent::Type airmap::qt::Dispatcher::Event::registered_type() { |
||||||
|
static const Type rt = static_cast<Type>(registerEventType()); |
||||||
|
return rt; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::Dispatcher::Event::Event(const std::function<void()>& task) : QEvent{registered_type()}, task_{task} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Dispatcher::Event::dispatch() { |
||||||
|
task_(); |
||||||
|
} |
||||||
|
|
||||||
|
std::shared_ptr<airmap::qt::Dispatcher::ToQt> airmap::qt::Dispatcher::ToQt::create() { |
||||||
|
return std::shared_ptr<ToQt>{new ToQt{}}; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::Dispatcher::ToQt::ToQt() { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Dispatcher::ToQt::dispatch(const Task& task) { |
||||||
|
auto sp = shared_from_this(); |
||||||
|
|
||||||
|
QCoreApplication::postEvent(this, new Event{[sp, task]() { task(); }}); |
||||||
|
} |
||||||
|
|
||||||
|
bool airmap::qt::Dispatcher::ToQt::event(QEvent* event) { |
||||||
|
assert(QCoreApplication::instance()); |
||||||
|
assert(QThread::currentThread() == QCoreApplication::instance()->thread()); |
||||||
|
|
||||||
|
if (event->type() == Event::registered_type()) { |
||||||
|
event->accept(); |
||||||
|
|
||||||
|
if (auto e = dynamic_cast<Event*>(event)) { |
||||||
|
e->dispatch(); |
||||||
|
} |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
std::shared_ptr<airmap::qt::Dispatcher::ToNative> airmap::qt::Dispatcher::ToNative::create( |
||||||
|
const std::shared_ptr<Context>& context) { |
||||||
|
return std::shared_ptr<ToNative>{new ToNative{context}}; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::Dispatcher::ToNative::ToNative(const std::shared_ptr<Context>& context) : context_{context} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Dispatcher::ToNative::dispatch(const Task& task) { |
||||||
|
context_->dispatch(task); |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::Dispatcher::Dispatcher(const std::shared_ptr<Context>& context) |
||||||
|
: to_qt_{ToQt::create()}, to_native_{ToNative::create(context)} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Dispatcher::dispatch_to_qt(const std::function<void()>& task) { |
||||||
|
to_qt_->dispatch(task); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Dispatcher::dispatch_to_native(const std::function<void()>& task) { |
||||||
|
to_native_->dispatch(task); |
||||||
|
} |
||||||
|
|
||||||
|
// From QObject
|
@ -0,0 +1,75 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_DISPATCHER_H_ |
||||||
|
#define AIRMAP_QT_DISPATCHER_H_ |
||||||
|
|
||||||
|
#include <airmap/context.h> |
||||||
|
|
||||||
|
#include <QEvent> |
||||||
|
#include <QObject> |
||||||
|
|
||||||
|
#include <functional> |
||||||
|
#include <memory> |
||||||
|
namespace airmap { |
||||||
|
namespace qt { |
||||||
|
|
||||||
|
class Dispatcher : public QObject { |
||||||
|
public: |
||||||
|
class Event : public QEvent { |
||||||
|
public: |
||||||
|
static Type registered_type(); |
||||||
|
|
||||||
|
explicit Event(const std::function<void()>& task); |
||||||
|
void dispatch(); |
||||||
|
|
||||||
|
private: |
||||||
|
std::function<void()> task_; |
||||||
|
}; |
||||||
|
|
||||||
|
using Task = std::function<void()>; |
||||||
|
|
||||||
|
class ToQt : public QObject, public std::enable_shared_from_this<ToQt> { |
||||||
|
public: |
||||||
|
static std::shared_ptr<ToQt> create(); |
||||||
|
void dispatch(const Task& task); |
||||||
|
|
||||||
|
private: |
||||||
|
ToQt(); |
||||||
|
// From QObject
|
||||||
|
bool event(QEvent* event) override; |
||||||
|
}; |
||||||
|
|
||||||
|
class ToNative : public std::enable_shared_from_this<ToNative> { |
||||||
|
public: |
||||||
|
static std::shared_ptr<ToNative> create(const std::shared_ptr<Context>& context); |
||||||
|
void dispatch(const Task& task); |
||||||
|
|
||||||
|
private: |
||||||
|
explicit ToNative(const std::shared_ptr<Context>& context); |
||||||
|
std::shared_ptr<Context> context_; |
||||||
|
}; |
||||||
|
|
||||||
|
explicit Dispatcher(const std::shared_ptr<Context>& context); |
||||||
|
|
||||||
|
void dispatch_to_qt(const Task& task); |
||||||
|
void dispatch_to_native(const Task& task); |
||||||
|
|
||||||
|
private: |
||||||
|
std::shared_ptr<ToQt> to_qt_; |
||||||
|
std::shared_ptr<ToNative> to_native_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_DISPATCHER_H_
|
@ -0,0 +1,72 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/flight_plans.h> |
||||||
|
|
||||||
|
std::shared_ptr<airmap::qt::FlightPlans> airmap::qt::FlightPlans::create( |
||||||
|
const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client) { |
||||||
|
return std::shared_ptr<FlightPlans>{new FlightPlans{dispatcher, client}}; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::FlightPlans::FlightPlans(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) |
||||||
|
: dispatcher_{dispatcher}, client_{client} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::FlightPlans::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flight_plans().for_id(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::FlightPlans::create_by_polygon(const Create::Parameters& parameters, const Create::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flight_plans().create_by_polygon(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::FlightPlans::update(const Update::Parameters& parameters, const Update::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flight_plans().update(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::FlightPlans::delete_(const Delete::Parameters& parameters, const Delete::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flight_plans().delete_(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::FlightPlans::render_briefing(const RenderBriefing::Parameters& parameters, |
||||||
|
const RenderBriefing::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flight_plans().render_briefing(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::FlightPlans::submit(const Submit::Parameters& parameters, const Submit::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flight_plans().submit(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_FLIGHT_PLANS_H_ |
||||||
|
#define AIRMAP_QT_FLIGHT_PLANS_H_ |
||||||
|
|
||||||
|
#include <airmap/client.h> |
||||||
|
#include <airmap/flight_plans.h> |
||||||
|
#include <Airmap/qt/dispatcher.h> |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
|
||||||
|
namespace airmap { |
||||||
|
namespace qt { |
||||||
|
|
||||||
|
/// FlightPlans provides functionality for managing flight plans.
|
||||||
|
class FlightPlans : public airmap::FlightPlans, public std::enable_shared_from_this<FlightPlans> { |
||||||
|
public: |
||||||
|
static std::shared_ptr<FlightPlans> create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
void for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) override; |
||||||
|
void create_by_polygon(const Create::Parameters& parameters, const Create::Callback& cb) override; |
||||||
|
void update(const Update::Parameters& parameters, const Update::Callback& cb) override; |
||||||
|
void delete_(const Delete::Parameters& parameters, const Delete::Callback& cb) override; |
||||||
|
void render_briefing(const RenderBriefing::Parameters& parameters, const RenderBriefing::Callback& cb) override; |
||||||
|
void submit(const Submit::Parameters& parameters, const Submit::Callback& cb) override; |
||||||
|
|
||||||
|
private: |
||||||
|
explicit FlightPlans(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
std::shared_ptr<Dispatcher> dispatcher_; |
||||||
|
std::shared_ptr<airmap::Client> client_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_FLIGHT_PLANS_H_
|
@ -0,0 +1,100 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/flights.h> |
||||||
|
|
||||||
|
std::shared_ptr<airmap::qt::Flights> airmap::qt::Flights::create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) { |
||||||
|
return std::shared_ptr<Flights>{new Flights{dispatcher, client}}; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::Flights::Flights(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) |
||||||
|
: dispatcher_{dispatcher}, client_{client} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Flights::search(const Search::Parameters& parameters, const Search::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flights().search(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Flights::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flights().for_id(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Flights::create_flight_by_point(const CreateFlight::Parameters& parameters, |
||||||
|
const CreateFlight::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flights().create_flight_by_point(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Flights::create_flight_by_path(const CreateFlight::Parameters& parameters, |
||||||
|
const CreateFlight::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flights().create_flight_by_path(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Flights::create_flight_by_polygon(const CreateFlight::Parameters& parameters, |
||||||
|
const CreateFlight::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flights().create_flight_by_polygon(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Flights::end_flight(const EndFlight::Parameters& parameters, const EndFlight::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flights().end_flight(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Flights::delete_flight(const DeleteFlight::Parameters& parameters, const DeleteFlight::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flights().delete_flight(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Flights::start_flight_communications(const StartFlightCommunications::Parameters& parameters, |
||||||
|
const StartFlightCommunications::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flights().start_flight_communications(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Flights::end_flight_communications(const EndFlightCommunications::Parameters& parameters, |
||||||
|
const EndFlightCommunications::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->flights().end_flight_communications(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
@ -0,0 +1,52 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_FLIGHTS_H_ |
||||||
|
#define AIRMAP_QT_FLIGHTS_H_ |
||||||
|
|
||||||
|
#include <airmap/client.h> |
||||||
|
#include <airmap/flights.h> |
||||||
|
#include <Airmap/qt/dispatcher.h> |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
|
||||||
|
namespace airmap { |
||||||
|
namespace qt { |
||||||
|
|
||||||
|
class Flights : public airmap::Flights, public std::enable_shared_from_this<Flights> { |
||||||
|
public: |
||||||
|
static std::shared_ptr<Flights> create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
void search(const Search::Parameters& parameters, const Search::Callback& cb) override; |
||||||
|
void for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) override; |
||||||
|
void create_flight_by_point(const CreateFlight::Parameters& parameters, const CreateFlight::Callback& cb) override; |
||||||
|
void create_flight_by_path(const CreateFlight::Parameters& parameters, const CreateFlight::Callback& cb) override; |
||||||
|
void create_flight_by_polygon(const CreateFlight::Parameters& parameters, const CreateFlight::Callback& cb) override; |
||||||
|
void end_flight(const EndFlight::Parameters& parameters, const EndFlight::Callback& cb) override; |
||||||
|
void delete_flight(const DeleteFlight::Parameters& parameters, const DeleteFlight::Callback& cb) override; |
||||||
|
void start_flight_communications(const StartFlightCommunications::Parameters& parameters, |
||||||
|
const StartFlightCommunications::Callback& cb) override; |
||||||
|
void end_flight_communications(const EndFlightCommunications::Parameters& parameters, |
||||||
|
const EndFlightCommunications::Callback& cb) override; |
||||||
|
|
||||||
|
private: |
||||||
|
explicit Flights(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
std::shared_ptr<Dispatcher> dispatcher_; |
||||||
|
std::shared_ptr<airmap::Client> client_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_FLIGHTS_H_
|
@ -0,0 +1,90 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/logger.h> |
||||||
|
|
||||||
|
#include <Airmap/qt/dispatcher.h> |
||||||
|
|
||||||
|
struct airmap::qt::Logger::Private { |
||||||
|
QLoggingCategory logging_category{"airmap"}; |
||||||
|
}; |
||||||
|
|
||||||
|
struct airmap::qt::DispatchingLogger::Private { |
||||||
|
std::shared_ptr<airmap::Logger> next; |
||||||
|
std::shared_ptr<Dispatcher::ToQt> dispatcher; |
||||||
|
}; |
||||||
|
|
||||||
|
airmap::qt::Logger::Logger() : d_{new Private{}} { |
||||||
|
} |
||||||
|
airmap::qt::Logger::~Logger() { |
||||||
|
} |
||||||
|
|
||||||
|
QLoggingCategory& airmap::qt::Logger::logging_category() { |
||||||
|
static QLoggingCategory lc{"airmap"}; |
||||||
|
return lc; |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Logger::log(Severity severity, const char* message, const char*) { |
||||||
|
switch (severity) { |
||||||
|
case Severity::debug: |
||||||
|
qCDebug(logging_category(), "%s", message); |
||||||
|
break; |
||||||
|
case Severity::info: |
||||||
|
qCInfo(logging_category(), "%s", message); |
||||||
|
break; |
||||||
|
case Severity::error: |
||||||
|
qCWarning(logging_category(), "%s", message); |
||||||
|
break; |
||||||
|
default: |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
bool airmap::qt::Logger::should_log(Severity severity, const char*, const char*) { |
||||||
|
switch (severity) { |
||||||
|
case Severity::debug: |
||||||
|
return logging_category().isDebugEnabled(); |
||||||
|
case Severity::info: |
||||||
|
return logging_category().isInfoEnabled(); |
||||||
|
case Severity::error: |
||||||
|
return logging_category().isWarningEnabled(); |
||||||
|
default: |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::DispatchingLogger::DispatchingLogger(const std::shared_ptr<airmap::Logger>& next) |
||||||
|
: d_{new Private{next, Dispatcher::ToQt::create()}} { |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::DispatchingLogger::~DispatchingLogger() { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::DispatchingLogger::log(Severity severity, const char* message, const char* component) { |
||||||
|
std::string cmessage{message}; |
||||||
|
std::string ccomponent{component}; |
||||||
|
auto cnext{d_->next}; |
||||||
|
|
||||||
|
d_->dispatcher->dispatch([severity, cmessage, ccomponent, cnext] { |
||||||
|
if (cnext->should_log(severity, cmessage.c_str(), ccomponent.c_str())) |
||||||
|
cnext->log(severity, cmessage.c_str(), ccomponent.c_str()); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
bool airmap::qt::DispatchingLogger::should_log(Severity, const char*, const char*) { |
||||||
|
// We have to accept all incoming log messages and postpone
|
||||||
|
// the actual evaluation of should_log in the context of next until we
|
||||||
|
// run on the correct thread.
|
||||||
|
return true; |
||||||
|
} |
@ -0,0 +1,69 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_LOGGER_H_ |
||||||
|
#define AIRMAP_QT_LOGGER_H_ |
||||||
|
|
||||||
|
#include <airmap/logger.h> |
||||||
|
#include <airmap/visibility.h> |
||||||
|
|
||||||
|
#include <QLoggingCategory> |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
|
||||||
|
namespace airmap { |
||||||
|
namespace qt { |
||||||
|
|
||||||
|
/// Logger is an airmap::Logger implementation that uses to
|
||||||
|
/// Qt's logging facilities.
|
||||||
|
class AIRMAP_EXPORT Logger : public airmap::Logger { |
||||||
|
public: |
||||||
|
/// logging_category returns a QLoggingCategory instance
|
||||||
|
/// that enables calling code to fine-tune logging behavior of a Logger instance.
|
||||||
|
QLoggingCategory& logging_category(); |
||||||
|
|
||||||
|
/// Logger initializes a new instance.
|
||||||
|
Logger(); |
||||||
|
/// ~Logger cleans up all resources held by a Logger instance.
|
||||||
|
~Logger(); |
||||||
|
|
||||||
|
// From airmap::Logger
|
||||||
|
void log(Severity severity, const char* message, const char* component) override; |
||||||
|
bool should_log(Severity severity, const char* message, const char* component) override; |
||||||
|
|
||||||
|
private: |
||||||
|
struct Private; |
||||||
|
std::unique_ptr<Private> d_; |
||||||
|
}; |
||||||
|
|
||||||
|
/// DispatchingLogger is an airmap::Logger implementation that dispatches to Qt's main
|
||||||
|
/// event loop for logger invocation
|
||||||
|
class AIRMAP_EXPORT DispatchingLogger : public airmap::Logger { |
||||||
|
public: |
||||||
|
/// DispatchingLogger initializes a new instance with 'next'.
|
||||||
|
DispatchingLogger(const std::shared_ptr<airmap::Logger>& next); |
||||||
|
/// ~DispatchingLogging cleans up all resources held a DispatchingLogger instance.
|
||||||
|
~DispatchingLogger(); |
||||||
|
|
||||||
|
// From airmap::Logger
|
||||||
|
void log(Severity severity, const char* message, const char* component) override; |
||||||
|
bool should_log(Severity severity, const char* message, const char* component) override; |
||||||
|
|
||||||
|
private: |
||||||
|
struct Private; |
||||||
|
std::unique_ptr<Private> d_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_LOGGER_H_
|
@ -0,0 +1,98 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/pilots.h> |
||||||
|
|
||||||
|
std::shared_ptr<airmap::qt::Pilots> airmap::qt::Pilots::create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& 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) |
||||||
|
: dispatcher_{dispatcher}, client_{client} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Pilots::authenticated(const Authenticated::Parameters& parameters, const Authenticated::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->pilots().authenticated(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Pilots::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->pilots().for_id(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Pilots::update_for_id(const UpdateForId::Parameters& parameters, const UpdateForId::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->pilots().update_for_id(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Pilots::start_verify_pilot_phone_for_id(const StartVerifyPilotPhoneForId::Parameters& parameters, |
||||||
|
const StartVerifyPilotPhoneForId::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->pilots().start_verify_pilot_phone_for_id(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Pilots::finish_verify_pilot_phone_for_id(const FinishVerifyPilotPhoneForId::Parameters& parameters, |
||||||
|
const FinishVerifyPilotPhoneForId::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->pilots().finish_verify_pilot_phone_for_id(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Pilots::aircrafts(const Aircrafts::Parameters& parameters, const Aircrafts::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->pilots().aircrafts(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Pilots::add_aircraft(const AddAircraft::Parameters& parameters, const AddAircraft::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->pilots().add_aircraft(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Pilots::delete_aircraft(const DeleteAircraft::Parameters& parameters, |
||||||
|
const DeleteAircraft::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->pilots().delete_aircraft(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Pilots::update_aircraft(const UpdateAircraft::Parameters& parameters, |
||||||
|
const UpdateAircraft::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->pilots().update_aircraft(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
@ -0,0 +1,53 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_PILOTS_H_ |
||||||
|
#define AIRMAP_QT_PILOTS_H_ |
||||||
|
|
||||||
|
#include <airmap/pilots.h> |
||||||
|
|
||||||
|
#include <airmap/pilots.h> |
||||||
|
#include <Airmap/qt/dispatcher.h> |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
|
||||||
|
namespace airmap { |
||||||
|
namespace qt { |
||||||
|
|
||||||
|
class Pilots : public airmap::Pilots, public std::enable_shared_from_this<Pilots> { |
||||||
|
public: |
||||||
|
static std::shared_ptr<Pilots> create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
void authenticated(const Authenticated::Parameters& parameters, const Authenticated::Callback& cb) override; |
||||||
|
void for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) override; |
||||||
|
void update_for_id(const UpdateForId::Parameters& parameters, const UpdateForId::Callback& cb) override; |
||||||
|
void start_verify_pilot_phone_for_id(const StartVerifyPilotPhoneForId::Parameters& parameters, |
||||||
|
const StartVerifyPilotPhoneForId::Callback& cb) override; |
||||||
|
void finish_verify_pilot_phone_for_id(const FinishVerifyPilotPhoneForId::Parameters& parameters, |
||||||
|
const FinishVerifyPilotPhoneForId::Callback& cb) override; |
||||||
|
void aircrafts(const Aircrafts::Parameters& parameters, const Aircrafts::Callback& cb) override; |
||||||
|
void add_aircraft(const AddAircraft::Parameters& parameters, const AddAircraft::Callback& cb) override; |
||||||
|
void delete_aircraft(const DeleteAircraft::Parameters& parameters, const DeleteAircraft::Callback& cb) override; |
||||||
|
void update_aircraft(const UpdateAircraft::Parameters& parameters, const UpdateAircraft::Callback& cb) override; |
||||||
|
|
||||||
|
private: |
||||||
|
explicit Pilots(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
std::shared_ptr<Dispatcher> dispatcher_; |
||||||
|
std::shared_ptr<airmap::Client> client_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_PILOTS_H_
|
@ -0,0 +1,65 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/rulesets.h> |
||||||
|
|
||||||
|
std::shared_ptr<airmap::qt::RuleSets> airmap::qt::RuleSets::create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) { |
||||||
|
return std::shared_ptr<RuleSets>{new RuleSets{dispatcher, client}}; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::RuleSets::RuleSets(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) |
||||||
|
: dispatcher_{dispatcher}, client_{client} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::RuleSets::search(const Search::Parameters& parameters, const Search::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->rulesets().search(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::RuleSets::for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->rulesets().for_id(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::RuleSets::fetch_rules(const FetchRules::Parameters& parameters, const FetchRules::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->rulesets().fetch_rules(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::RuleSets::evaluate_rulesets(const EvaluateRules::Parameters& parameters, |
||||||
|
const EvaluateRules::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->rulesets().evaluate_rulesets(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::RuleSets::evaluate_flight_plan(const EvaluateFlightPlan::Parameters& parameters, |
||||||
|
const EvaluateFlightPlan::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->rulesets().evaluate_flight_plan(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_RULESETS_H_ |
||||||
|
#define AIRMAP_QT_RULESETS_H_ |
||||||
|
|
||||||
|
#include <airmap/client.h> |
||||||
|
#include <Airmap/qt/dispatcher.h> |
||||||
|
#include <airmap/rulesets.h> |
||||||
|
|
||||||
|
namespace airmap { |
||||||
|
namespace qt { |
||||||
|
|
||||||
|
class RuleSets : public airmap::RuleSets, public std::enable_shared_from_this<RuleSets> { |
||||||
|
public: |
||||||
|
static std::shared_ptr<RuleSets> create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
void search(const Search::Parameters& parameters, const Search::Callback& cb) override; |
||||||
|
void for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) override; |
||||||
|
void fetch_rules(const FetchRules::Parameters& parameters, const FetchRules::Callback& cb) override; |
||||||
|
void evaluate_rulesets(const EvaluateRules::Parameters& parameters, const EvaluateRules::Callback& cb) override; |
||||||
|
void evaluate_flight_plan(const EvaluateFlightPlan::Parameters& parameters, const EvaluateFlightPlan::Callback& cb) override; |
||||||
|
|
||||||
|
private: |
||||||
|
explicit RuleSets(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client); |
||||||
|
std::shared_ptr<Dispatcher> dispatcher_; |
||||||
|
std::shared_ptr<airmap::Client> client_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_RULESETS_H_
|
@ -0,0 +1,46 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/status.h> |
||||||
|
|
||||||
|
std::shared_ptr<airmap::qt::Status> airmap::qt::Status::create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& 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) |
||||||
|
: dispatcher_{dispatcher}, client_{client} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Status::get_status_by_point(const GetStatus::Parameters& parameters, const GetStatus::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->status().get_status_by_point(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Status::get_status_by_path(const GetStatus::Parameters& parameters, const GetStatus::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->status().get_status_by_path(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Status::get_status_by_polygon(const GetStatus::Parameters& parameters, const GetStatus::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->status().get_status_by_polygon(parameters, [this, sp, cb](const auto& result) { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
@ -0,0 +1,44 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_STATUS_H_ |
||||||
|
#define AIRMAP_QT_STATUS_H_ |
||||||
|
|
||||||
|
#include <airmap/client.h> |
||||||
|
#include <Airmap/qt/dispatcher.h> |
||||||
|
#include <airmap/status.h> |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
|
||||||
|
namespace airmap { |
||||||
|
namespace qt { |
||||||
|
|
||||||
|
class Status : public airmap::Status, public std::enable_shared_from_this<Status> { |
||||||
|
public: |
||||||
|
static std::shared_ptr<Status> create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
void get_status_by_point(const GetStatus::Parameters& parameters, const GetStatus::Callback& cb) override; |
||||||
|
void get_status_by_path(const GetStatus::Parameters& parameters, const GetStatus::Callback& cb) override; |
||||||
|
void get_status_by_polygon(const GetStatus::Parameters& parameters, const GetStatus::Callback& cb) override; |
||||||
|
|
||||||
|
private: |
||||||
|
explicit Status(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
std::shared_ptr<Dispatcher> dispatcher_; |
||||||
|
std::shared_ptr<airmap::Client> client_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_STATUS_H_
|
@ -0,0 +1,32 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/telemetry.h> |
||||||
|
|
||||||
|
#include <airmap/flight.h> |
||||||
|
|
||||||
|
std::shared_ptr<airmap::qt::Telemetry> airmap::qt::Telemetry::create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) { |
||||||
|
return std::shared_ptr<Telemetry>{new Telemetry{dispatcher, client}}; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::Telemetry::Telemetry(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) |
||||||
|
: dispatcher_{dispatcher}, client_{client} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Telemetry::submit_updates(const Flight& flight, const std::string& key, |
||||||
|
const std::initializer_list<Update>& updates) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), flight, key, updates]() { |
||||||
|
sp->client_->telemetry().submit_updates(flight, key, updates); |
||||||
|
}); |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_TELEMETRY_H_ |
||||||
|
#define AIRMAP_QT_TELEMETRY_H_ |
||||||
|
|
||||||
|
#include <airmap/client.h> |
||||||
|
#include <Airmap/qt/dispatcher.h> |
||||||
|
#include <airmap/telemetry.h> |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
|
||||||
|
namespace airmap { |
||||||
|
namespace qt { |
||||||
|
|
||||||
|
class Telemetry : public airmap::Telemetry, public std::enable_shared_from_this<Telemetry> { |
||||||
|
public: |
||||||
|
static std::shared_ptr<Telemetry> create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
void submit_updates(const Flight& flight, const std::string& key, |
||||||
|
const std::initializer_list<Update>& updates) override; |
||||||
|
|
||||||
|
private: |
||||||
|
explicit Telemetry(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
std::shared_ptr<Dispatcher> dispatcher_; |
||||||
|
std::shared_ptr<airmap::Client> client_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_TELEMETRY_H_
|
@ -0,0 +1,64 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/traffic.h> |
||||||
|
|
||||||
|
std::shared_ptr<airmap::qt::Traffic::Monitor> airmap::qt::Traffic::Monitor::create( |
||||||
|
const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Traffic::Monitor>& native) { |
||||||
|
return std::shared_ptr<Monitor>{new Monitor{dispatcher, native}}; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::Traffic::Monitor::Monitor(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Traffic::Monitor>& native) |
||||||
|
: dispatcher_{dispatcher}, native_{native} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::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); }); |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Traffic::Monitor::unsubscribe( |
||||||
|
const std::shared_ptr<airmap::Traffic::Monitor::Subscriber>& 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) { |
||||||
|
dispatcher_->dispatch_to_qt([this, sp = shared_from_this(), type, update]() { |
||||||
|
for (const auto& subscriber : sp->subscribers_) |
||||||
|
subscriber->handle_update(type, update); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
std::shared_ptr<airmap::qt::Traffic> airmap::qt::Traffic::create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) { |
||||||
|
return std::shared_ptr<Traffic>{new Traffic{dispatcher, client}}; |
||||||
|
} |
||||||
|
|
||||||
|
airmap::qt::Traffic::Traffic(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client) |
||||||
|
: dispatcher_{dispatcher}, client_{client} { |
||||||
|
} |
||||||
|
|
||||||
|
void airmap::qt::Traffic::monitor(const Monitor::Params& parameters, const Monitor::Callback& cb) { |
||||||
|
dispatcher_->dispatch_to_native([this, sp = shared_from_this(), parameters, cb]() { |
||||||
|
sp->client_->traffic().monitor(parameters, [this, sp, parameters, cb](const auto& result) { |
||||||
|
if (result) { |
||||||
|
auto m = result.value(); |
||||||
|
auto mm = Monitor::create(sp->dispatcher_, m); |
||||||
|
m->subscribe(mm); |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, mm, cb]() { cb(Monitor::Result{mm}); }); |
||||||
|
} else { |
||||||
|
sp->dispatcher_->dispatch_to_qt([sp, result, cb]() { cb(result); }); |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
@ -0,0 +1,66 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_TRAFFIC_H_ |
||||||
|
#define AIRMAP_QT_TRAFFIC_H_ |
||||||
|
|
||||||
|
#include <airmap/traffic.h> |
||||||
|
|
||||||
|
#include <Airmap/qt/dispatcher.h> |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
#include <set> |
||||||
|
|
||||||
|
namespace airmap { |
||||||
|
namespace qt { |
||||||
|
|
||||||
|
class Traffic : public airmap::Traffic, public std::enable_shared_from_this<Traffic> { |
||||||
|
public: |
||||||
|
static std::shared_ptr<Traffic> create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
class Monitor : public airmap::Traffic::Monitor, |
||||||
|
public airmap::Traffic::Monitor::Subscriber, |
||||||
|
public std::enable_shared_from_this<Monitor> { |
||||||
|
public: |
||||||
|
static std::shared_ptr<Monitor> create(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Traffic::Monitor>& native); |
||||||
|
|
||||||
|
// From airmap::Traffic::Monitor
|
||||||
|
void subscribe(const std::shared_ptr<airmap::Traffic::Monitor::Subscriber>& subscriber) override; |
||||||
|
void unsubscribe(const std::shared_ptr<airmap::Traffic::Monitor::Subscriber>& subscriber) override; |
||||||
|
// From airmap::Traffic::Monitor::Subscriber
|
||||||
|
void handle_update(Update::Type type, const std::vector<Update>& update) override; |
||||||
|
|
||||||
|
private: |
||||||
|
explicit Monitor(const std::shared_ptr<Dispatcher>& dispatcher, |
||||||
|
const std::shared_ptr<airmap::Traffic::Monitor>& native); |
||||||
|
|
||||||
|
std::shared_ptr<Dispatcher> dispatcher_; |
||||||
|
std::shared_ptr<airmap::Traffic::Monitor> native_; |
||||||
|
std::set<std::shared_ptr<airmap::Traffic::Monitor::Subscriber>> subscribers_; |
||||||
|
}; |
||||||
|
|
||||||
|
// From airmap::Traffic
|
||||||
|
void monitor(const Monitor::Params& params, const Monitor::Callback& cb) override; |
||||||
|
|
||||||
|
private: |
||||||
|
explicit Traffic(const std::shared_ptr<Dispatcher>& dispatcher, const std::shared_ptr<airmap::Client>& client); |
||||||
|
|
||||||
|
std::shared_ptr<Dispatcher> dispatcher_; |
||||||
|
std::shared_ptr<airmap::Client> client_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_TRAFFIC_H_
|
@ -0,0 +1,91 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <Airmap/qt/types.h> |
||||||
|
|
||||||
|
namespace { |
||||||
|
|
||||||
|
template <typename T> |
||||||
|
inline void register_type_once(const char* name) { |
||||||
|
static const int id = qRegisterMetaType<T>(name); |
||||||
|
(void)id; |
||||||
|
} |
||||||
|
|
||||||
|
template <typename T> |
||||||
|
inline void register_type_once() { |
||||||
|
static const int id = qRegisterMetaType<T>(); |
||||||
|
(void)id; |
||||||
|
} |
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void airmap::qt::register_types() { |
||||||
|
register_type_once<Aircraft>("Aircraft"); |
||||||
|
register_type_once<Airspace>("Airspace"); |
||||||
|
register_type_once<Credentials>("Credentials"); |
||||||
|
register_type_once<DateTime>("DateTime"); |
||||||
|
register_type_once<Error>("Error"); |
||||||
|
register_type_once<FlightPlan>("FlightPlan"); |
||||||
|
register_type_once<Flight>("Flight"); |
||||||
|
register_type_once<Geometry>("Geometry"); |
||||||
|
register_type_once<Pilot>("Pilot"); |
||||||
|
register_type_once<Rule>("Rule"); |
||||||
|
register_type_once<RuleSet>("RuleSet"); |
||||||
|
register_type_once<RuleSet::Rule>("RuleSet::Rule"); |
||||||
|
register_type_once<Status::Advisory>("Status::Advisory"); |
||||||
|
register_type_once<Status::Wind>("Status::Wind"); |
||||||
|
register_type_once<Status::Weather>("Status::Weather"); |
||||||
|
register_type_once<Status::Report>("Status::Report"); |
||||||
|
register_type_once<Telemetry::Position>("Telemetry::Position"); |
||||||
|
register_type_once<Telemetry::Speed>("Telemetry::Speed"); |
||||||
|
register_type_once<Telemetry::Attitude>("Telemetry::Attitude"); |
||||||
|
register_type_once<Telemetry::Barometer>("Telemetry::Barometer"); |
||||||
|
register_type_once<Optional<Telemetry::Update>>("Optional<Telemetry::Update>"); |
||||||
|
register_type_once<Token::Type>("Token::Type"); |
||||||
|
register_type_once<Token::Anonymous>("Token::Anonymous"); |
||||||
|
register_type_once<Token::OAuth>("Token::OAuth"); |
||||||
|
register_type_once<Token::Refreshed>("Token::Refreshed"); |
||||||
|
register_type_once<Token>("Token"); |
||||||
|
register_type_once<Traffic::Update::Type>("Traffic::Update::Type"); |
||||||
|
register_type_once<Traffic::Update>("Traffic::Update"); |
||||||
|
register_type_once<Version>("Version"); |
||||||
|
|
||||||
|
register_type_once<airmap::Aircraft>("airmap::Aircraft"); |
||||||
|
register_type_once<airmap::Airspace>("airmap::Airspace"); |
||||||
|
register_type_once<airmap::Credentials>("airmap::Credentials"); |
||||||
|
register_type_once<airmap::DateTime>("airmap::DateTime"); |
||||||
|
register_type_once<airmap::Error>("airmap::Error"); |
||||||
|
register_type_once<airmap::FlightPlan>("airmap::FlightPlan"); |
||||||
|
register_type_once<airmap::Flight>("airmap::Flight"); |
||||||
|
register_type_once<airmap::Geometry>("airmap::Geometry"); |
||||||
|
register_type_once<airmap::Pilot>("airmap::Pilot"); |
||||||
|
register_type_once<airmap::Rule>("airmap::Rule"); |
||||||
|
register_type_once<airmap::RuleSet>("airmap::RuleSet"); |
||||||
|
register_type_once<airmap::RuleSet::Rule>("airmap::RuleSet::Rule"); |
||||||
|
register_type_once<airmap::Status::Advisory>("airmap::Advisory"); |
||||||
|
register_type_once<airmap::Status::Wind>("airmap::Wind"); |
||||||
|
register_type_once<airmap::Status::Weather>("airmap::Weather"); |
||||||
|
register_type_once<airmap::Status::Report>("airmap::Report"); |
||||||
|
register_type_once<airmap::Telemetry::Position>("airmap::Telemetry::Position"); |
||||||
|
register_type_once<airmap::Telemetry::Speed>("airmap::Telemetry::Speed"); |
||||||
|
register_type_once<airmap::Telemetry::Attitude>("airmap::Telemetry::Attitude"); |
||||||
|
register_type_once<airmap::Telemetry::Barometer>("airmap::Telemetry::Barometer"); |
||||||
|
register_type_once<airmap::Optional<airmap::Telemetry::Update>>("airmap::Optional<airmap::Telemetry::Update>"); |
||||||
|
register_type_once<airmap::Token::Type>("airmap::Token::Type"); |
||||||
|
register_type_once<airmap::Token::Anonymous>("airmap::Token::Anonymous"); |
||||||
|
register_type_once<airmap::Token::OAuth>("airmap::Token::OAuth"); |
||||||
|
register_type_once<airmap::Token::Refreshed>("airmap::Token::Refreshed"); |
||||||
|
register_type_once<airmap::Token>("airmap::Token"); |
||||||
|
register_type_once<airmap::Traffic::Update::Type>("airmap::Traffic::Update::Type"); |
||||||
|
register_type_once<airmap::Traffic::Update>("airmap::Traffic::Update"); |
||||||
|
register_type_once<airmap::Version>("airmap::Version"); |
||||||
|
} |
@ -0,0 +1,79 @@ |
|||||||
|
// AirMap Platform SDK
|
||||||
|
// Copyright © 2018 AirMap, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the License);
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an AS IS BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef AIRMAP_QT_TYPES_H_ |
||||||
|
#define AIRMAP_QT_TYPES_H_ |
||||||
|
|
||||||
|
#include <airmap/aircraft.h> |
||||||
|
#include <airmap/airspace.h> |
||||||
|
#include <airmap/credentials.h> |
||||||
|
#include <airmap/date_time.h> |
||||||
|
#include <airmap/flight.h> |
||||||
|
#include <airmap/flight_plan.h> |
||||||
|
#include <airmap/geometry.h> |
||||||
|
#include <airmap/optional.h> |
||||||
|
#include <airmap/outcome.h> |
||||||
|
#include <airmap/pilot.h> |
||||||
|
#include <airmap/rule.h> |
||||||
|
#include <airmap/ruleset.h> |
||||||
|
#include <airmap/status.h> |
||||||
|
#include <airmap/telemetry.h> |
||||||
|
#include <airmap/token.h> |
||||||
|
#include <airmap/traffic.h> |
||||||
|
#include <airmap/version.h> |
||||||
|
#include <airmap/visibility.h> |
||||||
|
|
||||||
|
#include <QMetaType> |
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(airmap::Aircraft) |
||||||
|
Q_DECLARE_METATYPE(airmap::Airspace) |
||||||
|
Q_DECLARE_METATYPE(airmap::Credentials) |
||||||
|
Q_DECLARE_METATYPE(airmap::DateTime) |
||||||
|
Q_DECLARE_METATYPE(airmap::Error) |
||||||
|
Q_DECLARE_METATYPE(airmap::FlightPlan) |
||||||
|
Q_DECLARE_METATYPE(airmap::Flight) |
||||||
|
Q_DECLARE_METATYPE(airmap::Geometry) |
||||||
|
Q_DECLARE_METATYPE(airmap::Pilot) |
||||||
|
Q_DECLARE_METATYPE(airmap::Rule) |
||||||
|
Q_DECLARE_METATYPE(airmap::RuleSet) |
||||||
|
Q_DECLARE_METATYPE(airmap::RuleSet::Rule) |
||||||
|
Q_DECLARE_METATYPE(airmap::Status::Advisory) |
||||||
|
Q_DECLARE_METATYPE(airmap::Status::Wind) |
||||||
|
Q_DECLARE_METATYPE(airmap::Status::Weather) |
||||||
|
Q_DECLARE_METATYPE(airmap::Status::Report) |
||||||
|
Q_DECLARE_METATYPE(airmap::Telemetry::Position) |
||||||
|
Q_DECLARE_METATYPE(airmap::Telemetry::Speed) |
||||||
|
Q_DECLARE_METATYPE(airmap::Telemetry::Attitude) |
||||||
|
Q_DECLARE_METATYPE(airmap::Telemetry::Barometer) |
||||||
|
Q_DECLARE_METATYPE(airmap::Optional<airmap::Telemetry::Update>) |
||||||
|
Q_DECLARE_METATYPE(airmap::Token::Type) |
||||||
|
Q_DECLARE_METATYPE(airmap::Token::Anonymous) |
||||||
|
Q_DECLARE_METATYPE(airmap::Token::OAuth) |
||||||
|
Q_DECLARE_METATYPE(airmap::Token::Refreshed) |
||||||
|
Q_DECLARE_METATYPE(airmap::Token) |
||||||
|
Q_DECLARE_METATYPE(airmap::Traffic::Update::Type) |
||||||
|
Q_DECLARE_METATYPE(airmap::Traffic::Update) |
||||||
|
Q_DECLARE_METATYPE(airmap::Version) |
||||||
|
|
||||||
|
namespace airmap { |
||||||
|
namespace qt { |
||||||
|
|
||||||
|
/// register_types makes airmap::* types known to the Qt type system.
|
||||||
|
///
|
||||||
|
/// This function has to be called at least once to be able to use airmap::*
|
||||||
|
/// types in queued signal-slot connections.
|
||||||
|
AIRMAP_EXPORT void register_types(); |
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace airmap
|
||||||
|
|
||||||
|
#endif // AIRMAP_QT_TYPES_H_
|
Loading…
Reference in new issue