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