X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FATC%2Ftrafficcontrol.hxx;h=bdedf0e1e902b57d6c45f95ac5794835512ba07c;hb=ea13c0f2de111a56bd4bf97113b50e29a693c7fc;hp=e4ce4c6bb8e2a9be7289f0b5f38ab673fb2756c5;hpb=4640f5bb025f2466184083803a31dc0b742f3d9c;p=flightgear.git diff --git a/src/ATC/trafficcontrol.hxx b/src/ATC/trafficcontrol.hxx index e4ce4c6bb..bdedf0e1e 100644 --- a/src/ATC/trafficcontrol.hxx +++ b/src/ATC/trafficcontrol.hxx @@ -21,10 +21,7 @@ #ifndef _TRAFFIC_CONTROL_HXX_ #define _TRAFFIC_CONTROL_HXX_ - -#ifndef __cplusplus -# error This library requires C++ -#endif +#include #include #include @@ -38,24 +35,25 @@ #include #include +class FGAIAircraft; +typedef std::vector AircraftVec; +typedef std::vector::iterator AircraftVecIterator; -#include -#include -#include - -using std::string; -using std::vector; -using std::list; +class FGAIFlightPlan; +typedef std::vector FlightPlanVec; +typedef std::vector::iterator FlightPlanVecIterator; +typedef std::map FlightPlanVecMap; +class FGTrafficRecord; +typedef std::list TrafficVector; +typedef std::list::iterator TrafficVectorIterator; -typedef vector intVec; -typedef vector::iterator intVecIterator; +class ActiveRunway; +typedef std::vector ActiveRunwayVec; +typedef std::vector::iterator ActiveRunwayVecIterator; - -class FGAIFlightPlan; // forward reference -class FGGroundNetwork; // forward reference -class FGAIAircraft; // forward reference -class FGAirportDynamics; +typedef std::vector intVec; +typedef std::vector::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 TrafficVector; -typedef list::iterator TrafficVectorIterator; - -typedef vector TimeVector; -typedef vector::iterator TimeVectorIterator; - -typedef vector AircraftVec; -typedef vector::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::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 ActiveRunwayVec; -typedef vector::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;