diff --git a/src/ATC/trafficcontrol.cxx b/src/ATC/trafficcontrol.cxx index 93878e4ea..0c4e2e5d7 100644 --- a/src/ATC/trafficcontrol.cxx +++ b/src/ATC/trafficcontrol.cxx @@ -52,6 +52,7 @@ #include using std::sort; +using std::string; /*************************************************************************** * ActiveRunway @@ -768,7 +769,7 @@ string FGATCController::formatATCFrequency3_2(int freq) // TODO: Set transponder codes according to real-world routes. // The current version just returns a random string of four octal numbers. -string FGATCController::genTransponderCode(string fltRules) +string FGATCController::genTransponderCode(const string& fltRules) { if (fltRules == "VFR") { return string("1200"); @@ -1687,7 +1688,7 @@ FGATCInstruction FGApproachController::getInstruction(int id) } -ActiveRunway *FGApproachController::getRunway(string name) +ActiveRunway *FGApproachController::getRunway(const string& name) { ActiveRunwayVecIterator rwy = activeRunways.begin(); if (activeRunways.size()) { diff --git a/src/ATC/trafficcontrol.hxx b/src/ATC/trafficcontrol.hxx index 7c17665f9..26d400015 100644 --- a/src/ATC/trafficcontrol.hxx +++ b/src/ATC/trafficcontrol.hxx @@ -21,10 +21,9 @@ #ifndef _TRAFFIC_CONTROL_HXX_ #define _TRAFFIC_CONTROL_HXX_ - -#ifndef __cplusplus -# error This library requires C++ -#endif +#include +#include +#include #include #include @@ -38,18 +37,8 @@ #include #include - -#include -#include -#include - -using std::string; -using std::vector; -using std::list; - - -typedef vector intVec; -typedef vector::iterator intVecIterator; +typedef std::vector intVec; +typedef std::vector::iterator intVecIterator; class FGAIFlightPlan; // forward reference @@ -162,7 +151,7 @@ private: intVec intentions; FGATCInstruction instruction; double latitude, longitude, heading, speed, altitude, radius; - string runway; + std::string runway; //FGAISchedule *trafficRef; FGAIAircraft *aircraft; @@ -177,7 +166,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) { @@ -264,7 +253,7 @@ public: instruction.setResolveCircularWait(false); }; - string getRunway() { + const std::string& getRunway() { return runway; }; //void setCallSign(string clsgn) { callsign = clsgn; }; @@ -317,14 +306,14 @@ public: int getPriority() { return priority; }; }; -typedef list TrafficVector; -typedef list::iterator TrafficVectorIterator; +typedef std::list TrafficVector; +typedef std::list::iterator TrafficVectorIterator; -typedef vector TimeVector; -typedef vector::iterator TimeVectorIterator; +typedef std::vector TimeVector; +typedef std::vector::iterator TimeVectorIterator; -typedef vector AircraftVec; -typedef vector::iterator AircraftVecIterator; +typedef std::vector AircraftVec; +typedef std::vector::iterator AircraftVecIterator; /*********************************************************************** * Active runway, a utility class to keep track of which aircraft has @@ -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 () { @@ -379,8 +368,8 @@ public: void printDepartureCue(); }; -typedef vector ActiveRunwayVec; -typedef vector::iterator ActiveRunwayVecIterator; +typedef std::vector ActiveRunwayVec; +typedef std::vector::iterator ActiveRunwayVecIterator; /** * class FGATCController @@ -399,8 +388,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: @@ -454,9 +443,9 @@ public: dt_count = dt; }; void transmit(FGTrafficRecord *rec, FGAirportDynamics *parent, AtcMsgId msgId, AtcMsgDir msgDir, bool audible); - string getGateName(FGAIAircraft *aircraft); + std::string getGateName(FGAIAircraft *aircraft); virtual void render(bool) = 0; - virtual string getName() = 0; + virtual std::string getName() = 0; virtual void update(double) = 0; @@ -490,7 +479,7 @@ 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; @@ -526,7 +515,7 @@ public: virtual FGATCInstruction getInstruction(int id); virtual void render(bool); - virtual string getName(); + virtual std::string getName(); virtual void update(double dt); bool hasActiveTraffic() { @@ -566,10 +555,10 @@ 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; diff --git a/src/Airports/gnnode.cxx b/src/Airports/gnnode.cxx index 0dc0e8ff0..691a42064 100644 --- a/src/Airports/gnnode.cxx +++ b/src/Airports/gnnode.cxx @@ -9,6 +9,7 @@ #include using std::sort; +using std::string; /***************************************************************************** * Helper function for parsing position string diff --git a/src/Airports/groundnetwork.cxx b/src/Airports/groundnetwork.cxx index 537b74366..62449b0cb 100644 --- a/src/Airports/groundnetwork.cxx +++ b/src/Airports/groundnetwork.cxx @@ -53,6 +53,7 @@ #include "groundnetwork.hxx" +using std::string; /*************************************************************************** * FGTaxiSegment diff --git a/src/Airports/groundnetwork.hxx b/src/Airports/groundnetwork.hxx index 2cb78d09a..b79bdfc69 100644 --- a/src/Airports/groundnetwork.hxx +++ b/src/Airports/groundnetwork.hxx @@ -47,8 +47,8 @@ class FGTaxiSegment; // forward reference class FGAIFlightPlan; // forward reference class FGAirport; // forward reference -typedef vector FGTaxiSegmentVector; -typedef vector::iterator FGTaxiSegmentVectorIterator; +typedef std::vector FGTaxiSegmentVector; +typedef std::vector::iterator FGTaxiSegmentVectorIterator; //typedef vector FGTaxiSegmentPointerVector; //typedef vector::iterator FGTaxiSegmentPointerVectorIterator; @@ -69,7 +69,7 @@ public: bool operator< (const Block &other) const { return blocktime < other.blocktime; }; }; -typedef vector BlockList; +typedef std::vector BlockList; typedef BlockList::iterator BlockListIterator; /*************************************************************************************** @@ -213,8 +213,8 @@ public: -typedef vector intVec; -typedef vector::iterator intVecIterator; +typedef std::vector intVec; +typedef std::vector::iterator intVecIterator; @@ -289,8 +289,8 @@ public: // int getDepth() { return depth; }; }; -typedef vector TaxiRouteVector; -typedef vector::iterator TaxiRouteVectorIterator; +typedef std::vector TaxiRouteVector; +typedef std::vector::iterator TaxiRouteVectorIterator; /************************************************************************************** * class FGGroundNetWork @@ -377,7 +377,7 @@ public: AtcMsgDir msgDir); bool checkForCircularWaits(int id); virtual void render(bool); - virtual string getName(); + virtual std::string getName(); virtual void update(double dt); void saveElevationCache();