]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/trafficcontrol.hxx
Cleanup, no functional change
[flightgear.git] / src / ATC / trafficcontrol.hxx
index e4ce4c6bb8e2a9be7289f0b5f38ab673fb2756c5..bdedf0e1e902b57d6c45f95ac5794835512ba07c 100644 (file)
 #ifndef _TRAFFIC_CONTROL_HXX_
 #define _TRAFFIC_CONTROL_HXX_
 
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
+#include <Airports/airports_fwd.hxx>
 
 #include <osg/Geode>
 #include <osg/Geometry>
 #include <simgear/structure/SGReferenced.hxx>
 #include <simgear/structure/SGSharedPtr.hxx>
 
+class FGAIAircraft;
+typedef std::vector<FGAIAircraft*> AircraftVec;
+typedef std::vector<FGAIAircraft*>::iterator AircraftVecIterator;
 
-#include <string>
-#include <vector>
-#include <list>
-
-using std::string;
-using std::vector;
-using std::list;
+class FGAIFlightPlan;
+typedef std::vector<FGAIFlightPlan*>           FlightPlanVec;
+typedef std::vector<FGAIFlightPlan*>::iterator FlightPlanVecIterator;
+typedef std::map<std::string, FlightPlanVec>   FlightPlanVecMap;
 
+class FGTrafficRecord;
+typedef std::list<FGTrafficRecord> TrafficVector;
+typedef std::list<FGTrafficRecord>::iterator TrafficVectorIterator;
 
-typedef vector<int> intVec;
-typedef vector<int>::iterator intVecIterator;
+class ActiveRunway;
+typedef std::vector<ActiveRunway> ActiveRunwayVec;
+typedef std::vector<ActiveRunway>::iterator ActiveRunwayVecIterator;
 
-
-class FGAIFlightPlan;  // forward reference
-class FGGroundNetwork; // forward reference
-class FGAIAircraft;    // forward reference
-class FGAirportDynamics;
+typedef std::vector<int> intVec;
+typedef std::vector<int>::iterator intVecIterator;
 
 /**************************************************************************************
  * class FGATCInstruction
@@ -78,34 +76,34 @@ private:
 public:
 
     FGATCInstruction();
-    bool hasInstruction   ();
-    bool getHoldPattern   () {
+    bool hasInstruction   () const;
+    bool getHoldPattern   () const {
         return holdPattern;
     };
-    bool getHoldPosition  () {
+    bool getHoldPosition  () const {
         return holdPosition;
     };
-    bool getChangeSpeed   () {
+    bool getChangeSpeed   () const {
         return changeSpeed;
     };
-    bool getChangeHeading () {
+    bool getChangeHeading () const {
         return changeHeading;
     };
-    bool getChangeAltitude() {
+    bool getChangeAltitude() const {
         return changeAltitude;
     };
 
-    double getSpeed       () {
+    double getSpeed       () const {
         return speed;
     };
-    double getHeading     () {
+    double getHeading     () const {
         return heading;
     };
-    double getAlt         () {
+    double getAlt         () const {
         return alt;
     };
 
-    bool getCheckForCircularWait() {
+    bool getCheckForCircularWait() const {
         return resolveCircularWait;
     };
 
@@ -162,7 +160,7 @@ private:
     intVec intentions;
     FGATCInstruction instruction;
     double latitude, longitude, heading, speed, altitude, radius;
-    string runway;
+    std::string runway;
     //FGAISchedule *trafficRef;
     FGAIAircraft *aircraft;
 
@@ -177,7 +175,7 @@ public:
         radius = rad;
     };
     void setPositionAndIntentions(int pos, FGAIFlightPlan *route);
-    void setRunway(string rwy) {
+    void setRunway(const std::string& rwy) {
         runway = rwy;
     };
     void setLeg(int lg) {
@@ -203,34 +201,34 @@ public:
     int  crosses                   (FGGroundNetwork *, FGTrafficRecord &other);
     bool isOpposing                (FGGroundNetwork *, FGTrafficRecord &other, int node);
     
-    bool isActive(int margin);
+    bool isActive(int margin) const;
 
     bool onRoute(FGGroundNetwork *, FGTrafficRecord &other);
 
-    bool getSpeedAdjustment() {
+    bool getSpeedAdjustment() const {
         return instruction.getChangeSpeed();
     };
 
-    double getLatitude () {
+    double getLatitude () const {
         return latitude ;
     };
-    double getLongitude() {
+    double getLongitude() const {
         return longitude;
     };
-    double getHeading  () {
+    double getHeading  () const {
         return heading  ;
     };
-    double getSpeed    () {
+    double getSpeed    () const {
         return speed    ;
     };
-    double getAltitude () {
+    double getAltitude () const {
         return altitude ;
     };
-    double getRadius   () {
+    double getRadius   () const {
         return radius   ;
     };
 
-    int getWaitsForId  () {
+    int getWaitsForId  () const {
         return waitsForId;
     };
 
@@ -243,10 +241,10 @@ public:
         instruction.setChangeHeading(false);
     };
 
-    bool hasHeadingAdjustment() {
+    bool hasHeadingAdjustment() const {
         return instruction.getChangeHeading();
     };
-    bool hasHoldPosition() {
+    bool hasHoldPosition() const {
         return instruction.getHoldPosition();
     };
     void setHoldPosition (bool inst) {
@@ -264,7 +262,7 @@ public:
         instruction.setResolveCircularWait(false);
     };
 
-    string getRunway() {
+    const std::string& getRunway() const {
         return runway;
     };
     //void setCallSign(string clsgn) { callsign = clsgn; };
@@ -276,21 +274,21 @@ public:
         allowTransmission=true;
     };
     //string getCallSign() { return callsign; };
-    FGAIAircraft *getAircraft() {
+    FGAIAircraft *getAircraft() const {
         return aircraft;
     };
-    int getTime() {
+    int getTime() const {
         return timer;
     };
-    int getLeg() {
+    int getLeg() const {
         return leg;
     };
     void setTime(time_t time) {
         timer = time;
     };
 
-    bool pushBackAllowed();
-    bool allowTransmissions() {
+    bool pushBackAllowed() const;
+    bool allowTransmissions() const {
         return allowTransmission;
     };
     void allowPushBack() { allowPushback =true;};
@@ -304,28 +302,19 @@ public:
     void nextFrequency() {
         frequencyId++;
     };
-    int  getNextFrequency() {
+    int  getNextFrequency() const {
         return frequencyId;
     };
     intVec& getIntentions() {
         return intentions;
     };
-    int getCurrentPosition() {
+    int getCurrentPosition() const {
         return currentPos;
     };
     void setPriority(int p) { priority = p; };
-    int getPriority()       { return priority; };
+    int getPriority() const { return priority; };
 };
 
-typedef list<FGTrafficRecord> TrafficVector;
-typedef list<FGTrafficRecord>::iterator TrafficVectorIterator;
-
-typedef vector<time_t> TimeVector;
-typedef vector<time_t>::iterator TimeVectorIterator;
-
-typedef vector<FGAIAircraft*> AircraftVec;
-typedef vector<FGAIAircraft*>::iterator AircraftVecIterator;
-
 /***********************************************************************
  * Active runway, a utility class to keep track of which aircraft has
  * clearance for a given runway.
@@ -333,20 +322,20 @@ typedef vector<FGAIAircraft*>::iterator AircraftVecIterator;
 class ActiveRunway
 {
 private:
-    string rwy;
+    std::string rwy;
     int currentlyCleared;
     double distanceToFinal;
     TimeVector estimatedArrivalTimes;
     AircraftVec departureCue;
 
 public:
-    ActiveRunway(string r, int cc) {
+    ActiveRunway(const std::string& r, int cc) {
         rwy = r;
         currentlyCleared = cc;
         distanceToFinal = 6.0 * SG_NM_TO_METER;
     };
 
-    string getRunwayName() {
+    std::string getRunwayName() {
         return rwy;
     };
     int    getCleared   () {
@@ -372,14 +361,13 @@ public:
     FGAIAircraft* getFirstAircraftInDepartureCue() {
         return departureCue.size() ? *(departureCue.begin()) : NULL;
     };
+    FGAIAircraft* getFirstOfStatus(int stat);
     void updateDepartureCue() {
         departureCue.erase(departureCue.begin());
     }
+    void printDepartureCue();
 };
 
-typedef vector<ActiveRunway> ActiveRunwayVec;
-typedef vector<ActiveRunway>::iterator ActiveRunwayVecIterator;
-
 /**
  * class FGATCController
  * NOTE: this class serves as an abstraction layer for all sorts of ATC controllers.
@@ -397,8 +385,8 @@ protected:
     double dt_count;
     osg::Group* group;
 
-    string formatATCFrequency3_2(int );
-    string genTransponderCode(string fltRules);
+    std::string formatATCFrequency3_2(int );
+    std::string genTransponderCode(const std::string& fltRules);
     bool isUserAircraft(FGAIAircraft*);
 
 public:
@@ -451,10 +439,10 @@ public:
     void   setDt(double dt) {
         dt_count = dt;
     };
-    void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir, bool audible);
-    string getGateName(FGAIAircraft *aircraft);
+    void transmit(FGTrafficRecord *rec, FGAirportDynamics *parent, AtcMsgId msgId, AtcMsgDir msgDir, bool audible);
+    std::string getGateName(FGAIAircraft *aircraft);
     virtual void render(bool) = 0;
-    virtual string getName()  = 0;
+    virtual std::string getName()  = 0;
 
     virtual void update(double) = 0;
 
@@ -488,10 +476,10 @@ public:
     virtual FGATCInstruction getInstruction(int id);
 
     virtual void render(bool);
-    virtual string getName();
+    virtual std::string getName();
     virtual void update(double dt);
     bool hasActiveTraffic() {
-        return activeTraffic.size() != 0;
+        return ! activeTraffic.empty();
     };
     TrafficVector &getActiveTraffic() {
         return activeTraffic;
@@ -524,11 +512,11 @@ public:
     virtual FGATCInstruction getInstruction(int id);
 
     virtual void render(bool);
-    virtual string getName();
+    virtual std::string getName();
     virtual void update(double dt);
 
     bool hasActiveTraffic() {
-        return activeTraffic.size() != 0;
+        return ! activeTraffic.empty();
     };
     TrafficVector &getActiveTraffic() {
         return activeTraffic;
@@ -564,13 +552,13 @@ public:
     virtual FGATCInstruction getInstruction(int id);
 
     virtual void render(bool);
-    virtual string getName();
+    virtual std::string getName();
     virtual void update(double dt);
 
-    ActiveRunway* getRunway(string name);
+    ActiveRunway* getRunway(const std::string& name);
 
     bool hasActiveTraffic() {
-        return activeTraffic.size() != 0;
+        return ! activeTraffic.empty();
     };
     TrafficVector &getActiveTraffic() {
         return activeTraffic;