1 /* -*- Mode: C++ -*- *****************************************************
3 * Written by Durk Talsma. Started May 5, 2004
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 **************************************************************************/
22 /**************************************************************************
23 * ScheduledFlight is a class that is used by FlightGear's Traffic Manager
24 * A scheduled flight can be assigned to a schedule, which can be assigned
25 * to an aircraft. The traffic manager decides for each schedule which
26 * scheduled flight (if any) is currently active. I no scheduled flights
27 * are found active, it tries to position the aircraft associated with this
28 * schedule at departure airport of the next scheduled flight.
29 * The class ScheduledFlight is a software implimentation of this.
30 * In summary, this class stores arrival and departure information, as well
31 * as some administrative data, such as the callsign of this particular
32 * flight (used in future ATC scenarios), under which flight rules the
33 * flight is taking place, as well as a requested initial cruise altitude.
34 * Finally, the class contains a repeat period, wich indicates after how
35 * many seconds a flight should repeat in this schedule (which is usually
36 * after either a day or a week). If this value is zero, this flight won't
38 **************************************************************************/
40 #ifndef _FGSCHEDFLIGHT_HXX_
41 #define _FGSCHEDFLIGHT_HXX_
45 class FGScheduledFlight
50 FGAirport *departurePort;
51 FGAirport *arrivalPort;
54 std::string requiredAircraft;
67 FGScheduledFlight(const FGScheduledFlight &other);
68 // FGScheduledFlight(const std::string);
69 FGScheduledFlight(const std::string& cs,
70 const std::string& fr,
71 const std::string& depPrt,
72 const std::string& arrPrt,
74 const std::string& deptime,
75 const std::string& arrtime,
76 const std::string& rep,
77 const std::string& reqAC
82 bool initializeAirports();
84 void adjustTime(time_t now);
86 time_t getDepartureTime() { return departureTime; };
87 time_t getArrivalTime () { return arrivalTime; };
89 void setDepartureAirport(const std::string& port) { depId = port; };
90 void setArrivalAirport (const std::string& port) { arrId = port; };
91 FGAirport *getDepartureAirport();
92 FGAirport *getArrivalAirport ();
94 int getCruiseAlt() { return cruiseAltitude; };
96 bool operator<(const FGScheduledFlight &other) const
98 return (departureTime < other.departureTime);
100 const std::string& getFlightRules() { return fltRules; };
102 time_t processTimeString(const std::string& time);
103 const std::string& getCallSign() {return callsign; };
104 const std::string& getRequirement() { return requiredAircraft; }
106 void lock() { available = false; };
107 void release() { available = true; };
109 bool isAvailable() { return available; };
111 void setCallSign(const std::string& val) { callsign = val; };
112 void setFlightRules(const std::string& val) { fltRules = val; };
115 typedef std::vector<FGScheduledFlight*> FGScheduledFlightVec;
116 typedef std::vector<FGScheduledFlight*>::iterator FGScheduledFlightVecIterator;
118 typedef std::map < std::string, FGScheduledFlightVec > FGScheduledFlightMap;
120 bool compareScheduledFlights(FGScheduledFlight *a, FGScheduledFlight *b);