]> git.mxchange.org Git - flightgear.git/blob - src/Airports/runways.hxx
FG_ to SG_ namespace changes.
[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 #define NDEBUG                  // she don't work without it.
53 #include <mk4.h>
54 #include <mk4str.h>
55 #undef NDEBUG
56
57 SG_USING_STD(string);
58 SG_USING_STD(vector);
59
60 #if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
61 SG_USING_STD(istream);
62 #endif
63
64
65 class FGRunway {
66
67 public:
68
69     string id;
70     string rwy_no;
71
72     double lon;
73     double lat;
74     double heading;
75     double length;
76     double width;
77     
78     string surface_flags;
79     string end1_flags;
80     string end2_flags;
81
82 public:
83
84     FGRunway();
85     ~FGRunway();
86
87 };
88
89 inline istream&
90 operator >> ( istream& in, FGRunway& a )
91 {
92     int tmp;
93
94     return in >> a.rwy_no >> a.lat >> a.lon >> a.heading >> a.length >> a.width
95               >> a.surface_flags >> a.end1_flags >> tmp >> tmp >> a.end2_flags
96               >> tmp >> tmp;
97 }
98
99
100 class FGRunways {
101
102 private:
103
104     c4_Storage *storage;
105     c4_View *vRunway;
106     int next_index;
107
108 public:
109
110     // Constructor
111     FGRunways( const string& file );
112
113     // Destructor
114     ~FGRunways();
115
116     // search for the specified id.
117     // Returns true if successful, otherwise returns false.
118     // On success, runway data is returned thru "runway" pointer.
119     // "runway" is not changed if "apt" is not found.
120     bool search( const string& id, FGRunway* runway );
121     FGRunway search( const string& id );
122     bool next( FGRunway* runway );
123     FGRunway next();
124 };
125
126
127 class FGRunwaysUtil {
128 public:
129     typedef vector< FGRunway > container;
130     typedef container::iterator iterator;
131     typedef container::const_iterator const_iterator;
132
133 private:
134     container runways;
135
136 public:
137
138     // Constructor
139     FGRunwaysUtil();
140
141     // Destructor
142     ~FGRunwaysUtil();
143
144     // load the data
145     int load( const string& file );
146
147     // save the data in metakit format
148     bool dump_mk4( const string& file );
149
150     // search for the specified id.
151     // Returns true if successful, otherwise returns false.
152     // On success, runway data is returned thru "runway" pointer.
153     // "runway" is not changed if "id" is not found.
154     // bool search( const string& id, FGRunway* runway ) const;
155     // FGRunway search( const string& id ) const;
156 };
157
158
159 #endif // _RUNWAYS_HXX