]> git.mxchange.org Git - flightgear.git/commitdiff
Clean up/prepare for porting NasalPositioned to cppbind
authorThomas Geymayer <tomgey@gmail.com>
Mon, 4 Mar 2013 15:31:37 +0000 (16:31 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Mon, 4 Mar 2013 15:31:37 +0000 (16:31 +0100)
28 files changed:
src/AIModel/AIEscort.cxx
src/ATC/CommStation.hxx
src/ATC/atc_mgr.hxx
src/ATC/trafficcontrol.hxx
src/ATCDCL/atis.cxx
src/Airports/CMakeLists.txt
src/Airports/airport.cxx
src/Airports/airport.hxx
src/Airports/airports_fwd.hxx [new file with mode: 0644]
src/Airports/dynamics.hxx
src/Airports/gnnode.hxx
src/Airports/groundnetwork.cxx
src/Airports/groundnetwork.hxx
src/Airports/parking.hxx
src/Airports/runwayprefs.cxx
src/Airports/runwayprefs.hxx
src/Airports/runways.cxx
src/Airports/runways.hxx
src/Airports/sidstar.cxx
src/Airports/sidstar.hxx
src/Airports/xmlloader.hxx
src/Navaids/positioned.cxx
src/Navaids/positioned.hxx
src/Navaids/procedure.cxx
src/Navaids/procedure.hxx
src/Scripting/NasalCanvas.cxx
src/Scripting/NasalPositioned.cxx
src/Traffic/Schedule.hxx

index 8012ae9230ea2df4b5659bdfd0017ab1a62107fa..9a816675597d88283aad6a25b43bb5b28472840c 100644 (file)
@@ -196,7 +196,7 @@ bool FGAIEscort::getGroundElev(SGGeod inpos) {
         _ht_agl_ft = inpos.getElevationFt() - height_m * SG_METER_TO_FEET;
 
         if (material) {
-            const vector<string>& names = material->get_names();
+            const std::vector<std::string>& names = material->get_names();
 
             _solid = material->get_solid();
 
index 04a7fe34482692b68280af76050ad28628e44666..33019f9805400fa13c1734ec8d7924fb21d9a56a 100644 (file)
@@ -29,8 +29,8 @@ private:
     int mRangeNM;
     int mFreqKhz;
     PositionedID mAirport;
-}; 
-    
+};
+
 } // of namespace flightgear
 
 #endif // of FG_ATC_COMM_STATION_HXX
index f169e34153e1f76de96dace60a27e72f68181c78..09d40197a36a7ec0294562d311a24367898bb6d3 100644 (file)
@@ -41,8 +41,8 @@
 //class FGATCController;
 
 
-typedef vector<FGATCController*> AtcVec;
-typedef vector<FGATCController*>::iterator AtcVecIterator;
+typedef std::vector<FGATCController*> AtcVec;
+typedef std::vector<FGATCController*>::iterator AtcVecIterator;
 
 class FGATCManager : public SGSubsystem
 {
index 3d58d58068fd0a9ed911c50fbe45376d30ab0d7e..1a137d4a59eaf19f2ab1087a63e33dd26ab3d068 100644 (file)
@@ -21,9 +21,7 @@
 #ifndef _TRAFFIC_CONTROL_HXX_
 #define _TRAFFIC_CONTROL_HXX_
 
-#include <string>
-#include <vector>
-#include <list>
+#include <Airports/airports_fwd.hxx>
 
 #include <osg/Geode>
 #include <osg/Geometry>
 #include <simgear/structure/SGReferenced.hxx>
 #include <simgear/structure/SGSharedPtr.hxx>
 
-typedef std::vector<int> intVec;
-typedef std::vector<int>::iterator intVecIterator;
+class FGAIAircraft;
+typedef std::vector<FGAIAircraft*> AircraftVec;
+typedef std::vector<FGAIAircraft*>::iterator AircraftVecIterator;
 
+class FGAIFlightPlan;
+typedef std::vector<FGAIFlightPlan*>           FlightPlanVec;
+typedef std::vector<FGAIFlightPlan*>::iterator FlightPlanVecIterator;
+typedef std::map<std::string, FlightPlanVec>   FlightPlanVecMap;
 
-class FGAIFlightPlan;  // forward reference
-class FGGroundNetwork; // forward reference
-class FGAIAircraft;    // forward reference
-class FGAirportDynamics;
+class FGTrafficRecord;
+typedef std::list<FGTrafficRecord> TrafficVector;
+typedef std::list<FGTrafficRecord>::iterator TrafficVectorIterator;
+
+class ActiveRunway;
+typedef std::vector<ActiveRunway> ActiveRunwayVec;
+typedef std::vector<ActiveRunway>::iterator ActiveRunwayVecIterator;
+
+typedef std::vector<int> intVec;
+typedef std::vector<int>::iterator intVecIterator;
 
 /**************************************************************************************
  * class FGATCInstruction
@@ -306,15 +315,6 @@ public:
     int getPriority() const { return priority; };
 };
 
-typedef std::list<FGTrafficRecord> TrafficVector;
-typedef std::list<FGTrafficRecord>::iterator TrafficVectorIterator;
-
-typedef std::vector<time_t> TimeVector;
-typedef std::vector<time_t>::iterator TimeVectorIterator;
-
-typedef std::vector<FGAIAircraft*> AircraftVec;
-typedef std::vector<FGAIAircraft*>::iterator AircraftVecIterator;
-
 /***********************************************************************
  * Active runway, a utility class to keep track of which aircraft has
  * clearance for a given runway.
@@ -368,9 +368,6 @@ public:
     void printDepartureCue();
 };
 
-typedef std::vector<ActiveRunway> ActiveRunwayVec;
-typedef std::vector<ActiveRunway>::iterator ActiveRunwayVecIterator;
-
 /**
  * class FGATCController
  * NOTE: this class serves as an abstraction layer for all sorts of ATC controllers.
index 3bc9e2f1f5fe2500ffd1a3bc5e7da7771ee857ae..c637640fd15337e0793fd859ff9655033f946924 100644 (file)
@@ -711,10 +711,10 @@ void FGATIS::genFacilityInfo(void)
 
     // Note that at this point, multi-word facility names
     // will sometimes contain hyphens, not spaces.
-    vector<string> name_words;
+    std::vector<std::string> name_words;
     boost::split(name_words, name, boost::is_any_of(" -"));
 
-    for (vector<string>::const_iterator wordp = name_words.begin();
+    for( std::vector<string>::const_iterator wordp = name_words.begin();
                   wordp != name_words.end(); wordp++) {
       string word(*wordp);
     // Remap some abbreviations that occur in apt.dat, to
index f0cde69e7aff73041a27024142bcd50c72430074..e83261507a65dce36719e1ed1de387e8e1f947e5 100644 (file)
@@ -18,6 +18,7 @@ set(SOURCES
        )
 
 set(HEADERS
+    airports_fwd.hxx
        apt_loader.hxx
        dynamicloader.hxx
        dynamics.hxx
index 2ba2fd8e95afe320fe11d2d23b36382121ba761e..508eb993442e8480edc75c5e979a581a89ac46fb 100644 (file)
@@ -58,15 +58,18 @@ using std::pair;
 
 using namespace flightgear;
 
-
 /***************************************************************************
  * FGAirport
  ***************************************************************************/
 
 AirportCache FGAirport::airportCache;
 
-FGAirport::FGAirport(PositionedID aGuid, const string &id, const SGGeod& location,
-        const string &name, bool has_metar, Type aType) :
+FGAirport::FGAirport( PositionedID aGuid,
+                      const std::string &id,
+                      const SGGeod& location,
+                      const std::string &name,
+                      bool has_metar,
+                      Type aType ):
     FGPositioned(aGuid, aType, id, location),
     _name(name),
     _has_metar(has_metar),
@@ -126,45 +129,83 @@ FGAirportDynamics * FGAirport::getDynamics()
     return _dynamics;
 }
 
+//------------------------------------------------------------------------------
 unsigned int FGAirport::numRunways() const
 {
   loadRunways();
   return mRunways.size();
 }
 
+//------------------------------------------------------------------------------
 unsigned int FGAirport::numHelipads() const
 {
   loadHelipads();
   return mHelipads.size();
 }
 
+//------------------------------------------------------------------------------
 FGRunway* FGAirport::getRunwayByIndex(unsigned int aIndex) const
 {
   loadRunways();
-  
-  assert(aIndex >= 0 && aIndex < mRunways.size());
-  return (FGRunway*) flightgear::NavDataCache::instance()->loadById(mRunways[aIndex]);
+  return loadById<FGRunway>(mRunways, aIndex);
 }
 
+//------------------------------------------------------------------------------
 FGHelipad* FGAirport::getHelipadByIndex(unsigned int aIndex) const
 {
   loadHelipads();
+  return loadById<FGHelipad>(mHelipads, aIndex);
+}
+
+//------------------------------------------------------------------------------
+FGRunwayMap FGAirport::getRunwayMap() const
+{
+  loadRunways();
+  FGRunwayMap map;
+
+  double minLengthFt = fgGetDouble("/sim/navdb/min-runway-length-ft");
+
+  BOOST_FOREACH(PositionedID id, mRunways)
+  {
+    FGRunway* rwy = loadById<FGRunway>(id);
+
+    // ignore unusably short runways
+    // TODO other methods don't check this...
+    if( rwy->lengthFt() >= minLengthFt )
+      map[ rwy->ident() ] = rwy;
+  }
+
+  return map;
+}
+
+//------------------------------------------------------------------------------
+FGHelipadMap FGAirport::getHelipadMap() const
+{
+  loadHelipads();
+  FGHelipadMap map;
 
-  assert(aIndex >= 0 && aIndex < mHelipads.size());
-  return (FGHelipad*) flightgear::NavDataCache::instance()->loadById(mHelipads[aIndex]);
+  BOOST_FOREACH(PositionedID id, mHelipads)
+  {
+    FGHelipad* rwy = loadById<FGHelipad>(id);
+    map[ rwy->ident() ] = rwy;
+  }
+
+  return map;
 }
 
-bool FGAirport::hasRunwayWithIdent(const string& aIdent) const
+//------------------------------------------------------------------------------
+bool FGAirport::hasRunwayWithIdent(const std::string& aIdent) const
 {
   return flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::RUNWAY, aIdent) != 0;
 }
 
-bool FGAirport::hasHelipadWithIdent(const string& aIdent) const
+bool FGAirport::hasHelipadWithIdent(const std::string& aIdent) const
 {
   return flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::HELIPAD, aIdent) != 0;
 }
 
-FGRunway* FGAirport::getRunwayByIdent(const string& aIdent) const
+//------------------------------------------------------------------------------
+FGRunway* FGAirport::getRunwayByIdent(const std::string& aIdent) const
 {
   PositionedID id = flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::RUNWAY, aIdent);  
   if (id == 0) {
@@ -172,10 +213,11 @@ FGRunway* FGAirport::getRunwayByIdent(const string& aIdent) const
     throw sg_range_exception("unknown runway " + aIdent + " at airport:" + ident(), "FGAirport::getRunwayByIdent");
   }
   
-  return (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
+  return loadById<FGRunway>(id);
 }
 
-FGHelipad* FGAirport::getHelipadByIdent(const string& aIdent) const
+//------------------------------------------------------------------------------
+FGHelipad* FGAirport::getHelipadByIdent(const std::string& aIdent) const
 {
   PositionedID id = flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::HELIPAD, aIdent);
   if (id == 0) {
@@ -183,10 +225,10 @@ FGHelipad* FGAirport::getHelipadByIdent(const string& aIdent) const
     throw sg_range_exception("unknown helipad " + aIdent + " at airport:" + ident(), "FGAirport::getRunwayByIdent");
   }
 
-  return (FGHelipad*) flightgear::NavDataCache::instance()->loadById(id);
+  return loadById<FGHelipad>(id);
 }
 
-
+//------------------------------------------------------------------------------
 FGRunway* FGAirport::findBestRunwayForHeading(double aHeading) const
 {
   loadRunways();
@@ -201,7 +243,7 @@ FGRunway* FGAirport::findBestRunwayForHeading(double aHeading) const
   double deviationWeight = param->getDoubleValue("deviation-weight", 1);
     
   BOOST_FOREACH(PositionedID id, mRunways) {
-    FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
+    FGRunway* rwy = loadById<FGRunway>(id);
     double good = rwy->score(lengthWeight, widthWeight, surfaceWeight);
     double dev = aHeading - rwy->headingDeg();
     SG_NORMALIZE_RANGE(dev, -180.0, 180.0);
@@ -217,6 +259,7 @@ FGRunway* FGAirport::findBestRunwayForHeading(double aHeading) const
   return result;
 }
 
+//------------------------------------------------------------------------------
 FGRunway* FGAirport::findBestRunwayForPos(const SGGeod& aPos) const
 {
   loadRunways();
@@ -225,7 +268,7 @@ FGRunway* FGAirport::findBestRunwayForPos(const SGGeod& aPos) const
   double currentLowestDev = 180.0;
   
   BOOST_FOREACH(PositionedID id, mRunways) {
-    FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
+    FGRunway* rwy = loadById<FGRunway>(id);
 
     double inboundCourse = SGGeodesy::courseDeg(aPos, rwy->end());
     double dev = inboundCourse - rwy->headingDeg();
@@ -242,12 +285,13 @@ FGRunway* FGAirport::findBestRunwayForPos(const SGGeod& aPos) const
 
 }
 
+//------------------------------------------------------------------------------
 bool FGAirport::hasHardRunwayOfLengthFt(double aLengthFt) const
 {
   loadRunways();
   
   BOOST_FOREACH(PositionedID id, mRunways) {
-    FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
+    FGRunway* rwy = loadById<FGRunway>(id);
     if (rwy->isHardSurface() && (rwy->lengthFt() >= aLengthFt)) {
       return true; // we're done!
     }
@@ -256,6 +300,7 @@ bool FGAirport::hasHardRunwayOfLengthFt(double aLengthFt) const
   return false;
 }
 
+//------------------------------------------------------------------------------
 FGRunwayList FGAirport::getRunwaysWithoutReciprocals() const
 {
   loadRunways();
@@ -263,7 +308,7 @@ FGRunwayList FGAirport::getRunwaysWithoutReciprocals() const
   FGRunwayList r;
   
   BOOST_FOREACH(PositionedID id, mRunways) {
-    FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
+    FGRunway* rwy = loadById<FGRunway>(id);
     FGRunway* recip = rwy->reciprocalRunway();
     if (recip) {
       FGRunwayList::iterator it = std::find(r.begin(), r.end(), recip);
@@ -278,33 +323,49 @@ FGRunwayList FGAirport::getRunwaysWithoutReciprocals() const
   return r;
 }
 
+//------------------------------------------------------------------------------
 unsigned int FGAirport::numTaxiways() const
 {
   loadTaxiways();
   return mTaxiways.size();
 }
 
+//------------------------------------------------------------------------------
 FGTaxiway* FGAirport::getTaxiwayByIndex(unsigned int aIndex) const
 {
   loadTaxiways();
-  
-  assert(aIndex >= 0 && aIndex < mTaxiways.size());
-  return (FGTaxiway*) flightgear::NavDataCache::instance()->loadById(mTaxiways[aIndex]);
+  return loadById<FGTaxiway>(mTaxiways, aIndex);
+}
+
+//------------------------------------------------------------------------------
+FGTaxiwayList FGAirport::getTaxiways() const
+{
+  loadTaxiways();
+  return loadAllById<FGTaxiway>(mTaxiways);
 }
 
+//------------------------------------------------------------------------------
 unsigned int FGAirport::numPavements() const
 {
   loadTaxiways();
   return mPavements.size();
 }
 
+//------------------------------------------------------------------------------
 FGPavement* FGAirport::getPavementByIndex(unsigned int aIndex) const
 {
   loadTaxiways();
-  assert(aIndex >= 0 && aIndex < mPavements.size());
-  return (FGPavement*) flightgear::NavDataCache::instance()->loadById(mPavements[aIndex]);
+  return loadById<FGPavement>(mPavements, aIndex);
 }
 
+//------------------------------------------------------------------------------
+FGPavementList FGAirport::getPavements() const
+{
+  loadTaxiways();
+  return loadAllById<FGPavement>(mPavements);
+}
+
+//------------------------------------------------------------------------------
 FGRunway* FGAirport::getActiveRunwayForUsage() const
 {
   FGEnvironmentMgr* envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment");
@@ -383,7 +444,7 @@ char** FGAirport::searchNamesAndIdents(const std::string& aFilter)
 }
 
 // find basic airport location info from airport database
-const FGAirport *fgFindAirportID( const string& id)
+const FGAirport *fgFindAirportID( const std::string& id)
 {
     if ( id.empty() ) {
         return NULL;
@@ -482,7 +543,7 @@ void FGAirport::readThresholdData(SGPropertyNode* aRoot)
 void FGAirport::processThreshold(SGPropertyNode* aThreshold)
 {
   // first, let's identify the current runway
-  string rwyIdent(aThreshold->getStringValue("rwy"));
+  std::string rwyIdent(aThreshold->getStringValue("rwy"));
   NavDataCache* cache = NavDataCache::instance(); 
   PositionedID id = cache->airportItemWithIdent(guid(), FGPositioned::RUNWAY, rwyIdent);
   if (id == 0) {
@@ -642,18 +703,21 @@ void FGAirport::addApproach(Approach* aApp)
   mApproaches.push_back(aApp);
 }
 
+//------------------------------------------------------------------------------
 unsigned int FGAirport::numSIDs() const
 {
   loadProcedures();
   return mSIDs.size();
 }
 
+//------------------------------------------------------------------------------
 flightgear::SID* FGAirport::getSIDByIndex(unsigned int aIndex) const
 {
   loadProcedures();
   return mSIDs[aIndex];
 }
 
+//------------------------------------------------------------------------------
 flightgear::SID* FGAirport::findSIDWithIdent(const std::string& aIdent) const
 {
   loadProcedures();
@@ -666,18 +730,28 @@ flightgear::SID* FGAirport::findSIDWithIdent(const std::string& aIdent) const
   return NULL;
 }
 
+//------------------------------------------------------------------------------
+flightgear::SIDList FGAirport::getSIDs() const
+{
+  loadProcedures();
+  return flightgear::SIDList(mSIDs.begin(), mSIDs.end());
+}
+
+//------------------------------------------------------------------------------
 unsigned int FGAirport::numSTARs() const
 {
   loadProcedures();
   return mSTARs.size();
 }
 
+//------------------------------------------------------------------------------
 STAR* FGAirport::getSTARByIndex(unsigned int aIndex) const
 {
   loadProcedures();
   return mSTARs[aIndex];
 }
 
+//------------------------------------------------------------------------------
 STAR* FGAirport::findSTARWithIdent(const std::string& aIdent) const
 {
   loadProcedures();
@@ -690,18 +764,27 @@ STAR* FGAirport::findSTARWithIdent(const std::string& aIdent) const
   return NULL;
 }
 
+//------------------------------------------------------------------------------
+STARList FGAirport::getSTARs() const
+{
+  loadProcedures();
+  return STARList(mSTARs.begin(), mSTARs.end());
+}
+
 unsigned int FGAirport::numApproaches() const
 {
   loadProcedures();
   return mApproaches.size();
 }
 
+//------------------------------------------------------------------------------
 Approach* FGAirport::getApproachByIndex(unsigned int aIndex) const
 {
   loadProcedures();
   return mApproaches[aIndex];
 }
 
+//------------------------------------------------------------------------------
 Approach* FGAirport::findApproachWithIdent(const std::string& aIdent) const
 {
   loadProcedures();
@@ -714,6 +797,22 @@ Approach* FGAirport::findApproachWithIdent(const std::string& aIdent) const
   return NULL;
 }
 
+//------------------------------------------------------------------------------
+ApproachList FGAirport::getApproaches(ProcedureType type) const
+{
+  loadProcedures();
+  if( type == PROCEDURE_INVALID )
+    return ApproachList(mApproaches.begin(), mApproaches.end());
+
+  ApproachList ret;
+  for(size_t i = 0; i < mApproaches.size(); ++i)
+  {
+    if( mApproaches[i]->type() == type )
+      ret.push_back(mApproaches[i]);
+  }
+  return ret;
+}
+
 CommStationList
 FGAirport::commStations() const
 {
@@ -742,7 +841,7 @@ FGAirport::commStationsOfType(FGPositioned::Type aTy) const
 }
 
 // get airport elevation
-double fgGetAirportElev( const string& id )
+double fgGetAirportElev( const std::string& id )
 {
     const FGAirport *a=fgFindAirportID( id);
     if (a) {
@@ -754,7 +853,7 @@ double fgGetAirportElev( const string& id )
 
 
 // get airport position
-SGGeod fgGetAirportPos( const string& id )
+SGGeod fgGetAirportPos( const std::string& id )
 {
     const FGAirport *a = fgFindAirportID( id);
 
index c715c72326ef36c06867243d077e37f275cda006..3ca4d62c7face5c45ee89a39e48c30586ec78112 100644 (file)
 #include <map>
 
 #include <Navaids/positioned.hxx>
-#include <Airports/runways.hxx>
-
-// forward decls
-class FGAirportDynamics;
-class FGRunway;
-class FGHelipad;
-class FGTaxiway;
-class FGPavement;
-class SGPropertyNode;
-class FGAirport;
-
-namespace flightgear {
-  class SID;
-  class STAR;
-  class Approach;
-  class Waypt;
-  class CommStation;
-
-  typedef SGSharedPtr<Waypt> WayptRef;
-  typedef std::vector<WayptRef> WayptVec;
-  
-  typedef std::vector<CommStation*> CommStationList;
-  typedef std::map<std::string, FGAirport*> AirportCache;
-}
-
-typedef std::vector<FGRunway*> FGRunwayList;
+#include <Navaids/procedure.hxx>
 
+#include "airports_fwd.hxx"
+#include "runways.hxx"
 
 /***************************************************************************************
  *
@@ -108,6 +85,8 @@ public:
     unsigned int numHelipads() const;
     FGRunway* getRunwayByIndex(unsigned int aIndex) const;
     FGHelipad* getHelipadByIndex(unsigned int aIndex) const;
+    FGRunwayMap getRunwayMap() const;
+    FGHelipadMap getHelipadMap() const;
 
     bool hasRunwayWithIdent(const std::string& aIdent) const;
     bool hasHelipadWithIdent(const std::string& aIdent) const;
@@ -145,9 +124,11 @@ public:
 
     unsigned int numTaxiways() const;
     FGTaxiway* getTaxiwayByIndex(unsigned int aIndex) const;
+    FGTaxiwayList getTaxiways() const;
 
     unsigned int numPavements() const;
     FGPavement* getPavementByIndex(unsigned int aIndex) const;
+    FGPavementList getPavements() const;
     
     class AirportFilter : public Filter
      {
@@ -203,14 +184,20 @@ public:
       unsigned int numSIDs() const;
       flightgear::SID* getSIDByIndex(unsigned int aIndex) const;
       flightgear::SID* findSIDWithIdent(const std::string& aIdent) const;
+      flightgear::SIDList getSIDs() const;
       
       unsigned int numSTARs() const;
       flightgear::STAR* getSTARByIndex(unsigned int aIndex) const;
       flightgear::STAR* findSTARWithIdent(const std::string& aIdent) const;
+      flightgear::STARList getSTARs() const;
       
       unsigned int numApproaches() const;
       flightgear::Approach* getApproachByIndex(unsigned int aIndex) const;
       flightgear::Approach* findApproachWithIdent(const std::string& aIdent) const;
+      flightgear::ApproachList getApproaches
+      (
+        flightgear::ProcedureType type = flightgear::PROCEDURE_INVALID
+      ) const;
   
      /**
       * Syntactic wrapper around FGPositioned::findClosest - find the closest
diff --git a/src/Airports/airports_fwd.hxx b/src/Airports/airports_fwd.hxx
new file mode 100644 (file)
index 0000000..ecb76a5
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * airports_fwd.hxx
+ *
+ *  Created on: 04.03.2013
+ *      Author: tom
+ */
+
+#ifndef AIRPORTS_FWD_HXX_
+#define AIRPORTS_FWD_HXX_
+
+#include <simgear/structure/SGSharedPtr.hxx>
+
+#include <list>
+#include <map>
+#include <vector>
+#include <string>
+
+// forward decls
+class FGAirport;
+class FGAirportDynamics;
+class FGRunway;
+class FGHelipad;
+class FGTaxiway;
+class FGPavement;
+
+class FGNavRecord;
+
+class Block;
+class FGTaxiNode;
+class FGParking;
+class FGTaxiSegment;
+class FGTaxiRoute;
+class FGGroundNetwork;
+
+class RunwayList;
+class RunwayGroup;
+class FGRunwayPreference;
+
+class FGSidStar;
+
+class SGPropertyNode;
+
+namespace flightgear {
+  class SID;
+  class STAR;
+  class Approach;
+  class Waypt;
+  class CommStation;
+
+  typedef std::vector<flightgear::SID*> SIDList;
+  typedef std::vector<STAR*> STARList;
+  typedef std::vector<Approach*> ApproachList;
+
+  typedef SGSharedPtr<Waypt> WayptRef;
+  typedef std::vector<WayptRef> WayptVec;
+
+  typedef SGSharedPtr<CommStation> CommStationRef;
+  typedef std::vector<CommStation*> CommStationList;
+  typedef std::map<std::string, FGAirport*> AirportCache;
+}
+
+typedef std::vector<FGRunway*> FGRunwayList;
+typedef std::map<std::string, FGRunway*> FGRunwayMap;
+typedef std::map<std::string, FGHelipad*> FGHelipadMap;
+
+typedef std::vector<FGTaxiway*> FGTaxiwayList;
+typedef std::vector<FGPavement*> FGPavementList;
+
+typedef std::vector<FGTaxiSegment*>  FGTaxiSegmentVector;
+typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
+
+typedef SGSharedPtr<FGTaxiNode> FGTaxiNodeRef;
+typedef std::vector<FGTaxiNodeRef> FGTaxiNodeVector;
+typedef FGTaxiNodeVector::iterator FGTaxiNodeVectorIterator;
+typedef std::map<int, FGTaxiNodeRef> IndexTaxiNodeMap;
+
+typedef std::vector<Block> BlockList;
+typedef BlockList::iterator BlockListIterator;
+
+typedef std::vector<time_t> TimeVector;
+typedef std::vector<time_t>::iterator TimeVectorIterator;
+
+typedef std::vector<FGTaxiRoute> TaxiRouteVector;
+typedef std::vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
+
+typedef std::vector<FGParking*> FGParkingVec;
+typedef FGParkingVec::iterator FGParkingVecIterator;
+typedef FGParkingVec::const_iterator FGParkingVecConstIterator;
+
+typedef std::vector<RunwayList> RunwayListVec;
+typedef std::vector<RunwayList>::iterator RunwayListVectorIterator;
+typedef std::vector<RunwayList>::const_iterator RunwayListVecConstIterator;
+
+typedef std::vector<RunwayGroup> PreferenceList;
+typedef std::vector<RunwayGroup>::iterator PreferenceListIterator;
+typedef std::vector<RunwayGroup>::const_iterator PreferenceListConstIterator;
+
+#endif /* AIRPORTS_FWD_HXX_ */
index 007c8a780d36f2933ac1974cb703dad11d101517..b2ee16fdd68825aab928b648ccb6e42d2127c779 100644 (file)
 #include <set>
 
 #include <ATC/trafficcontrol.hxx>
+#include "airports_fwd.hxx"
 #include "parking.hxx"
 #include "groundnetwork.hxx"
 #include "runwayprefs.hxx"
 
-// forward decls
-class FGAirport;
-class FGEnvironment;
-
 class ParkingAssignment
 {
 public:
@@ -125,7 +122,10 @@ public:
     FGAirport* parent() const
     { return _ap; }
   
-    void getActiveRunway(const string& trafficType, int action, string& runway, double heading);
+    void getActiveRunway( const std::string& trafficType,
+                          int action,
+                          std::string& runway,
+                          double heading );
     
     /**
      * retrieve an available parking by GateID, or -1 if no suitable
index 2ade6673d57bc43ff22a184b4131ed022b308098..2d4c16a9ebe882bf2455a6748d00ec896763b766 100644 (file)
@@ -41,8 +41,4 @@ public:
   bool getIsOnRunway() const { return isOnRunway; };
 };
 
-typedef SGSharedPtr<FGTaxiNode> FGTaxiNode_ptr;
-typedef std::vector<FGTaxiNode_ptr> FGTaxiNodeVector;
-typedef FGTaxiNodeVector::iterator FGTaxiNodeVectorIterator;
-
 #endif
index 3ea86f979243adc66ece7db3a01d714e71a4045f..344161172820a1780c9027cc136a515dccb413b2 100644 (file)
@@ -394,7 +394,7 @@ public:
   {}
   
   double score;
-  FGTaxiNode_ptr previousNode;
+  FGTaxiNodeRef previousNode;
 };
 
 FGTaxiRoute FGGroundNetwork::findShortestRoute(PositionedID start, PositionedID end,
index de8d94ed44a5008af63bf98f341b5a2a585d2abd..2c7884bf269aa922707c5a5102f47d87a7641272 100644 (file)
 #include <simgear/compiler.h>
 
 #include <string>
-#include <vector>
-#include <list>
-#include <map>
 
 #include "gnnode.hxx"
 #include "parking.hxx"
 #include <ATC/trafficcontrol.hxx>
 
-
-class Block;
-class FGRunway;
-class FGTaxiSegment; // forward reference
-class FGAIFlightPlan; // forward reference
-class FGAirport;      // forward reference
-
-typedef std::vector<FGTaxiSegment*>  FGTaxiSegmentVector;
-typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
-
-typedef std::map<int, FGTaxiNode_ptr> IndexTaxiNodeMap;
-
 class Block
 {
 private:
@@ -63,9 +48,6 @@ public:
     bool operator< (const Block &other) const { return blocktime < other.blocktime; };
 };
 
-typedef std::vector<Block> BlockList;
-typedef BlockList::iterator BlockListIterator;
-
 /***************************************************************************************
  * class FGTaxiSegment
  **************************************************************************************/
@@ -119,14 +101,6 @@ public:
     };
 };
 
-
-
-
-typedef std::vector<int> intVec;
-typedef std::vector<int>::iterator intVecIterator;
-
-
-
 /***************************************************************************************
  * class FGTaxiRoute
  **************************************************************************************/
@@ -181,9 +155,6 @@ public:
     };
 };
 
-typedef std::vector<FGTaxiRoute> TaxiRouteVector;
-typedef std::vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
-
 /**************************************************************************************
  * class FGGroundNetWork
  *************************************************************************************/
index ff466d256f56d1951f27e79b897b50a7ccff211d..6d8892c802d6307cce06f42996013d42f07fd6fe 100644 (file)
@@ -33,7 +33,6 @@
 #include <simgear/sg_inlines.h>
 
 #include <string>
-#include <vector>
 #include <memory> // for std::auto_ptr
 
 #include "gnnode.hxx"
@@ -79,8 +78,4 @@ public:
     return radius < other.radius; };
 };
 
-typedef std::vector<FGParking*> FGParkingVec;
-typedef FGParkingVec::iterator FGParkingVecIterator;
-typedef FGParkingVec::const_iterator FGParkingVecConstIterator;
-
 #endif
index 2a2fceb0f743251d07e162c952b6720caf8d679d..4ee6ac7b345a4e9a375e9235280c576acb18b0ad 100644 (file)
@@ -90,7 +90,7 @@ ScheduleTime & ScheduleTime::operator=(const ScheduleTime & other)
     return *this;
 }
 
-string ScheduleTime::getName(time_t dayStart)
+std::string ScheduleTime::getName(time_t dayStart)
 {
     if ((start.size() != end.size())
         || (start.size() != scheduleNames.size())) {
@@ -109,7 +109,7 @@ string ScheduleTime::getName(time_t dayStart)
         //couldn't find one so return 0;
         //cerr << "Returning 0 " << endl;
     }
-    return string("");
+    return std::string("");
 }
 
 /******************************************************************************
@@ -136,15 +136,15 @@ RunwayList & RunwayList::operator=(const RunwayList & other)
     return *this;
 }
 
-void RunwayList::set(const string & tp, const string & lst)
+void RunwayList::set(const std::string & tp, const std::string & lst)
 {
     //weekday          = atoi(timeCopy.substr(0,1).c_str());
     //    timeOffsetInDays = weekday - currTimeDate->getGmt()->tm_wday;
     //    timeCopy = timeCopy.substr(2,timeCopy.length());
     type = tp;
-    string rwys = lst;
-    string rwy;
-    while (rwys.find(",") != string::npos) {
+    std::string rwys = lst;
+    std::string rwy;
+    while (rwys.find(",") != std::string::npos) {
         rwy = rwys.substr(0, rwys.find(",", 0));
         //cerr << "adding runway [" << rwy << "] to the list " << endl;
         preferredRunways.push_back(rwy);
@@ -206,7 +206,7 @@ void RunwayGroup::setActive(const FGAirport * airport,
     double hdgDiff;
     double crossWind;
     double tailWind;
-    string name;
+    std::string name;
     //stringVec names;
     int bestMatch = 0, bestChoice = 0;
 
@@ -229,7 +229,7 @@ void RunwayGroup::setActive(const FGAirport * airport,
             validSelection = true;
             
             for (int j = 0; j < activeRwys; j++) {
-                string ident(rwyList[j].getRwyList(i));
+                std::string ident(rwyList[j].getRwyList(i));
                 if (!airport->hasRunwayWithIdent(ident)) {
                     SG_LOG(SG_GENERAL, SG_WARN,
                            "no such runway:" << ident << " at " <<
@@ -290,9 +290,9 @@ void RunwayGroup::setActive(const FGAirport * airport,
         choice[0] = 0;
         choice[1] = 0;
         for (int i = activeRwys - 1; i; i--) {
-            if (rwyList[i].getType() == string("landing"))
+            if (rwyList[i].getType() == std::string("landing"))
                 choice[0] = i;
-            if (rwyList[i].getType() == string("takeoff"))
+            if (rwyList[i].getType() == std::string("takeoff"))
                 choice[1] = i;
         }
         //cerr << "Choosing " << choice[0] << " for landing and " << choice[1] << "for takeoff" << endl;
@@ -327,7 +327,7 @@ void RunwayGroup::setActive(const FGAirport * airport,
     nrActive = 0;
 }
 
-void RunwayGroup::getActive(int i, string & name, string & type)
+void RunwayGroup::getActive(int i, std::string & name, std::string & type)
 {
     if (i == -1) {
         return;
@@ -394,7 +394,7 @@ ScheduleTime *FGRunwayPreference::getSchedule(const char *trafficType)
     return 0;
 }
 
-RunwayGroup *FGRunwayPreference::getGroup(const string & groupName)
+RunwayGroup *FGRunwayPreference::getGroup(const std::string & groupName)
 {
     PreferenceListIterator i = preferences.begin();
     if (preferences.begin() == preferences.end())
@@ -407,7 +407,7 @@ RunwayGroup *FGRunwayPreference::getGroup(const string & groupName)
         return 0;
 }
 
-string FGRunwayPreference::getId()
+std::string FGRunwayPreference::getId()
 {
     return _ap->getId();
 };
index c9ac72709c82e4e0c0e00c8ead197a5ac155bebf..7e2eced2f39ead331c71b76cc060f2ef73e298e1 100644 (file)
 #ifndef _RUNWAYPREFS_HXX_
 #define _RUNWAYPREFS_HXX_
 
-#include <time.h>
-#include <vector>
-#include <string>
+#include "airports_fwd.hxx"
 
 #include <simgear/compiler.h>
+#include <time.h>
 
-using std::vector;
-using std::string;
-
-typedef vector<time_t> timeVec;
-typedef vector<time_t>::const_iterator timeVecConstIterator;
+typedef std::vector<time_t> timeVec;
+typedef std::vector<time_t>::const_iterator timeVecConstIterator;
 
-typedef vector<string> stringVec;
-typedef vector<string>::iterator stringVecIterator;
-typedef vector<string>::const_iterator stringVecConstIterator;
+typedef std::vector<std::string> stringVec;
+typedef std::vector<std::string>::iterator stringVecIterator;
+typedef std::vector<std::string>::const_iterator stringVecConstIterator;
 
-class FGAirport;
 
 /***************************************************************************/
 class ScheduleTime {
@@ -54,12 +49,12 @@ public:
   ScheduleTime() : tailWind(0), crssWind(0) {};
   ScheduleTime(const ScheduleTime &other);
   ScheduleTime &operator= (const ScheduleTime &other);
-  string getName(time_t dayStart);
+  std::string getName(time_t dayStart);
 
   void clear();
   void addStartTime(time_t time)     { start.push_back(time);            };
   void addEndTime  (time_t time)     { end.  push_back(time);            };
-  void addScheduleName(const string& sched) { scheduleNames.push_back(sched);   };
+  void addScheduleName(const std::string& sched) { scheduleNames.push_back(sched);   };
   void setTailWind(double wnd)  { tailWind = wnd;                        };
   void setCrossWind(double wnd) { tailWind = wnd;                        };
 
@@ -73,32 +68,27 @@ public:
 class RunwayList
 {
 private:
-  string type;
+  std::string type;
   stringVec preferredRunways;
 public:
   RunwayList() {};
   RunwayList(const RunwayList &other);
   RunwayList& operator= (const RunwayList &other);
 
-  void set(const string&, const string&);
+  void set(const std::string&, const std::string&);
   void clear();
 
-  string getType() { return type; };
+  std::string getType() { return type; };
   stringVec *getRwyList() { return &preferredRunways;    };
-  string getRwyList(int j) { return preferredRunways[j]; };
+  std::string getRwyList(int j) { return preferredRunways[j]; };
 };
 
-typedef vector<RunwayList> RunwayListVec;
-typedef vector<RunwayList>::iterator RunwayListVectorIterator;
-typedef vector<RunwayList>::const_iterator RunwayListVecConstIterator;
-
-
 /*****************************************************************************/
 
 class RunwayGroup
 {
 private:
-  string name;
+  std::string name;
   RunwayListVec rwyList;
   int active;
   //stringVec runwayNames;
@@ -110,22 +100,18 @@ public:
   RunwayGroup(const RunwayGroup &other);
   RunwayGroup &operator= (const RunwayGroup &other);
 
-  void setName(const string& nm) { name = nm;                };
+  void setName(const std::string& nm) { name = nm;                };
   void add(const RunwayList& list) { rwyList.push_back(list);};
   void setActive(const FGAirport* airport, double windSpeed, double windHeading, double maxTail, double maxCross, stringVec *curr);
 
   int getNrActiveRunways() { return nrActive;};
-  void getActive(int i, string& name, string& type);
+  void getActive(int i, std::string& name, std::string& type);
 
-  string getName() { return name; };
+  std::string getName() { return name; };
   void clear() { rwyList.clear(); }; 
   //void add(string, string);
 };
 
-typedef vector<RunwayGroup> PreferenceList;
-typedef vector<RunwayGroup>::iterator PreferenceListIterator;
-typedef vector<RunwayGroup>::const_iterator PreferenceListConstIterator;
-
 /******************************************************************************/
 
 class FGRunwayPreference {
@@ -148,9 +134,9 @@ public:
   FGRunwayPreference & operator= (const FGRunwayPreference &other);
 
   ScheduleTime *getSchedule(const char *trafficType);
-  RunwayGroup *getGroup(const string& groupName);
+  RunwayGroup *getGroup(const std::string& groupName);
 
-  string getId();
+  std::string getId();
 
   bool available() { return initialized; };
   void setInitialized(bool state) { initialized = state; };
index 66f2407a2989d438321b4feea5022239e34108fe..e63fb9d73d273f72af8730b5d573841ca60d9584 100644 (file)
@@ -130,12 +130,12 @@ void FGRunway::setReciprocalRunway(PositionedID other)
 
 FGAirport* FGRunway::airport() const
 {
-  return (FGAirport*) flightgear::NavDataCache::instance()->loadById(_airport);
+  return loadById<FGAirport>(_airport);
 }
 
 FGRunway* FGRunway::reciprocalRunway() const
 {
-  return (FGRunway*) flightgear::NavDataCache::instance()->loadById(_reciprocal);
+  return loadById<FGRunway>(_reciprocal);
 }
 
 FGNavRecord* FGRunway::ILS() const
@@ -144,7 +144,7 @@ FGNavRecord* FGRunway::ILS() const
     return NULL;
   }
   
-  return (FGNavRecord*) flightgear::NavDataCache::instance()->loadById(_ils);
+  return loadById<FGNavRecord>(_ils);
 }
 
 FGNavRecord* FGRunway::glideslope() const
@@ -158,10 +158,10 @@ FGNavRecord* FGRunway::glideslope() const
   return (FGNavRecord*) cache->loadById(gsId);
 }
 
-std::vector<flightgear::SID*> FGRunway::getSIDs() const
+flightgear::SIDList FGRunway::getSIDs() const
 {
   FGAirport* apt = airport();
-  std::vector<flightgear::SID*> result;
+  flightgear::SIDList result;
   for (unsigned int i=0; i<apt->numSIDs(); ++i) {
     flightgear::SID* s = apt->getSIDByIndex(i);
     if (s->isForRunway(this)) {
@@ -172,10 +172,10 @@ std::vector<flightgear::SID*> FGRunway::getSIDs() const
   return result;
 }
 
-std::vector<flightgear::STAR*> FGRunway::getSTARs() const
+flightgear::STARList FGRunway::getSTARs() const
 {
   FGAirport* apt = airport();
-  std::vector<flightgear::STAR*> result;
+  flightgear::STARList result;
   for (unsigned int i=0; i<apt->numSTARs(); ++i) {
     flightgear::STAR* s = apt->getSTARByIndex(i);
     if (s->isForRunway(this)) {
@@ -186,13 +186,17 @@ std::vector<flightgear::STAR*> FGRunway::getSTARs() const
   return result;
 }
 
-std::vector<flightgear::Approach*> FGRunway::getApproaches() const
+flightgear::ApproachList
+FGRunway::getApproaches(flightgear::ProcedureType type) const
 {
   FGAirport* apt = airport();
-  std::vector<flightgear::Approach*> result;
-  for (unsigned int i=0; i<apt->numApproaches(); ++i) {
+  flightgear::ApproachList result;
+  for (unsigned int i=0; i<apt->numApproaches(); ++i)
+  {
     flightgear::Approach* s = apt->getApproachByIndex(i);
-    if (s->runway() == this) {
+    if(    s->runway() == this
+        && (type == flightgear::PROCEDURE_INVALID || type == s->type()) )
+    {
       result.push_back(s);
     }
   } // of approaches at the airport iteration
index 216875c410c8caa2793798d815df06b77f2d7ebf..03434ab8efff2a6c629f9b6c0d35e2872614e095 100644 (file)
 
 #include <simgear/compiler.h>
 
-#include <Airports/runwaybase.hxx>
-
-// forward decls
-class FGAirport;
-class FGNavRecord;
-class SGPropertyNode;
-
-namespace flightgear {
-  class SID;
-  class STAR;
-  class Approach;
-}
+#include <Navaids/procedure.hxx>
+#include "runwaybase.hxx"
+#include "airports_fwd.hxx"
 
 class FGRunway : public FGRunwayBase
 {
@@ -113,15 +104,18 @@ public:
   /**
    * Get SIDs (DPs) associated with this runway
    */
-  std::vector<flightgear::SID*> getSIDs() const;
+  flightgear::SIDList getSIDs() const;
   
   /**
    * Get STARs associared with this runway
    */ 
-  std::vector<flightgear::STAR*> getSTARs() const;
+  flightgear::STARList getSTARs() const;
   
   
-  std::vector<flightgear::Approach*> getApproaches() const;
+  flightgear::ApproachList getApproaches
+  (
+    flightgear::ProcedureType type = flightgear::PROCEDURE_INVALID
+  ) const;
   
 };
 
index 93360b432cbb87c8696e27ee62f67bca94e2da78..a951194822c193a62f13149a644b25a550688bfe 100644 (file)
 #include <simgear/props/props.hxx>
 #include <simgear/props/props_io.hxx>
 
-
-
+#include <AIModel/AIFlightPlan.hxx>
 #include <Airports/airport.hxx>
 
-
 #include "sidstar.hxx"
 
 using std::cerr;
@@ -119,4 +117,4 @@ FGAIFlightPlan *FGSidStar::getBest(string activeRunway, double heading)
      } else {
         return 0;
     }
-}
\ No newline at end of file
+}
index ad8d10e94e418c24001cf6fd9e2cb8d566965ad6..c7e8f93d3ac8a242b1450247696051bc3c6bdc9a 100644 (file)
 #ifndef _SIDSTAR_HXX_
 #define _SIDSTAR_HXX_
 
-#include <string>
-#include <map>
+#include "airports_fwd.hxx"
+#include <ATC/trafficcontrol.hxx>
 
 #include <simgear/misc/sg_path.hxx>
-
 #include <simgear/xml/easyxml.hxx>
 
-#include <ATC/trafficcontrol.hxx>
-#include <AIModel/AIFlightPlan.hxx>
-#include "parking.hxx"
-#include "groundnetwork.hxx"
-#include "runwayprefs.hxx"
-
-
-class FGAirport;
-
-typedef std::vector<FGAIFlightPlan*>           FlightPlanVec;
-typedef std::vector<FGAIFlightPlan*>::iterator FlightPlanVecIterator;
-
-typedef std::map < std::string, FlightPlanVec > FlightPlanVecMap;
-
-
-class FGSidStar 
+class FGSidStar
 {
    private:
       std::string id;
@@ -61,6 +45,4 @@ class FGSidStar
       FGAIFlightPlan *getBest(std::string activeRunway, double heading);
 };
 
-
-
-#endif
\ No newline at end of file
+#endif
index 47e34daaf7ca8850f16ea0a74ee61f0ea4a75590..e303fbeb246798f6a6aa57b97b9af6554757a79f 100644 (file)
@@ -16,9 +16,7 @@
 #ifndef _XML_LOADER_HXX_
 #define _XML_LOADER_HXX_
 
-class FGAirportDynamics;
-class FGRunwayPreference;
-class FGSidStar;
+#include "airports_fwd.hxx"
 
 class XMLVisitor; // ffrom easyxml.hxx
 
index 450c755d94195b229424445fff6c78f19c6eb91d..f6b706fd38e233f5d49cd0459d58281692307019 100644 (file)
@@ -326,6 +326,12 @@ void FGPositioned::modifyPosition(const SGGeod& newPos)
   const_cast<SGVec3d&>(mCart) = SGVec3d::fromGeod(newPos);
 }
 
+//------------------------------------------------------------------------------
+FGPositioned* FGPositioned::loadByIdImpl(PositionedID id)
+{
+  return flightgear::NavDataCache::instance()->loadById(id);
+}
+
 FGPositioned::TypeFilter::TypeFilter(Type aTy) :
   mMinType(aTy),
   mMaxType(aTy)
index 4943c964b776e1a45202d6816511fef6572fffc4..8341c22f1c7968a97a9c5dc483fabb858c9d3b06 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef FG_POSITIONED_HXX
 #define FG_POSITIONED_HXX
 
+#include <cassert>
 #include <string>
 #include <vector>
 #include <stdint.h>
@@ -128,6 +129,9 @@ public:
   double elevation() const
   { return mPosition.getElevationFt(); }
   
+  double elevationM() const
+  { return mPosition.getElevationM(); }
+
   /**
    * Predicate class to support custom filtering of FGPositioned queries
    * Default implementation of this passes any FGPositioned instance.
@@ -243,7 +247,33 @@ protected:
   FGPositioned(PositionedID aGuid, Type ty, const std::string& aIdent, const SGGeod& aPos);
     
   void modifyPosition(const SGGeod& newPos);
-  
+
+  static FGPositioned* loadByIdImpl(PositionedID id);
+
+  template<class T>
+  static T* loadById(PositionedID id)
+  {
+    return static_cast<T*>( loadByIdImpl(id) );
+  }
+
+  template<class T>
+  static T* loadById(const PositionedIDVec& id_vec, size_t index)
+  {
+    assert(index >= 0 && index < id_vec.size());
+    return loadById<T>(id_vec[index]);
+  }
+
+  template<class T>
+  static std::vector<T*> loadAllById(const PositionedIDVec& id_vec)
+  {
+    std::vector<T*> vec(id_vec.size());
+
+    for(size_t i = 0; i < id_vec.size(); ++i)
+      vec[i] = loadById<T>(id_vec[i]);
+
+    return vec;
+  }
+
   const PositionedID mGuid;
   const SGGeod mPosition;
   const SGVec3d mCart;
index f94ec0cc1cd03312d670b45a7d067dcd4504071c..96f8a77d77176e40db9f30063ca29c54dbb1d52f 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <simgear/structure/exception.hxx>
 
+#include <Airports/runways.hxx>
 #include <Navaids/waypoint.hxx>
 
 using std::string;
index 1a4ce12298139ec969c936842d4ac97c1576a523..146e237ad43352e5b51b34b80559b0b62238b72e 100644 (file)
@@ -23,9 +23,8 @@
 #include <set>
 
 #include <simgear/math/sg_types.hxx> // for string_list
-
+#include <Airports/airports_fwd.hxx>
 #include <Navaids/route.hxx>
-#include <Airports/runways.hxx>
 
 typedef SGSharedPtr<FGRunway> FGRunwayRef;
 
index b12643e229010d7458cd2fe5697c89691ea08065..3a1c263ef7794603939a53aec69701501737ac11 100644 (file)
@@ -164,16 +164,16 @@ naRef f_groupGetElementById(sc::Group& group, const nasal::CallContext& ctx)
   );
 }
 
-naRef f_eventGetTarget(naContext c, sc::Event& event)
+naRef to_nasal_helper(naContext c, const sc::ElementWeakPtr& el)
 {
-  return NasalElement::create(c, event.getTarget().lock());
+  return NasalElement::create(c, el.lock());
 }
 
 naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave)
 {
   NasalEvent::init("canvas.Event")
     .member("type", &sc::Event::getTypeString)
-    .member("target", &f_eventGetTarget)
+    .member("target", &sc::Event::getTarget)
     .method("stopPropagation", &sc::Event::stopPropagation);
   NasalMouseEvent::init("canvas.MouseEvent")
     .bases<NasalEvent>()
index 1f10e5baf73bd213c5a1740d1a1189b863cfd838..f4eeb84440f00030b24c5bcee004668dc2ebe390 100644 (file)
@@ -462,7 +462,7 @@ static const char* wayptGhostGetMember(naContext c, void* g, naRef field, naRef*
 
 static RouteRestriction routeRestrictionFromString(const char* s)
 {
-  string u(s);
+  std::string u(s);
   boost::to_lower(u);
   if (u == "computed") return RESTRICT_COMPUTED;
   if (u == "at") return RESTRICT_AT;
@@ -728,7 +728,7 @@ static const char* procedureGhostGetMember(naContext c, void* g, naRef field, na
         
     ArrivalDeparture* ad = static_cast<ArrivalDeparture*>(proc);
     *out = naNewVector(c);
-    BOOST_FOREACH(string id, ad->transitionIdents()) {
+    BOOST_FOREACH(std::string id, ad->transitionIdents()) {
       naVec_append(*out, stringToNasal(c, id));
     }
   } else {
@@ -1112,7 +1112,7 @@ static naRef f_findAirportsByICAO(naContext c, naRef me, int argc, naRef* args)
   }
   
   int argOffset = 0;
-  string prefix(naStr_data(args[argOffset++]));
+  std::string prefix(naStr_data(args[argOffset++]));
   AirportInfoFilter filter; // defaults to airports only
   if (argOffset < argc) {
     filter.fromArg(args[argOffset++]);
@@ -1213,26 +1213,6 @@ static naRef f_airport_runwaysWithoutReciprocals(naContext c, naRef me, int argc
   return runways;
 }
 
-static naRef f_airport_taxiway(naContext c, naRef me, int argc, naRef* args)
-{
-  FGAirport* apt = airportGhost(me);
-  if (!apt) {
-    naRuntimeError(c, "airport.taxiway called on non-airport object");
-  }
-  
-  if ((argc < 1) || !naIsString(args[0])) {
-    naRuntimeError(c, "airport.taxiway expects a taxiway ident argument");
-  }
-  
-  naRef taxiways = naNewVector(c);
-  
-  for (unsigned int i = 0; i < apt->numTaxiways(); i++) {
-    naVec_append(taxiways, ghostForTaxiway(c, apt->getTaxiwayByIndex(i)));
-  }
-  
-  return taxiways;  
-}
-
 static naRef f_airport_sids(naContext c, naRef me, int argc, naRef* args)
 {
   FGAirport* apt = airportGhost(me);
@@ -1417,7 +1397,7 @@ static naRef f_airport_getSid(naContext c, naRef me, int argc, naRef* args)
     naRuntimeError(c, "airport.getSid passed invalid argument");
   }
   
-  string ident = naStr_data(args[0]);
+  std::string ident = naStr_data(args[0]);
   return ghostForProcedure(c, apt->findSIDWithIdent(ident));
 }
 
@@ -1432,7 +1412,7 @@ static naRef f_airport_getStar(naContext c, naRef me, int argc, naRef* args)
     naRuntimeError(c, "airport.getStar passed invalid argument");
   }
   
-  string ident = naStr_data(args[0]);
+  std::string ident = naStr_data(args[0]);
   return ghostForProcedure(c, apt->findSTARWithIdent(ident));
 }
 
@@ -1447,7 +1427,7 @@ static naRef f_airport_getApproach(naContext c, naRef me, int argc, naRef* args)
     naRuntimeError(c, "airport.getIAP passed invalid argument");
   }
   
-  string ident = naStr_data(args[0]);
+  std::string ident = naStr_data(args[0]);
   return ghostForProcedure(c, apt->findApproachWithIdent(ident));
 }
 
@@ -1621,7 +1601,7 @@ static naRef f_findNavaidsByIdent(naContext c, naRef me, int argc, naRef* args)
   }
   
   FGPositioned::Type type = FGPositioned::INVALID;
-  string ident = naStr_data(args[argOffset++]);
+  std::string ident = naStr_data(args[argOffset++]);
   if (argOffset < argc) {
     type = FGPositioned::typeFromName(naStr_data(args[argOffset]));
   }
@@ -1647,7 +1627,7 @@ static naRef f_findFixesByIdent(naContext c, naRef me, int argc, naRef* args)
     naRuntimeError(c, "findFixesByIdent expectes ident string as arg %d", argOffset);
   }
   
-  string ident(naStr_data(args[argOffset]));
+  std::string ident(naStr_data(args[argOffset]));
   naRef r = naNewVector(c);
   
   FGPositioned::TypeFilter filter(FGPositioned::FIX);
@@ -1954,7 +1934,7 @@ static naRef f_createWP(naContext c, naRef me, int argc, naRef* args)
     naRuntimeError(c, "createWP: no identifier supplied");
   }
     
-  string ident = naStr_data(args[argOffset++]);
+  std::string ident = naStr_data(args[argOffset++]);
   WayptRef wpt = new BasicWaypt(pos, ident, NULL);
   
 // set waypt flags - approach, departure, pseudo, etc
@@ -2430,7 +2410,6 @@ naRef initNasalPositioned(naRef globals, naContext c, naRef gcSave)
     hashset(c, airportPrototype, "runway", naNewFunc(c, naNewCCode(c, f_airport_runway)));
     hashset(c, airportPrototype, "runwaysWithoutReciprocals", naNewFunc(c, naNewCCode(c, f_airport_runwaysWithoutReciprocals)));
     hashset(c, airportPrototype, "helipad", naNewFunc(c, naNewCCode(c, f_airport_runway)));
-    hashset(c, airportPrototype, "taxiway", naNewFunc(c, naNewCCode(c, f_airport_taxiway)));
     hashset(c, airportPrototype, "tower", naNewFunc(c, naNewCCode(c, f_airport_tower)));
     hashset(c, airportPrototype, "comms", naNewFunc(c, naNewCCode(c, f_airport_comms)));
     hashset(c, airportPrototype, "sids", naNewFunc(c, naNewCCode(c, f_airport_sids)));
index 016c12c6010309281b4f660481f8d0921c2bb03a..7a705cae5b2c0505d9c9017c5c7a6687c8c50e5c 100644 (file)
@@ -140,8 +140,8 @@ class FGAISchedule
 
 };
 
-typedef vector<FGAISchedule*>           ScheduleVector;
-typedef vector<FGAISchedule*>::iterator ScheduleVectorIterator;
+typedef std::vector<FGAISchedule*>           ScheduleVector;
+typedef std::vector<FGAISchedule*>::iterator ScheduleVectorIterator;
 
 bool compareSchedules(FGAISchedule*a, FGAISchedule*b);