]> git.mxchange.org Git - flightgear.git/blob - src/Traffic/SchedFlight.hxx
Update VS2008 projects : use Boost 1.44.0 available in last 3rd Party archive
[flightgear.git] / src / Traffic / SchedFlight.hxx
1 /* -*- Mode: C++ -*- *****************************************************
2  * SchedFlight.hxx
3  * Written by Durk Talsma. Started May 5, 2004
4  *
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.
9  *
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.
14  *
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.
18  *
19  *
20  **************************************************************************/
21
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
37  * repeat. 
38  **************************************************************************/
39
40 #ifndef _FGSCHEDFLIGHT_HXX_
41 #define _FGSCHEDFLIGHT_HXX_
42
43
44 using namespace std;
45
46 using std::vector;
47
48
49 class FGScheduledFlight
50 {
51 private:
52   string callsign;
53   string fltRules;
54   FGAirport *departurePort;
55   FGAirport *arrivalPort;
56   string depId;
57   string arrId;
58   string requiredAircraft;
59   time_t departureTime;
60   time_t arrivalTime;
61   time_t repeatPeriod;
62   int cruiseAltitude;
63   
64   bool initialized;
65   bool available;
66
67  
68  
69 public:
70   FGScheduledFlight();
71   FGScheduledFlight(const FGScheduledFlight &other);
72   //  FGScheduledFlight(const string);
73   FGScheduledFlight(const string& cs,
74                      const string& fr,
75                      const string& depPrt,
76                      const string& arrPrt,
77                      int cruiseAlt,
78                      const string& deptime,
79                      const string& arrtime,
80                      const string& rep,
81                      const string& reqAC
82                      );
83   ~FGScheduledFlight();
84
85   void update();
86    bool initializeAirports();
87   
88   void adjustTime(time_t now);
89
90   time_t getDepartureTime() { return departureTime; };
91   time_t getArrivalTime  () { return arrivalTime;   };
92   
93   FGAirport *getDepartureAirport();
94   FGAirport *getArrivalAirport  ();
95
96   int getCruiseAlt() { return cruiseAltitude; };
97
98   bool operator<(const FGScheduledFlight &other) const  
99   { 
100     return (departureTime < other.departureTime); 
101   };
102   string& getFlightRules() { return fltRules; };
103
104   time_t processTimeString(const string& time);
105   const string& getCallSign() {return callsign; };
106   const string& getRequirement() { return requiredAircraft; }
107
108   void lock() { available = false; };
109   void release() { available = true; };
110
111   bool isAvailable() { return available; };
112 };
113
114 typedef vector<FGScheduledFlight*>           FGScheduledFlightVec;
115 typedef vector<FGScheduledFlight*>::iterator FGScheduledFlightVecIterator;
116
117 typedef std::map < std::string, FGScheduledFlightVec > FGScheduledFlightMap;
118
119 bool compareScheduledFlights(FGScheduledFlight *a, FGScheduledFlight *b);
120
121
122 #endif