flight_plans.h 7.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
#ifndef AIRMAP_FLIGHT_PLANS_H_
#define AIRMAP_FLIGHT_PLANS_H_

#include <airmap/do_not_copy_or_move.h>
#include <airmap/error.h>
#include <airmap/flight_plan.h>
#include <airmap/outcome.h>

#include <cstdint>
#include <functional>
#include <vector>

namespace airmap {

/// FlightPlans provides functionality for managing flight plans.
class FlightPlans : DoNotCopyOrMove {
 public:
  /// ForId bundles up types to ease interaction with
  /// FlightPlans::for_id.
  struct ForId {
    /// Parameters bundles up input parameters.
    struct Parameters {
      Optional<std::string> authorization;  ///< Authorization token obtained by logging in to the AirMap services.
      FlightPlan::Id id;                    ///< Search for the flight with this id.
    };

    /// Result models the outcome of calling FlightPlans::for_id.
    using Result = Outcome<FlightPlan, Error>;
    /// Callback describes the function signature of the callback that is invoked
    /// when a call to FlightPlans::for_id finishes.
    using Callback = std::function<void(const Result&)>;
  };

  /// Create bundles up types to ease interaction with
  /// FlightPlans::create_by_point and FlightPlans::create_by_polygon.
  struct Create {
    /// Parameters bundles up input parameters.
    struct Parameters {
      std::string authorization;           ///< Authorization token obtained by logging in to the AirMap services.
      Pilot pilot;                         ///< The pilot responsible for the flight.
      Optional<Pilot::Aircraft> aircraft;  ///< The aircraft conducting the flight.
      float latitude;                      ///< The latitude component of the takeoff point in [°].
      float longitude;                     ///< The longitude component of the takeoff point in [°].
      float max_altitude;                  ///< The maximum altitude over the entire flight in [m].
      float min_altitude;                  ///< The minimum altitude over the entire flight in [m].
      float buffer;                        ///< The buffer in [m] around the geometry.
      Geometry geometry;                   ///< The geometry describing the flight.
      DateTime start_time;                 ///< Point in time when the flight will start/was started.
      DateTime end_time;                   ///< Point in time when the fligth will end.
      std::vector<RuleSet::Id> rulesets;   ///< RuleSets that apply to this flight plan.
      std::unordered_map<std::string, RuleSet::Feature::Value>
          features;  ///< Additional properties of the planned flight.
    };

    /// Result models the outcome of calling FlightPlans::create_by_polygon.
    using Result = Outcome<FlightPlan, Error>;
    /// Callback describes the function signature of the callback that is invoked
    /// when a call to FlightPlans::create_by_point or FlightPlans::create_by_polygon finishes.
    using Callback = std::function<void(const Result&)>;
  };

  /// Update bundles up types to ease interaction with
  /// FlightPlans::update.
  struct Update {
    /// Parameters bundles up input parameters.
    struct Parameters {
      Optional<std::string> authorization;  ///< Authorization token obtained by logging in to the AirMap services.
      FlightPlan flight_plan;  ///< The details of the plan that should be created with the AirMap services.
    };
    /// Result models the outcome of calling FlightPlans::update.
    using Result = Outcome<FlightPlan, Error>;
    /// Callback describes the function signature of the callback that is invoked
    /// when a call to FlightPlans::update finishes.
    using Callback = std::function<void(const Result&)>;
  };

  /// Delete bundles up types to ease interaction with
  /// FlightPlans::delete_.
  struct Delete {
    /// Parameters bundles up input parameters.
    struct Parameters {
      Optional<std::string> authorization;  ///< Authorization token obtained by logging in to the AirMap services.
      FlightPlan::Id id;                    ///< Id of the flight plan that should be deleted.
    };

    /// Response models the response from the AirMap services.
    struct Response {
      FlightPlan::Id id;  ///< Id of the flight plan that was deleted.
    };

    /// Result models the outcome of calling FlightPlans::delete_flight.
    using Result = Outcome<Response, Error>;
    /// Callback describes the function signature of the callback that is
    /// invoked when a call to FlightPlans::delete_flight finishes.
    using Callback = std::function<void(const Result&)>;
  };

  /// RenderBriefing bundles up types to ease interaction with
  /// FlightPlans::render_briefing.
  struct RenderBriefing {
    /// Parameters bundles up input parameters.
    struct Parameters {
      Optional<std::string> authorization;  ///< Authorization token obtained by logging in to the AirMap services.
      FlightPlan::Id id;                    ///< Id of the flight plan that should be rendered as a briefing.
    };
    /// Result models the outcome of calling FlightPlans::submit.
    using Result = Outcome<FlightPlan::Briefing, Error>;
    /// Callback describes the function signature of the callback that is invoked
    /// when a call to FlightPlans::submit finishes.
    using Callback = std::function<void(const Result&)>;
  };

  /// Submit bundles up types to ease interaction with
  /// FlightPlans::submit.
  struct Submit {
    /// Parameters bundles up input parameters.
    struct Parameters {
      Optional<std::string> authorization;  ///< Authorization token obtained by logging in to the AirMap services.
      FlightPlan::Id id;                    ///< Id of the flight plan that should be submitted.
    };
    /// Result models the outcome of calling FlightPlans::submit.
    using Result = Outcome<FlightPlan, Error>;
    /// Callback describes the function signature of the callback that is invoked
    /// when a call to FlightPlans::submit finishes.
    using Callback = std::function<void(const Result&)>;
  };

  /// for_id queries the AirMap services for detailed information about
  /// a flight plan identified by a UUID and reports back results to 'cb'.
  virtual void for_id(const ForId::Parameters& parameters, const ForId::Callback& cb) = 0;

  /// create_by_polygon creates a flight plan for 'parameters' and reports
  /// results back to 'cb'.
  virtual void create_by_polygon(const Create::Parameters& parameters, const Create::Callback& cb) = 0;

  /// update updates a flight plan identified by 'parameters' and reports
  /// results back to 'cb'.
  virtual void update(const Update::Parameters& parameters, const Update::Callback& cb) = 0;

  /// delete deletes a flight plan identified by 'parameters' and reports
  /// results back to 'cb'.
  virtual void delete_(const Delete::Parameters& parameters, const Delete::Callback& cb) = 0;

  /// render_briefing requests rendering a briefing for a flight plan identified by 'parameters' and reports
  /// results back to 'cb'.
  virtual void render_briefing(const RenderBriefing::Parameters& parameters, const RenderBriefing::Callback& cb) = 0;

  /// submit submits a flight plan identified by 'parameters' and reports
  /// results back to 'cb'.
  virtual void submit(const Submit::Parameters& parameters, const Submit::Callback& cb) = 0;

 protected:
  /// @cond
  FlightPlans() = default;
  /// @endcond
};

}  // namespace airmap

#endif  // AIRMAP_FLIGHT_PLANS_H_