1
0
Fork 0

- unify coding style (though not to the last detail)

- remove trailing spaces
- fix mixed indentation (tabs -> 8 spaces)
- throw out braindead FSF coding style that has somehow sneaked in
This commit is contained in:
mfranz 2006-07-10 11:36:38 +00:00
parent 2c20ef1c7f
commit 62bdd89fd7
2 changed files with 120 additions and 118 deletions

View file

@ -57,8 +57,6 @@ SG_USING_STD(random_shuffle);
/*************************************************************************** /***************************************************************************
* FGAirport * FGAirport
***************************************************************************/ ***************************************************************************/
@ -79,6 +77,7 @@ FGAirport::FGAirport(const string &id, double lon, double lat, double elev, cons
dynamics = 0; dynamics = 0;
} }
FGAirport::~FGAirport() FGAirport::~FGAirport()
{ {
delete dynamics; delete dynamics;
@ -87,11 +86,9 @@ FGAirport::~FGAirport()
FGAirportDynamics * FGAirport::getDynamics() FGAirportDynamics * FGAirport::getDynamics()
{ {
if (dynamics != 0) {
if (dynamics != 0)
return dynamics; return dynamics;
else } else {
{
FGRunwayPreference rwyPrefs; FGRunwayPreference rwyPrefs;
//cerr << "Trying to load dynamics for " << _id << endl; //cerr << "Trying to load dynamics for " << _id << endl;
dynamics = new FGAirportDynamics(_latitude, _longitude, _elevation, _id); dynamics = new FGAirportDynamics(_latitude, _longitude, _elevation, _id);
@ -105,27 +102,25 @@ FGAirportDynamics * FGAirport::getDynamics()
rwyPrefPath.append( "/Airports/AI/" ); rwyPrefPath.append( "/Airports/AI/" );
rwyPrefPath.append(_id); rwyPrefPath.append(_id);
rwyPrefPath.append("rwyuse.xml"); rwyPrefPath.append("rwyuse.xml");
//if (ai_dirs.find(id.c_str()) != ai_dirs.end() //if (ai_dirs.find(id.c_str()) != ai_dirs.end()
// && parkpath.exists()) // && parkpath.exists())
if (parkpath.exists()) if (parkpath.exists()) {
{
try { try {
readXML(parkpath.str(),*dynamics); readXML(parkpath.str(),*dynamics);
dynamics->init(); dynamics->init();
} } catch (const sg_exception &e) {
catch (const sg_exception &e) {
//cerr << "unable to read " << parkpath.str() << endl; //cerr << "unable to read " << parkpath.str() << endl;
} }
} }
//if (ai_dirs.find(id.c_str()) != ai_dirs.end() //if (ai_dirs.find(id.c_str()) != ai_dirs.end()
// && rwyPrefPath.exists()) // && rwyPrefPath.exists())
if (rwyPrefPath.exists()) if (rwyPrefPath.exists()) {
{
try { try {
readXML(rwyPrefPath.str(), rwyPrefs); readXML(rwyPrefPath.str(), rwyPrefs);
dynamics->setRwyUse(rwyPrefs); dynamics->setRwyUse(rwyPrefs);
} } catch (const sg_exception &e) {
catch (const sg_exception &e) {
//cerr << "unable to read " << rwyPrefPath.str() << endl; //cerr << "unable to read " << rwyPrefPath.str() << endl;
//exit(1); //exit(1);
} }
@ -168,7 +163,8 @@ FGAirportList::FGAirportList()
} }
FGAirportList::~FGAirportList( void ) { FGAirportList::~FGAirportList( void )
{
for (unsigned int i = 0; i < airports_array.size(); ++i) { for (unsigned int i = 0; i < airports_array.size(); ++i) {
delete airports_array[i]; delete airports_array[i];
} }
@ -183,7 +179,6 @@ void FGAirportList::add( const string &id, const double longitude,
FGRunwayPreference rwyPrefs; FGRunwayPreference rwyPrefs;
FGAirport* a = new FGAirport(id, longitude, latitude, elevation, name, has_metar); FGAirport* a = new FGAirport(id, longitude, latitude, elevation, name, has_metar);
airports_by_id[a->getId()] = a; airports_by_id[a->getId()] = a;
// try and read in an auxilary file // try and read in an auxilary file
@ -194,14 +189,16 @@ void FGAirportList::add( const string &id, const double longitude,
// search for the specified id // search for the specified id
FGAirport* FGAirportList::search( const string& id) { FGAirport* FGAirportList::search( const string& id)
{
airport_map_iterator itr = airports_by_id.find(id); airport_map_iterator itr = airports_by_id.find(id);
return (itr == airports_by_id.end() ? NULL : itr->second); return (itr == airports_by_id.end() ? NULL : itr->second);
} }
// search for first subsequent alphabetically to supplied id // search for first subsequent alphabetically to supplied id
const FGAirport* FGAirportList::findFirstById( const string& id, bool exact ) { const FGAirport* FGAirportList::findFirstById( const string& id, bool exact )
{
airport_map_iterator itr; airport_map_iterator itr;
if (exact) { if (exact) {
itr = airports_by_id.find(id); itr = airports_by_id.find(id);
@ -218,7 +215,8 @@ const FGAirport* FGAirportList::findFirstById( const string& id, bool exact ) {
// search for the airport nearest the specified position // search for the airport nearest the specified position
FGAirport* FGAirportList::search( double lon_deg, double lat_deg, FGAirport* FGAirportList::search( double lon_deg, double lat_deg,
bool with_metar ) { bool with_metar )
{
int closest = -1; int closest = -1;
double min_dist = 360.0; double min_dist = 360.0;
unsigned int i; unsigned int i;
@ -244,6 +242,7 @@ FGAirportList::size () const
return airports_array.size(); return airports_array.size();
} }
const FGAirport *FGAirportList::getAirport( unsigned int index ) const const FGAirport *FGAirportList::getAirport( unsigned int index ) const
{ {
if (index < airports_array.size()) { if (index < airports_array.size()) {
@ -257,7 +256,8 @@ const FGAirport *FGAirportList::getAirport( unsigned int index ) const
/** /**
* Mark the specified airport record as not having metar * Mark the specified airport record as not having metar
*/ */
void FGAirportList::no_metar( const string &id ) { void FGAirportList::no_metar( const string &id )
{
if(airports_by_id.find(id) != airports_by_id.end()) { if(airports_by_id.find(id) != airports_by_id.end()) {
airports_by_id[id]->setMetar(false); airports_by_id[id]->setMetar(false);
} }
@ -267,14 +267,17 @@ void FGAirportList::no_metar( const string &id ) {
/** /**
* Mark the specified airport record as (yes) having metar * Mark the specified airport record as (yes) having metar
*/ */
void FGAirportList::has_metar( const string &id ) { void FGAirportList::has_metar( const string &id )
{
if(airports_by_id.find(id) != airports_by_id.end()) { if(airports_by_id.find(id) != airports_by_id.end()) {
airports_by_id[id]->setMetar(true); airports_by_id[id]->setMetar(true);
} }
} }
// find basic airport location info from airport database // find basic airport location info from airport database
const FGAirport *fgFindAirportID( const string& id) { const FGAirport *fgFindAirportID( const string& id)
{
const FGAirport* result = NULL; const FGAirport* result = NULL;
if ( id.length() ) { if ( id.length() ) {
SG_LOG( SG_GENERAL, SG_BULK, "Searching for airport code = " << id ); SG_LOG( SG_GENERAL, SG_BULK, "Searching for airport code = " << id );
@ -299,10 +302,8 @@ const FGAirport *fgFindAirportID( const string& id) {
// get airport elevation // get airport elevation
double fgGetAirportElev( const string& id ) { double fgGetAirportElev( const string& id )
{
// double lon, lat;
SG_LOG( SG_GENERAL, SG_BULK, SG_LOG( SG_GENERAL, SG_BULK,
"Finding elevation for airport: " << id ); "Finding elevation for airport: " << id );
@ -314,10 +315,10 @@ double fgGetAirportElev( const string& id ) {
} }
} }
// get airport position
Point3D fgGetAirportPos( const string& id ) {
// double lon, lat;
// get airport position
Point3D fgGetAirportPos( const string& id )
{
SG_LOG( SG_ATC, SG_BULK, SG_LOG( SG_ATC, SG_BULK,
"Finding position for airport: " << id ); "Finding position for airport: " << id );

View file

@ -39,7 +39,6 @@
#include <simgear/math/point3d.hxx> #include <simgear/math/point3d.hxx>
#include <simgear/compiler.h> #include <simgear/compiler.h>
//#include <simgear/xml/easyxml.hxx>
#include STL_STRING #include STL_STRING
#include <map> #include <map>
@ -78,24 +77,27 @@ public:
FGAirport(const string& id, double lon, double lat, double elev, const string& name, bool has_metar); FGAirport(const string& id, double lon, double lat, double elev, const string& name, bool has_metar);
~FGAirport(); ~FGAirport();
string getId() const { return _id;}; string getId() const { return _id; }
const string &getName() const { return _name;}; const string &getName() const { return _name; }
double getLongitude() const { return _longitude;}; double getLongitude() const { return _longitude; }
// Returns degrees // Returns degrees
double getLatitude() const { return _latitude; }; double getLatitude() const { return _latitude; }
// Returns ft // Returns ft
double getElevation() const { return _elevation;}; double getElevation() const { return _elevation; }
bool getMetar() const { return _has_metar;}; bool getMetar() const { return _has_metar; }
void setId(const string& id) { _id = id;}; void setId(const string& id) { _id = id; }
void setMetar(bool value) { _has_metar = value; }; void setMetar(bool value) { _has_metar = value; }
FGAirportDynamics *getDynamics(); FGAirportDynamics *getDynamics();
private: private:
FGAirport operator=(FGAirport &other); FGAirport operator=(FGAirport &other);
FGAirport(const FGAirport&); FGAirport(const FGAirport&);
}; };
typedef map < string, FGAirport* > airport_map; typedef map < string, FGAirport* > airport_map;
typedef airport_map::iterator airport_map_iterator; typedef airport_map::iterator airport_map_iterator;
typedef airport_map::const_iterator const_airport_map_iterator; typedef airport_map::const_iterator const_airport_map_iterator;
@ -105,8 +107,8 @@ typedef airport_list::iterator airport_list_iterator;
typedef airport_list::const_iterator const_airport_list_iterator; typedef airport_list::const_iterator const_airport_list_iterator;
class FGAirportList {
class FGAirportList {
private: private:
airport_map airports_by_id; airport_map airports_by_id;
@ -114,7 +116,6 @@ private:
//set < string > ai_dirs; //set < string > ai_dirs;
public: public:
// Constructor (new) // Constructor (new)
FGAirportList(); FGAirportList();