1 // runwayprefs.hxx - A number of classes to configure runway
2 // assignments by the AI code
4 // Written by Durk Talsma, started January 2005.
6 // Copyright (C) 2004 Durk Talsma.
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.
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.
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.
24 #ifndef _RUNWAYPREFS_HXX_
25 #define _RUNWAYPREFS_HXX_
27 #include <simgear/xml/easyxml.hxx>
29 typedef vector<time_t> timeVec;
30 typedef vector<time_t>::const_iterator timeVecConstIterator;
32 typedef vector<string> stringVec;
33 typedef vector<string>::iterator stringVecIterator;
34 typedef vector<string>::const_iterator stringVecConstIterator;
37 /***************************************************************************/
42 stringVec scheduleNames;
46 ScheduleTime() : tailWind(0), crssWind(0) {};
47 ScheduleTime(const ScheduleTime &other);
48 ScheduleTime &operator= (const ScheduleTime &other);
49 string getName(time_t dayStart);
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; };
58 double getTailWind() { return tailWind; };
59 double getCrossWind() { return crssWind; };
62 //typedef vector<ScheduleTime> ScheduleTimes;
63 /*****************************************************************************/
69 stringVec preferredRunways;
72 RunwayList(const RunwayList &other);
73 RunwayList& operator= (const RunwayList &other);
75 void set(const string&, const string&);
78 string getType() { return type; };
79 stringVec *getRwyList() { return &preferredRunways; };
80 string getRwyList(int j) { return preferredRunways[j]; };
83 typedef vector<RunwayList> RunwayListVec;
84 typedef vector<RunwayList>::iterator RunwayListVectorIterator;
85 typedef vector<RunwayList>::const_iterator RunwayListVecConstIterator;
88 /*****************************************************************************/
94 RunwayListVec rwyList;
96 //stringVec runwayNames;
102 RunwayGroup(const RunwayGroup &other);
103 RunwayGroup &operator= (const RunwayGroup &other);
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);
109 int getNrActiveRunways() { return nrActive;};
110 void getActive(int i, string& name, string& type);
112 string getName() { return name; };
113 void clear() { rwyList.clear(); };
114 //void add(string, string);
117 typedef vector<RunwayGroup> PreferenceList;
118 typedef vector<RunwayGroup>::iterator PreferenceListIterator;
119 typedef vector<RunwayGroup>::const_iterator PreferenceListConstIterator;
121 /******************************************************************************/
123 class FGRunwayPreference : public XMLVisitor {
128 ScheduleTime comTimes; // Commercial Traffic;
129 ScheduleTime genTimes; // General Aviation;
130 ScheduleTime milTimes; // Military Traffic;
131 ScheduleTime currTimes; // Needed for parsing;
134 RunwayGroup rwyGroup;
135 PreferenceList preferences;
138 time_t processTime(const string&);
142 FGRunwayPreference();
143 FGRunwayPreference(const FGRunwayPreference &other);
145 FGRunwayPreference & operator= (const FGRunwayPreference &other);
146 ScheduleTime *getSchedule(const char *trafficType);
147 RunwayGroup *getGroup(const string& groupName);
148 bool available() { return initialized; };
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);