]> git.mxchange.org Git - flightgear.git/blob - src/Airports/runwayprefs.hxx
Durk Talsma, Olaf Flebbe & Mathias Fröhlich:
[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., 675 Mass Ave, Cambridge, MA 02139, 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 public:
100   RunwayGroup() {};
101   RunwayGroup(const RunwayGroup &other);
102   RunwayGroup &operator= (const RunwayGroup &other);
103
104   void setName(const string& nm) { name = nm;                };
105   void add(const RunwayList& list) { rwyList.push_back(list);};
106   void setActive(const string& aptId, double windSpeed, double windHeading, double maxTail, double maxCross);
107
108   int getNrActiveRunways() { return nrActive;};
109   void getActive(int i, string& name, string& type);
110
111   string getName() { return name; };
112   void clear() { rwyList.clear(); }; 
113   //void add(string, string);
114 };
115
116 typedef vector<RunwayGroup> PreferenceList;
117 typedef vector<RunwayGroup>::iterator PreferenceListIterator;
118 typedef vector<RunwayGroup>::const_iterator PreferenceListConstIterator;
119
120 /******************************************************************************/
121
122 class FGRunwayPreference  : public XMLVisitor {
123 private:
124   string value;
125   string scheduleName;
126
127   ScheduleTime comTimes; // Commercial Traffic;
128   ScheduleTime genTimes; // General Aviation;
129   ScheduleTime milTimes; // Military Traffic;
130   ScheduleTime currTimes; // Needed for parsing;
131
132   RunwayList  rwyList;
133   RunwayGroup rwyGroup;
134   PreferenceList preferences;
135
136   time_t processTime(const string&);
137   bool initialized;
138
139 public:
140   FGRunwayPreference();
141   FGRunwayPreference(const FGRunwayPreference &other);
142   
143   FGRunwayPreference & operator= (const FGRunwayPreference &other);
144   ScheduleTime *getSchedule(const char *trafficType);
145   RunwayGroup *getGroup(const string& groupName);
146   bool available() { return initialized; };
147
148  // Some overloaded virtual XMLVisitor members
149   virtual void startXML (); 
150   virtual void endXML   ();
151   virtual void startElement (const char * name, const XMLAttributes &atts);
152   virtual void endElement (const char * name);
153   virtual void data (const char * s, int len);
154   virtual void pi (const char * target, const char * data);
155   virtual void warning (const char * message, int line, int column);
156   virtual void error (const char * message, int line, int column);
157 };
158
159 #endif