]> git.mxchange.org Git - flightgear.git/blob - src/Airports/runways.hxx
MSVC++ changes contributed by Geoff McLane.
[flightgear.git] / src / Airports / runways.hxx
1 // runways.hxx -- a simple class to manage airport runway info
2 //
3 // Written by Curtis Olson, started August 2000.
4 //
5 // Copyright (C) 2000  Curtis L. Olson  - curt@flightgear.org
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _RUNWAYS_HXX
25 #define _RUNWAYS_HXX
26
27
28 #ifndef __cplusplus                                                          
29 # error This library requires C++
30 #endif                                   
31
32
33 #ifdef HAVE_CONFIG_H
34 #  include <config.h>
35 #endif
36
37 #include <simgear/compiler.h>
38
39 #ifdef SG_HAVE_STD_INCLUDES
40 #  include <istream>
41 #elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
42 #  include <iostream.h>
43 #elif defined( __BORLANDC__ )
44 #  include <iostream>
45 #else
46 #  include <istream.h>
47 #endif
48
49 #include STL_STRING
50 #include <vector>
51
52 #ifndef _MSC_VER
53 #define NDEBUG                  // she don't work without it.
54 #endif // !_MSC_VER
55
56 #include <mk4.h>
57 #include <mk4str.h>
58
59 #ifndef _MSC_VER
60 #undef NDEBUG
61 #endif // !_MSC_VER
62
63 SG_USING_STD(string);
64 SG_USING_STD(vector);
65
66 #if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
67 SG_USING_STD(istream);
68 #endif
69
70
71 class FGRunway {
72
73 public:
74
75     string id;
76     string rwy_no;
77
78     double lon;
79     double lat;
80     double heading;
81     double length;
82     double width;
83     
84     string surface_flags;
85     string end1_flags;
86     string end2_flags;
87
88 public:
89
90     FGRunway();
91     ~FGRunway();
92
93 };
94
95 inline istream&
96 operator >> ( istream& in, FGRunway& a )
97 {
98     int tmp;
99
100     return in >> a.rwy_no >> a.lat >> a.lon >> a.heading >> a.length >> a.width
101               >> a.surface_flags >> a.end1_flags >> tmp >> tmp >> a.end2_flags
102               >> tmp >> tmp;
103 }
104
105
106 class FGRunways {
107
108 private:
109
110     c4_Storage *storage;
111     c4_View *vRunway;
112     int next_index;
113
114 public:
115
116     // Constructor
117     FGRunways( const string& file );
118
119     // Destructor
120     ~FGRunways();
121
122     // search for the specified apt id.
123     // Returns true if successful, otherwise returns false.
124     // On success, runway data is returned thru "runway" pointer.
125     // "runway" is not changed if "apt" is not found.
126     bool search( const string& aptid, FGRunway* runway );
127     bool search( const string& aptid, const string& rwyno, FGRunway* runway );
128     FGRunway search( const string& aptid );
129     bool next( FGRunway* runway );
130     FGRunway next();
131 };
132
133
134 class FGRunwaysUtil {
135 public:
136     typedef vector< FGRunway > container;
137     typedef container::iterator iterator;
138     typedef container::const_iterator const_iterator;
139
140 private:
141     container runways;
142
143 public:
144
145     // Constructor
146     FGRunwaysUtil();
147
148     // Destructor
149     ~FGRunwaysUtil();
150
151     // load the data
152     int load( const string& file );
153
154     // save the data in metakit format
155     bool dump_mk4( const string& file );
156
157     // search for the specified id.
158     // Returns true if successful, otherwise returns false.
159     // On success, runway data is returned thru "runway" pointer.
160     // "runway" is not changed if "id" is not found.
161     // bool search( const string& id, FGRunway* runway ) const;
162     // FGRunway search( const string& id ) const;
163 };
164
165
166 #endif // _RUNWAYS_HXX