1
0
Fork 0

traffic: more pass by reference + member init

This commit is contained in:
ThorstenB 2012-11-25 16:41:10 +01:00
parent b682ae91d6
commit 1c6643d7ac
7 changed files with 47 additions and 40 deletions

View file

@ -96,6 +96,7 @@ FGAIAircraft::FGAIAircraft(FGAISchedule *ref) :
takeOffStatus = 0; takeOffStatus = 0;
trackCache.remainingLength = 0; trackCache.remainingLength = 0;
trackCache.startWptName = "-";
} }
@ -631,7 +632,7 @@ void FGAIAircraft::scheduleForATCTowerDepartureControl(int state) {
// Process ATC instructions and report back // Process ATC instructions and report back
void FGAIAircraft::processATC(FGATCInstruction instruction) { void FGAIAircraft::processATC(const FGATCInstruction& instruction) {
if (instruction.getCheckForCircularWait()) { if (instruction.getCheckForCircularWait()) {
// This is not exactly an elegant solution, // This is not exactly an elegant solution,
// but at least it gives me a chance to check // but at least it gives me a chance to check

View file

@ -73,7 +73,7 @@ public:
void setCompany(const std::string& comp) { company = comp;}; void setCompany(const std::string& comp) { company = comp;};
void announcePositionToController(); //TODO have to be public? void announcePositionToController(); //TODO have to be public?
void processATC(FGATCInstruction instruction); void processATC(const FGATCInstruction& instruction);
void setTaxiClearanceRequest(bool arg) { needsTaxiClearance = arg; }; void setTaxiClearanceRequest(bool arg) { needsTaxiClearance = arg; };
bool getTaxiClearanceRequest() { return needsTaxiClearance; }; bool getTaxiClearanceRequest() { return needsTaxiClearance; };
FGAISchedule * getTrafficRef() { return trafficRef; }; FGAISchedule * getTrafficRef() { return trafficRef; };

View file

@ -447,7 +447,7 @@ int FGAIFlightPlan::getRouteIndex(int i) {
return 0; return 0;
} }
double FGAIFlightPlan::checkTrackLength(const string& wptName) { double FGAIFlightPlan::checkTrackLength(const string& wptName) const {
// skip the first two waypoints: first one is behind, second one is partially done; // skip the first two waypoints: first one is behind, second one is partially done;
double trackDistance = 0; double trackDistance = 0;
wpt_vector_iterator wptvec = waypoints.begin(); wpt_vector_iterator wptvec = waypoints.begin();
@ -471,7 +471,7 @@ void FGAIFlightPlan::shortenToFirst(unsigned int number, string name)
(waypoints.back())->setName((waypoints.back())->getName() + name); (waypoints.back())->setName((waypoints.back())->getName() + name);
} }
void FGAIFlightPlan::setGate(ParkingAssignment pka) void FGAIFlightPlan::setGate(const ParkingAssignment& pka)
{ {
gate = pka; gate = pka;
} }

View file

@ -130,7 +130,7 @@ public:
double getBearing(FGAIWaypoint* previous, FGAIWaypoint* next) const; double getBearing(FGAIWaypoint* previous, FGAIWaypoint* next) const;
double getBearing(const SGGeod& aPos, FGAIWaypoint* next) const; double getBearing(const SGGeod& aPos, FGAIWaypoint* next) const;
double checkTrackLength(const std::string& wptName); double checkTrackLength(const std::string& wptName) const;
time_t getStartTime() const { return start_time; } time_t getStartTime() const { return start_time; }
time_t getArrivalTime() const { return arrivalTime; } time_t getArrivalTime() const { return arrivalTime; }
@ -173,7 +173,7 @@ public:
void shortenToFirst(unsigned int number, std::string name); void shortenToFirst(unsigned int number, std::string name);
void setGate(ParkingAssignment pka); void setGate(const ParkingAssignment& pka);
FGParking* getParkingGate(); FGParking* getParkingGate();
private: private:

View file

@ -179,7 +179,9 @@ FGTrafficRecord::FGTrafficRecord():
allowTransmission(true), allowTransmission(true),
allowPushback(true), allowPushback(true),
priority(0), priority(0),
latitude(0), longitude(0), heading(0), speed(0), altitude(0), radius(0) timer(0),
latitude(0), longitude(0), heading(0), speed(0), altitude(0), radius(0),
aircraft(NULL)
{ {
} }
@ -413,7 +415,7 @@ bool FGTrafficRecord::isOpposing(FGGroundNetwork * net,
return false; return false;
} }
bool FGTrafficRecord::isActive(int margin) bool FGTrafficRecord::isActive(int margin) const
{ {
time_t now = time(NULL) + fgGetLong("/sim/time/warp"); time_t now = time(NULL) + fgGetLong("/sim/time/warp");
time_t deptime = aircraft->getTrafficRef()->getDepartureTime(); time_t deptime = aircraft->getTrafficRef()->getDepartureTime();
@ -433,7 +435,7 @@ void FGTrafficRecord::setHeadingAdjustment(double heading)
instruction.setHeading(heading); instruction.setHeading(heading);
} }
bool FGTrafficRecord::pushBackAllowed() bool FGTrafficRecord::pushBackAllowed() const
{ {
return allowPushback; return allowPushback;
} }
@ -460,7 +462,7 @@ FGATCInstruction::FGATCInstruction()
} }
bool FGATCInstruction::hasInstruction() bool FGATCInstruction::hasInstruction() const
{ {
return (holdPattern || holdPosition || changeSpeed || changeHeading return (holdPattern || holdPosition || changeSpeed || changeHeading
|| changeAltitude || resolveCircularWait); || changeAltitude || resolveCircularWait);
@ -481,6 +483,8 @@ FGATCController::FGATCController()
available = true; available = true;
lastTransmission = 0; lastTransmission = 0;
initialized = false; initialized = false;
lastTransmissionDirection = ATC_AIR_TO_GROUND;
group = NULL;
} }
FGATCController::~FGATCController() FGATCController::~FGATCController()

View file

@ -67,34 +67,34 @@ private:
public: public:
FGATCInstruction(); FGATCInstruction();
bool hasInstruction (); bool hasInstruction () const;
bool getHoldPattern () { bool getHoldPattern () const {
return holdPattern; return holdPattern;
}; };
bool getHoldPosition () { bool getHoldPosition () const {
return holdPosition; return holdPosition;
}; };
bool getChangeSpeed () { bool getChangeSpeed () const {
return changeSpeed; return changeSpeed;
}; };
bool getChangeHeading () { bool getChangeHeading () const {
return changeHeading; return changeHeading;
}; };
bool getChangeAltitude() { bool getChangeAltitude() const {
return changeAltitude; return changeAltitude;
}; };
double getSpeed () { double getSpeed () const {
return speed; return speed;
}; };
double getHeading () { double getHeading () const {
return heading; return heading;
}; };
double getAlt () { double getAlt () const {
return alt; return alt;
}; };
bool getCheckForCircularWait() { bool getCheckForCircularWait() const {
return resolveCircularWait; return resolveCircularWait;
}; };
@ -192,34 +192,34 @@ public:
int crosses (FGGroundNetwork *, FGTrafficRecord &other); int crosses (FGGroundNetwork *, FGTrafficRecord &other);
bool isOpposing (FGGroundNetwork *, FGTrafficRecord &other, int node); bool isOpposing (FGGroundNetwork *, FGTrafficRecord &other, int node);
bool isActive(int margin); bool isActive(int margin) const;
bool onRoute(FGGroundNetwork *, FGTrafficRecord &other); bool onRoute(FGGroundNetwork *, FGTrafficRecord &other);
bool getSpeedAdjustment() { bool getSpeedAdjustment() const {
return instruction.getChangeSpeed(); return instruction.getChangeSpeed();
}; };
double getLatitude () { double getLatitude () const {
return latitude ; return latitude ;
}; };
double getLongitude() { double getLongitude() const {
return longitude; return longitude;
}; };
double getHeading () { double getHeading () const {
return heading ; return heading ;
}; };
double getSpeed () { double getSpeed () const {
return speed ; return speed ;
}; };
double getAltitude () { double getAltitude () const {
return altitude ; return altitude ;
}; };
double getRadius () { double getRadius () const {
return radius ; return radius ;
}; };
int getWaitsForId () { int getWaitsForId () const {
return waitsForId; return waitsForId;
}; };
@ -232,10 +232,10 @@ public:
instruction.setChangeHeading(false); instruction.setChangeHeading(false);
}; };
bool hasHeadingAdjustment() { bool hasHeadingAdjustment() const {
return instruction.getChangeHeading(); return instruction.getChangeHeading();
}; };
bool hasHoldPosition() { bool hasHoldPosition() const {
return instruction.getHoldPosition(); return instruction.getHoldPosition();
}; };
void setHoldPosition (bool inst) { void setHoldPosition (bool inst) {
@ -253,7 +253,7 @@ public:
instruction.setResolveCircularWait(false); instruction.setResolveCircularWait(false);
}; };
const std::string& getRunway() { const std::string& getRunway() const {
return runway; return runway;
}; };
//void setCallSign(string clsgn) { callsign = clsgn; }; //void setCallSign(string clsgn) { callsign = clsgn; };
@ -265,21 +265,21 @@ public:
allowTransmission=true; allowTransmission=true;
}; };
//string getCallSign() { return callsign; }; //string getCallSign() { return callsign; };
FGAIAircraft *getAircraft() { FGAIAircraft *getAircraft() const {
return aircraft; return aircraft;
}; };
int getTime() { int getTime() const {
return timer; return timer;
}; };
int getLeg() { int getLeg() const {
return leg; return leg;
}; };
void setTime(time_t time) { void setTime(time_t time) {
timer = time; timer = time;
}; };
bool pushBackAllowed(); bool pushBackAllowed() const;
bool allowTransmissions() { bool allowTransmissions() const {
return allowTransmission; return allowTransmission;
}; };
void allowPushBack() { allowPushback =true;}; void allowPushBack() { allowPushback =true;};
@ -293,17 +293,17 @@ public:
void nextFrequency() { void nextFrequency() {
frequencyId++; frequencyId++;
}; };
int getNextFrequency() { int getNextFrequency() const {
return frequencyId; return frequencyId;
}; };
intVec& getIntentions() { intVec& getIntentions() {
return intentions; return intentions;
}; };
int getCurrentPosition() { int getCurrentPosition() const {
return currentPos; return currentPos;
}; };
void setPriority(int p) { priority = p; }; void setPriority(int p) { priority = p; };
int getPriority() { return priority; }; int getPriority() const { return priority; };
}; };
typedef std::list<FGTrafficRecord> TrafficVector; typedef std::list<FGTrafficRecord> TrafficVector;

View file

@ -79,6 +79,8 @@ FGScheduledFlight::FGScheduledFlight()
repeatPeriod = 0; repeatPeriod = 0;
initialized = false; initialized = false;
available = true; available = true;
departurePort = NULL;
arrivalPort = NULL;
} }
FGScheduledFlight::FGScheduledFlight(const FGScheduledFlight &other) FGScheduledFlight::FGScheduledFlight(const FGScheduledFlight &other)