]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/simple.hxx
Multiplayer client/server system -- MessageBuf class and test harness complete
[flightgear.git] / src / Airports / simple.hxx
index 6543ddce6170fd301e1557e971166eceb248eb62..3919b23c57b9e03de7f5cfbeff35eef227788558 100644 (file)
@@ -23,8 +23,8 @@
 // $Id$
 
 
-#ifndef _AIRPORTS_HXX
-#define _AIRPORTS_HXX
+#ifndef _FG_SIMPLE_HXX
+#define _FG_SIMPLE_HXX
 
 
 #ifndef __cplusplus                                                          
 #  include <config.h>
 #endif
 
-#ifdef HAVE_GDBM
-#  include <gdbm.h>
-#else
-#  include <simgear/gdbm/gdbm.h>
-#endif
-
 #include <simgear/compiler.h>
 
-#ifdef FG_HAVE_STD_INCLUDES
-#  include <istream>
-#elif defined( FG_HAVE_NATIVE_SGI_COMPILERS )
-#  include <iostream.h>
-#elif defined( __BORLANDC__ )
-#  include <iostream>
-#else
-#  include <istream.h>
-#endif
-
 #include STL_STRING
-#include <set>
-
-FG_USING_STD(string);
-FG_USING_STD(set);
-
-#if ! defined( FG_HAVE_NATIVE_SGI_COMPILERS )
-FG_USING_STD(istream);
-#endif
-
+#include <map>
 
-class FGAirport {
+SG_USING_STD(string);
+SG_USING_STD(map);
 
-public:
-
-    FGAirport( const string& name = "",
-              double lon = 0.0,
-              double lat = 0.0,
-              double ele = 0.0 )
-       : id(name), longitude(lon), latitude(lat), elevation(ele) {}
 
-    bool operator < ( const FGAirport& a ) const {
-       return id < a.id;
-    }
-
-public:
+struct FGAirport {
 
     string id;
     double longitude;
     double latitude;
     double elevation;
+    string code;
+    string name;
 
 };
 
-inline istream&
-operator >> ( istream& in, FGAirport& a )
-{
-    return in >> a.id >> a.longitude >> a.latitude >> a.elevation;
-}
+typedef map < string, FGAirport > airport_map;
+typedef airport_map::iterator airport_map_iterator;
+typedef airport_map::const_iterator const_airport_map_iterator;
 
 
-class FGAirports {
+class FGAirportList {
 
 private:
 
-    GDBM_FILE dbf;
+    airport_map airports;
 
 public:
 
     // Constructor
-    FGAirports( const string& file );
+    FGAirportList( const string& file );
 
     // Destructor
-    ~FGAirports();
-
-    // search for the specified id.
-    // Returns true if successful, otherwise returns false.
-    // On success, airport data is returned thru "airport" pointer.
-    // "airport" is not changed if "id" is not found.
-    bool search( const string& id, FGAirport* airport ) const;
-    FGAirport search( const string& id ) const;
-};
-
-
-class FGAirportsUtil {
-public:
-#ifdef FG_NO_DEFAULT_TEMPLATE_ARGS
-    typedef set< FGAirport, less< FGAirport > > container;
-#else
-    typedef set< FGAirport > container;
-#endif
-    typedef container::iterator iterator;
-    typedef container::const_iterator const_iterator;
-
-private:
-    container airports;
-
-public:
-
-    // Constructor
-    FGAirportsUtil();
-
-    // Destructor
-    ~FGAirportsUtil();
-
-    // load the data
-    int load( const string& file );
-
-    // save the data in gdbm format
-    bool dump_gdbm( const string& file );
+    ~FGAirportList();
 
     // search for the specified id.
     // Returns true if successful, otherwise returns false.
     // On success, airport data is returned thru "airport" pointer.
-    // "airport" is not changed if "id" is not found.
-    bool search( const string& id, FGAirport* airport ) const;
-    FGAirport search( const string& id ) const;
+    // "airport" is not changed if "apt" is not found.
+    FGAirport search( const string& id );
 };
 
 
-#endif /* _AIRPORTS_HXX */
+#endif // _FG_SIMPLE_HXX