#include <string>
-#include <Debug/fg_debug.h>
+#include <Debug/logstream.hxx>
#include <Main/options.hxx>
#include <Misc/fgstream.hxx>
-#include <Misc/stopwatch.hxx>
#include "simple.hxx"
#include STL_FUNCTIONAL
#include STL_ALGORITHM
+
fgAIRPORTS::fgAIRPORTS() {
}
// load the data
int fgAIRPORTS::load( const string& file ) {
+ fgAIRPORT a;
+
// build the path name to the airport file
string path = current_options.get_fg_root() + "/Airports/" + file;
- StopWatch t;
airports.erase( airports.begin(), airports.end() );
fg_gzifstream in( path );
- if ( !in )
- fgPrintf( FG_GENERAL, FG_EXIT, "Cannot open file: %s\n",
- path.c_str());
-
- t.start();
+ if ( !in ) {
+ FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << path );
+ exit(-1);
+ }
+ /*
// We can use the STL copy algorithm because the input
// file doesn't contain and comments or blank lines.
copy( istream_iterator<fgAIRPORT,ptrdiff_t>(in.stream()),
istream_iterator<fgAIRPORT,ptrdiff_t>(),
inserter( airports, airports.begin() ) );
+ */
- t.stop();
-
- fgPrintf( FG_GENERAL, FG_INFO, "Loaded %d airports in %f seconds\n",
- airports.size(), t.elapsedSeconds() );
+ // read in each line of the file
+ in >> skipcomment;
+ while ( ! in.eof() )
+ {
+ in >> a;
+ airports.insert(a);
+ in >> skipcomment;
+ }
return 1;
}
-// class fgAIRPORT_eq : public unary_function<fgAIRPORT,bool>
-// {
-// public:
-// explicit fgAIRPORT_eq( const string& id ) : _id(id) {}
-// bool operator () ( const fgAIRPORT& a ) const { return a.id == _id; }
-// private:
-// string _id;
-// };
// search for the specified id
bool
fgAIRPORTS::search( const string& id, fgAIRPORT* a ) const
{
- StopWatch t;
- t.start();
-// const_iterator it = find_if( airports.begin(),
-// airports.end(), fgAIRPORT_eq(id) );
-
const_iterator it = airports.find( fgAIRPORT(id) );
- t.stop();
if ( it != airports.end() )
{
*a = *it;
- cout << "Found " << id << " in " << t.elapsedSeconds()
- << " seconds" << endl;
return true;
}
else
// $Log$
+// Revision 1.9 1998/11/06 21:17:34 curt
+// Converted to new logstream debugging facility. This allows release
+// builds with no messages at all (and no performance impact) by using
+// the -DFG_NDEBUG flag.
+//
+// Revision 1.8 1998/11/06 14:47:01 curt
+// Changes to track Bernie's updates to fgstream.
+//
+// Revision 1.7 1998/09/08 21:38:41 curt
+// Changes by Bernie Bright.
+//
+// Revision 1.6 1998/09/03 21:25:02 curt
+// tweaked in data file comment handling.
+//
+// Revision 1.5 1998/09/02 14:35:38 curt
+// Rewrote simple airport loader so it can deal with comments and blank lines.
+//
// Revision 1.4 1998/09/01 19:02:53 curt
// Changes contributed by Bernie Bright <bbright@c031.aone.net.au>
// - The new classes in libmisc.tgz define a stream interface into zlib.