]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/FlightPlan.hxx
commradio: improvements for atis speech
[flightgear.git] / src / Navaids / FlightPlan.hxx
index b46dae03c7a11230b2bd8f8b2713dc592642a421..11d98643d201a85c42234823b0b6b35d865248e8 100644 (file)
 #define FG_FLIGHTPLAN_HXX
 
 #include <Navaids/route.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
-typedef SGSharedPtr<FGAirport> FGAirportRef;
-    
 namespace flightgear
 {
 
 class Transition;
-
+class FlightPlan;
+    
+typedef SGSharedPtr<FlightPlan> FlightPlanRef;
+    
 class FlightPlan : public RouteBase
 {
 public:
@@ -100,13 +101,13 @@ public:
   {
   public:
     virtual ~Delegate();
-    
+        
     virtual void departureChanged() { }
     virtual void arrivalChanged() { }
     virtual void waypointsChanged() { }
-    
+    virtual void cleared() { }
     virtual void currentWaypointChanged() { }
-  
+    virtual void endOfFlightPlan() { }
   protected:
     Delegate();
     
@@ -117,9 +118,12 @@ public:
     void runArrivalChanged();
     void runWaypointsChanged();
     void runCurrentWaypointChanged();
-    
+    void runCleared();
+    void runFinished();
+      
     friend class FlightPlan;
     
+    bool _deleteWithPlan;
     Delegate* _inner;
   };
   
@@ -135,6 +139,8 @@ public:
   
   void setCurrentIndex(int index);
   
+  void finish();
+    
   Leg* currentLeg() const;
   Leg* nextLeg() const;
   Leg* previousLeg() const;
@@ -198,6 +204,13 @@ public:
   double totalDistanceNm() const
   { return _totalDistance; }
   
+  /**
+   * given a waypoint index, and an offset in NM, find the geodetic
+   * position on the route path. I.e the point 10nm before or after
+   * a particular waypoint.
+   */
+  SGGeod pointAlongRoute(int aIndex, double aOffsetNm) const;
+    
   /**
    * Create a WayPoint from a string in the following format:
    *  - simple identifier
@@ -207,11 +220,34 @@ public:
    */
   WayptRef waypointFromString(const std::string& target);
   
-  void setDelegate(Delegate* d);
+  /**
+   * abstract interface for creating delegates automatically when a
+   * flight-plan is created or loaded
+   */
+  class DelegateFactory
+  {
+  public:
+    virtual Delegate* createFlightPlanDelegate(FlightPlan* fp) = 0;
+  };
+  
+  static void registerDelegateFactory(DelegateFactory* df);
+  static void unregisterDelegateFactory(DelegateFactory* df);
+  
+  void addDelegate(Delegate* d);
   void removeDelegate(Delegate* d);
 private:
+  void lockDelegate();
+  void unlockDelegate();
+  
+  int _delegateLock;
+  bool _arrivalChanged, 
+    _departureChanged, 
+    _waypointsChanged, 
+    _currentWaypointChanged;
   
-  bool loadPlainTextRoute(const SGPath& path);
+  bool loadXmlFormat(const SGPath& path);
+  bool loadGpxFormat(const SGPath& path);
+  bool loadPlainTextFormat(const SGPath& path);
   
   void loadVersion1XMLRoute(SGPropertyNode_ptr routeData);
   void loadVersion2XMLRoute(SGPropertyNode_ptr routeData);
@@ -225,9 +261,9 @@ private:
   
   FGAirportRef _departure, _destination;
   FGRunway* _departureRunway, *_destinationRunway;
-  SID* _sid;
-  STAR* _star;
-  Approach* _approach;
+  SGSharedPtr<SID> _sid;
+  SGSharedPtr<STAR> _star;
+  SGSharedPtr<Approach> _approach;
   std::string _sidTransition, _starTransition;
   
   double _totalDistance;