]> git.mxchange.org Git - flightgear.git/blob - src/Airports/runwayprefs.hxx
Make FGTaxiNode and FGParking inherit FGPositioned.
[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 <time.h>
28 #include <vector>
29 #include <string>
30
31 #include <simgear/compiler.h>
32
33 using std::vector;
34 using std::string;
35
36 typedef vector<time_t> timeVec;
37 typedef vector<time_t>::const_iterator timeVecConstIterator;
38
39 typedef vector<string> stringVec;
40 typedef vector<string>::iterator stringVecIterator;
41 typedef vector<string>::const_iterator stringVecConstIterator;
42
43 class FGAirport;
44
45 /***************************************************************************/
46 class ScheduleTime {
47 private:
48   timeVec   start;
49   timeVec   end;
50   stringVec scheduleNames;
51   double tailWind;
52   double crssWind;
53 public:
54   ScheduleTime() : tailWind(0), crssWind(0) {};
55   ScheduleTime(const ScheduleTime &other);
56   ScheduleTime &operator= (const ScheduleTime &other);
57   string getName(time_t dayStart);
58
59   void clear();
60   void addStartTime(time_t time)     { start.push_back(time);            };
61   void addEndTime  (time_t time)     { end.  push_back(time);            };
62   void addScheduleName(const string& sched) { scheduleNames.push_back(sched);   };
63   void setTailWind(double wnd)  { tailWind = wnd;                        };
64   void setCrossWind(double wnd) { tailWind = wnd;                        };
65
66   double getTailWind()  { return tailWind;                               };
67   double getCrossWind() { return crssWind;                               };
68 };
69
70 //typedef vector<ScheduleTime> ScheduleTimes;
71 /*****************************************************************************/
72
73 class RunwayList
74 {
75 private:
76   string type;
77   stringVec preferredRunways;
78 public:
79   RunwayList() {};
80   RunwayList(const RunwayList &other);
81   RunwayList& operator= (const RunwayList &other);
82
83   void set(const string&, const string&);
84   void clear();
85
86   string getType() { return type; };
87   stringVec *getRwyList() { return &preferredRunways;    };
88   string getRwyList(int j) { return preferredRunways[j]; };
89 };
90
91 typedef vector<RunwayList> RunwayListVec;
92 typedef vector<RunwayList>::iterator RunwayListVectorIterator;
93 typedef vector<RunwayList>::const_iterator RunwayListVecConstIterator;
94
95
96 /*****************************************************************************/
97
98 class RunwayGroup
99 {
100 private:
101   string name;
102   RunwayListVec rwyList;
103   int active;
104   //stringVec runwayNames;
105   int choice[2];
106   int nrActive;
107
108 public:
109   RunwayGroup() {};
110   RunwayGroup(const RunwayGroup &other);
111   RunwayGroup &operator= (const RunwayGroup &other);
112
113   void setName(const string& nm) { name = nm;                };
114   void add(const RunwayList& list) { rwyList.push_back(list);};
115   void setActive(const FGAirport* airport, double windSpeed, double windHeading, double maxTail, double maxCross, stringVec *curr);
116
117   int getNrActiveRunways() { return nrActive;};
118   void getActive(int i, string& name, string& type);
119
120   string getName() { return name; };
121   void clear() { rwyList.clear(); }; 
122   //void add(string, string);
123 };
124
125 typedef vector<RunwayGroup> PreferenceList;
126 typedef vector<RunwayGroup>::iterator PreferenceListIterator;
127 typedef vector<RunwayGroup>::const_iterator PreferenceListConstIterator;
128
129 /******************************************************************************/
130
131 class FGRunwayPreference {
132 private:
133   FGAirport* _ap;
134
135   ScheduleTime comTimes; // Commercial Traffic;
136   ScheduleTime genTimes; // General Aviation;
137   ScheduleTime milTimes; // Military Traffic;
138   ScheduleTime ulTimes;  // Ultralight Traffic
139
140   PreferenceList preferences;
141   
142   bool initialized;
143
144 public:
145   FGRunwayPreference(FGAirport* ap);
146   FGRunwayPreference(const FGRunwayPreference &other);
147   
148   FGRunwayPreference & operator= (const FGRunwayPreference &other);
149
150   ScheduleTime *getSchedule(const char *trafficType);
151   RunwayGroup *getGroup(const string& groupName);
152
153   string getId();
154
155   bool available() { return initialized; };
156   void setInitialized(bool state) { initialized = state; };
157
158   void setMilTimes(ScheduleTime& t) { milTimes = t; };
159   void setGenTimes(ScheduleTime& t) { genTimes = t; };
160   void setComTimes(ScheduleTime& t) { comTimes = t; };
161   void setULTimes (ScheduleTime& t) { ulTimes  = t; };
162
163   void addRunwayGroup(RunwayGroup& g) { preferences.push_back(g); };
164 };
165
166 #endif