]> git.mxchange.org Git - flightgear.git/blob - src/Airports/simple.hxx
Added first stab at a socket class.
[flightgear.git] / src / Airports / simple.hxx
1 //
2 // simple.hxx -- a really simplistic class to manage airport ID,
3 //                 lat, lon of the center of one of it's runways, and 
4 //                 elevation in feet.
5 //
6 // Written by Curtis Olson, started April 1998.
7 //
8 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
9 //
10 // This program is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU General Public License as
12 // published by the Free Software Foundation; either version 2 of the
13 // License, or (at your option) any later version.
14 //
15 // This program is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 // General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 //
24 // $Id$
25
26
27 #ifndef _AIRPORTS_HXX
28 #define _AIRPORTS_HXX
29
30
31 #ifndef __cplusplus                                                          
32 # error This library requires C++
33 #endif                                   
34
35
36 #include <Include/compiler.h>
37 #ifdef FG_HAVE_STD_INCLUDES
38 #  include <istream>
39 #elif defined( FG_HAVE_NATIVE_SGI_COMPILERS )
40 #  include <iostream.h>
41 #elif defined( __BORLANDC__ )
42 #  include <iostream>
43 #else
44 #  include <istream.h>
45 #endif
46
47 #include STL_STRING
48 #include <set>
49
50 FG_USING_STD(string);
51 FG_USING_STD(set);
52
53 #if ! defined( FG_HAVE_NATIVE_SGI_COMPILERS )
54 FG_USING_STD(istream);
55 #endif
56
57
58 class fgAIRPORT {
59 public:
60     fgAIRPORT( const string& name = "",
61                double lon = 0.0,
62                double lat = 0.0,
63                double ele = 0.0 )
64         : id(name), longitude(lon), latitude(lat), elevation(ele) {}
65
66     bool operator < ( const fgAIRPORT& a ) const {
67         return id < a.id;
68     }
69
70 public:
71     string id;
72     double longitude;
73     double latitude;
74     double elevation;
75 };
76
77 inline istream&
78 operator >> ( istream& in, fgAIRPORT& a )
79 {
80     return in >> a.id >> a.longitude >> a.latitude >> a.elevation;
81 }
82
83 class fgAIRPORTS {
84 public:
85 #ifdef FG_NO_DEFAULT_TEMPLATE_ARGS
86     typedef set< fgAIRPORT, less< fgAIRPORT > > container;
87 #else
88     typedef set< fgAIRPORT > container;
89 #endif
90     typedef container::iterator iterator;
91     typedef container::const_iterator const_iterator;
92
93 private:
94     container airports;
95
96 public:
97
98     // Constructor
99     fgAIRPORTS();
100
101     // Destructor
102     ~fgAIRPORTS();
103
104     // load the data
105     int load( const string& file );
106
107     // search for the specified id.
108     // Returns true if successful, otherwise returns false.
109     // On success, airport data is returned thru "airport" pointer.
110     // "airport" is not changed if "id" is not found.
111     bool search( const string& id, fgAIRPORT* airport ) const;
112     fgAIRPORT search( const string& id ) const;
113 };
114
115
116 #endif /* _AIRPORTS_HXX */
117
118