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;
trackCache.remainingLength = 0;
trackCache.startWptName = "-";
}
@ -631,7 +632,7 @@ void FGAIAircraft::scheduleForATCTowerDepartureControl(int state) {
// Process ATC instructions and report back
void FGAIAircraft::processATC(FGATCInstruction instruction) {
void FGAIAircraft::processATC(const FGATCInstruction& instruction) {
if (instruction.getCheckForCircularWait()) {
// This is not exactly an elegant solution,
// 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 announcePositionToController(); //TODO have to be public?
void processATC(FGATCInstruction instruction);
void processATC(const FGATCInstruction& instruction);
void setTaxiClearanceRequest(bool arg) { needsTaxiClearance = arg; };
bool getTaxiClearanceRequest() { return needsTaxiClearance; };
FGAISchedule * getTrafficRef() { return trafficRef; };

View file

@ -447,7 +447,7 @@ int FGAIFlightPlan::getRouteIndex(int i) {
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;
double trackDistance = 0;
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);
}
void FGAIFlightPlan::setGate(ParkingAssignment pka)
void FGAIFlightPlan::setGate(const ParkingAssignment& pka)
{
gate = pka;
}

View file

@ -130,7 +130,7 @@ public:
double getBearing(FGAIWaypoint* previous, 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 getArrivalTime() const { return arrivalTime; }
@ -173,7 +173,7 @@ public:
void shortenToFirst(unsigned int number, std::string name);
void setGate(ParkingAssignment pka);
void setGate(const ParkingAssignment& pka);
FGParking* getParkingGate();
private:

View file

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

View file

@ -67,34 +67,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;
};
@ -192,34 +192,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;
};
@ -232,10 +232,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) {
@ -253,7 +253,7 @@ public:
instruction.setResolveCircularWait(false);
};
const std::string& getRunway() {
const std::string& getRunway() const {
return runway;
};
//void setCallSign(string clsgn) { callsign = clsgn; };
@ -265,21 +265,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;};
@ -293,17 +293,17 @@ 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 std::list<FGTrafficRecord> TrafficVector;

View file

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