]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/groundnetwork.hxx
Interim windows build fix
[flightgear.git] / src / Airports / groundnetwork.hxx
index de8d94ed44a5008af63bf98f341b5a2a585d2abd..7f0b5cfdd86e57fb587f8ac49cbbb11c36294611 100644 (file)
 #include <simgear/compiler.h>
 
 #include <string>
-#include <vector>
-#include <list>
-#include <map>
 
 #include "gnnode.hxx"
 #include "parking.hxx"
-#include <ATC/trafficcontrol.hxx>
 
+class FGAirportDynamicsXMLLoader;
 
-class Block;
-class FGRunway;
-class FGTaxiSegment; // forward reference
-class FGAIFlightPlan; // forward reference
-class FGAirport;      // forward reference
-
-typedef std::vector<FGTaxiSegment*>  FGTaxiSegmentVector;
-typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
-
-typedef std::map<int, FGTaxiNode_ptr> IndexTaxiNodeMap;
+typedef std::vector<int> intVec;
+typedef std::vector<int>::iterator intVecIterator;
 
 class Block
 {
@@ -63,27 +52,26 @@ public:
     bool operator< (const Block &other) const { return blocktime < other.blocktime; };
 };
 
-typedef std::vector<Block> BlockList;
-typedef BlockList::iterator BlockListIterator;
-
 /***************************************************************************************
  * class FGTaxiSegment
  **************************************************************************************/
 class FGTaxiSegment
 {
 private:
-    const PositionedID startNode;
-    const PositionedID endNode;
+    // weak (non-owning) pointers deliberately here:
+    // the ground-network owns the nodes
+    const FGTaxiNode* startNode;
+    const FGTaxiNode* endNode;
     
     bool isActive;
     BlockList blockTimes;
 
     int index;
-    FGTaxiSegment *oppositeDirection;
+    FGTaxiSegment *oppositeDirection; // also deliberatley weak
 
     friend class FGGroundNetwork;
 public:
-    FGTaxiSegment(PositionedID start, PositionedID end);
+    FGTaxiSegment(FGTaxiNode* start, FGTaxiNode* end);
   
     void setIndex        (int val) {
         index     = val;
@@ -94,8 +82,8 @@ public:
     void unblock(time_t now); 
     bool hasBlock(time_t now);
 
-    FGTaxiNode * getEnd() const;
-    FGTaxiNode * getStart() const;
+    FGTaxiNodeRef getEnd() const;
+    FGTaxiNodeRef getStart() const;
   
     double getLength() const;
   
@@ -119,47 +107,48 @@ public:
     };
 };
 
-
-
-
-typedef std::vector<int> intVec;
-typedef std::vector<int>::iterator intVecIterator;
-
-
-
 /***************************************************************************************
  * class FGTaxiRoute
  **************************************************************************************/
 class FGTaxiRoute
 {
 private:
-    PositionedIDVec nodes;
+    FGTaxiNodeVector nodes;
+    intVec routes;
     double distance;
-    PositionedIDVec::iterator currNode;
+    FGTaxiNodeVector::iterator currNode;
+    intVec::iterator currRoute;
 
 public:
     FGTaxiRoute() {
         distance = 0;
         currNode = nodes.begin();
+        currRoute = routes.begin();
     };
   
-    FGTaxiRoute(const PositionedIDVec& nds, double dist, int dpth) {
+    FGTaxiRoute(const FGTaxiNodeVector& nds, intVec rts,  double dist, int dpth) {
         nodes = nds;
+        routes = rts;
         distance = dist;
         currNode = nodes.begin();
+        currRoute = routes.begin();
     };
 
     FGTaxiRoute& operator= (const FGTaxiRoute &other) {
         nodes = other.nodes;
+        routes = other.routes;
         distance = other.distance;
         currNode = nodes.begin();
+        currRoute = routes.begin();
         return *this;
     };
 
     FGTaxiRoute(const FGTaxiRoute& copy) :
             nodes(copy.nodes),
+            routes(copy.routes),
             distance(copy.distance),
-            currNode(nodes.begin())
+            currNode(nodes.begin()),
+            currRoute(routes.begin())
     {};
 
     bool operator< (const FGTaxiRoute &other) const {
@@ -168,10 +157,11 @@ public:
     bool empty () {
         return nodes.empty();
     };
-    bool next(PositionedID *nde);
+    bool next(FGTaxiNodeRef& nde, int *rte);
   
     void first() {
         currNode = nodes.begin();
+        currRoute = routes.begin();
     };
     int size() {
         return nodes.size();
@@ -181,32 +171,28 @@ public:
     };
 };
 
-typedef std::vector<FGTaxiRoute> TaxiRouteVector;
-typedef std::vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
-
 /**************************************************************************************
  * class FGGroundNetWork
  *************************************************************************************/
-class FGGroundNetwork : public FGATCController
+class FGGroundNetwork
 {
 private:
+    friend class FGAirportDynamicsXMLLoader;
+
+    FGAirportDynamics* dynamics; // weak back-pointer to our owner
     bool hasNetwork;
     bool networkInitialized;
-    time_t nextSave;
-    //int maxDepth;
-    int count;
+
     int version;
   
     FGTaxiSegmentVector segments;
 
-    TrafficVector activeTraffic;
-    TrafficVectorIterator currTraffic;
-
-    bool foundRoute;
-    double totalDistance, maxDistance;
-    FGTowerController *towerController;
     FGAirport *parent;
 
+    FGParkingList m_parkings;
+    FGTaxiNodeVector m_nodes;
+
+    FGTaxiNodeRef findNodeByIndex(int index) const;
 
     //void printRoutingError(string);
 
@@ -216,9 +202,11 @@ private:
                            double heading, double speed, double alt);
 
 
-    void parseCache();
-  
-    void loadSegments();
+    void addSegment(const FGTaxiNodeRef& from, const FGTaxiNodeRef& to);
+    void addParking(const FGParkingRef& park);
+
+    FGTaxiNodeVector segmentsFrom(const FGTaxiNodeRef& from) const;
+
 public:
     FGGroundNetwork();
     ~FGGroundNetwork();
@@ -226,47 +214,36 @@ public:
     void setVersion (int v) { version = v;};
     int getVersion() { return version; };
 
-    void init(FGAirport* pr);
+    void init(FGAirportDynamics* pr);
     bool exists() {
         return hasNetwork;
     };
-    void setTowerController(FGTowerController *twrCtrlr) {
-        towerController = twrCtrlr;
-    };
 
-    int findNearestNode(const SGGeod& aGeod) const;
-    int findNearestNodeOnRunway(const SGGeod& aGeod, FGRunway* aRunway = NULL) const;
+    FGTaxiNodeRef findNearestNode(const SGGeod& aGeod) const;
+    FGTaxiNodeRef findNearestNodeOnRunway(const SGGeod& aGeod, FGRunway* aRunway = NULL) const;
+
+    FGTaxiSegment *findSegment(unsigned int idx) const;
+
+    FGTaxiSegment* findOppositeSegment(unsigned int index) const;
+
+    const FGParkingList& allParkings() const;
 
-    FGTaxiNode *findNode(PositionedID idx) const;
-    FGTaxiSegment *findSegment(unsigned idx) const;
-  
     /**
      * Find the taxiway segment joining two (ground-net) nodes. Returns
      * NULL if no such segment exists.
-     * It is permitted to pass 0 for the 'to' ID, indicating that any
+     * It is permitted to pass HULL for the 'to' indicating that any
      * segment originating at 'from' is acceptable.
      */
-    FGTaxiSegment* findSegment(PositionedID from, PositionedID to) const;
+    FGTaxiSegment *findSegment(const FGTaxiNode* from, const FGTaxiNode* to) const;
   
-    FGTaxiRoute findShortestRoute(PositionedID start, PositionedID end, bool fullSearch=true);
-
-    virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
-                                  double lat, double lon, double hdg, double spd, double alt,
-                                  double radius, int leg, FGAIAircraft *aircraft);
-    virtual void signOff(int id);
-    virtual void updateAircraftInformation(int id, double lat, double lon, double heading, double speed, double alt, double dt);
-    virtual bool hasInstruction(int id);
-    virtual FGATCInstruction getInstruction(int id);
-
-    bool checkTransmissionState(int minState, int MaxState, TrafficVectorIterator i, time_t now, AtcMsgId msgId,
-                                AtcMsgDir msgDir);
-    bool checkForCircularWaits(int id);
-    virtual void render(bool);
-    virtual std::string getName();
-    virtual void update(double dt);
-
-    void saveElevationCache();
+    FGTaxiRoute findShortestRoute(FGTaxiNode* start, FGTaxiNode* end, bool fullSearch=true);
+
+
+    void blockSegmentsEndingAt(FGTaxiSegment* seg, int blockId,
+                               time_t blockTime, time_t now);
+
     void addVersion(int v) {version = v; };
+    void unblockAllSegments(time_t now);
 };