]> git.mxchange.org Git - flightgear.git/blob - src/Airports/runwayprefs.hxx
Fix for refueling and radar calculations.
[flightgear.git] / src / Airports / runwayprefs.hxx
1 // runwayprefs.hxx - A number of classes to configure runway
2 // assignments by the AI code
3 //
4 // Written by Durk Talsma, started January 2005.
5 //
6 // Copyright (C) 2004 Durk Talsma.
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 //
22 // $Id$
23
24 #ifndef _RUNWAYPREFS_HXX_
25 #define _RUNWAYPREFS_HXX_
26
27 #include <simgear/xml/easyxml.hxx>
28
29 typedef vector<time_t> timeVec;
30 typedef vector<time_t>::const_iterator timeVecConstIterator;
31
32 typedef vector<string> stringVec;
33 typedef vector<string>::iterator stringVecIterator;
34 typedef vector<string>::const_iterator stringVecConstIterator;
35
36
37 /***************************************************************************/
38 class ScheduleTime {
39 private:
40   timeVec   start;
41   timeVec   end;
42   stringVec scheduleNames;
43   double tailWind;
44   double crssWind;
45 public:
46   ScheduleTime() : tailWind(0), crssWind(0) {};
47   ScheduleTime(const ScheduleTime &other);
48   ScheduleTime &operator= (const ScheduleTime &other);
49   string getName(time_t dayStart);
50
51   void clear();
52   void addStartTime(time_t time)     { start.push_back(time);            };
53   void addEndTime  (time_t time)     { end.  push_back(time);            };
54   void addScheduleName(const string& sched) { scheduleNames.push_back(sched);   };
55   void setTailWind(double wnd)  { tailWind = wnd;                        };
56   void setCrossWind(double wnd) { tailWind = wnd;                        };
57
58   double getTailWind()  { return tailWind;                               };
59   double getCrossWind() { return crssWind;                               };
60 };
61
62 //typedef vector<ScheduleTime> ScheduleTimes;
63 /*****************************************************************************/
64
65 class RunwayList
66 {
67 private:
68   string type;
69   stringVec preferredRunways;
70 public:
71   RunwayList() {};
72   RunwayList(const RunwayList &other);
73   RunwayList& operator= (const RunwayList &other);
74
75   void set(const string&, const string&);
76   void clear();
77
78   string getType() { return type; };
79   stringVec *getRwyList() { return &preferredRunways;    };
80   string getRwyList(int j) { return preferredRunways[j]; };
81 };
82
83 typedef vector<RunwayList> RunwayListVec;
84 typedef vector<RunwayList>::iterator RunwayListVectorIterator;
85 typedef vector<RunwayList>::const_iterator RunwayListVecConstIterator;
86
87
88 /*****************************************************************************/
89
90 class RunwayGroup
91 {
92 private:
93   string name;
94   RunwayListVec rwyList;
95   int active;
96   //stringVec runwayNames;
97   int choice[2];
98   int nrActive;
99
100 public:
101   RunwayGroup() {};
102   RunwayGroup(const RunwayGroup &other);
103   RunwayGroup &operator= (const RunwayGroup &other);
104
105   void setName(const string& nm) { name = nm;                };
106   void add(const RunwayList& list) { rwyList.push_back(list);};
107   void setActive(const string& aptId, double windSpeed, double windHeading, double maxTail, double maxCross, stringVec *curr);
108
109   int getNrActiveRunways() { return nrActive;};
110   void getActive(int i, string& name, string& type);
111
112   string getName() { return name; };
113   void clear() { rwyList.clear(); }; 
114   //void add(string, string);
115 };
116
117 typedef vector<RunwayGroup> PreferenceList;
118 typedef vector<RunwayGroup>::iterator PreferenceListIterator;
119 typedef vector<RunwayGroup>::const_iterator PreferenceListConstIterator;
120
121 /******************************************************************************/
122
123 class FGRunwayPreference  : public XMLVisitor {
124 private:
125   string value;
126   string scheduleName;
127
128   ScheduleTime comTimes; // Commercial Traffic;
129   ScheduleTime genTimes; // General Aviation;
130   ScheduleTime milTimes; // Military Traffic;
131   ScheduleTime currTimes; // Needed for parsing;
132
133   RunwayList  rwyList;
134   RunwayGroup rwyGroup;
135   PreferenceList preferences;
136   
137
138   time_t processTime(const string&);
139   bool initialized;
140
141 public:
142   FGRunwayPreference();
143   FGRunwayPreference(const FGRunwayPreference &other);
144   
145   FGRunwayPreference & operator= (const FGRunwayPreference &other);
146   ScheduleTime *getSchedule(const char *trafficType);
147   RunwayGroup *getGroup(const string& groupName);
148   bool available() { return initialized; };
149
150  // Some overloaded virtual XMLVisitor members
151   virtual void startXML (); 
152   virtual void endXML   ();
153   virtual void startElement (const char * name, const XMLAttributes &atts);
154   virtual void endElement (const char * name);
155   virtual void data (const char * s, int len);
156   virtual void pi (const char * target, const char * data);
157   virtual void warning (const char * message, int line, int column);
158   virtual void error (const char * message, int line, int column);
159 };
160
161 #endif