From 2d267a578224f5028dbe1a37a9fe122c0d31c9d3 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 26 Apr 2012 00:37:47 +0100 Subject: [PATCH] Remove PositionedBinding (which no one ever used), Nasal is better for this jobs. --- src/ATC/CommStation.cxx | 8 -- src/ATC/CommStation.hxx | 2 - src/Airports/runways.cxx | 7 -- src/Airports/runways.hxx | 4 +- src/Airports/simple.cxx | 36 ------ src/Airports/simple.hxx | 6 +- src/Main/fg_init.cxx | 1 - src/Navaids/CMakeLists.txt | 6 +- src/Navaids/PositionedBinding.cxx | 188 ------------------------------ src/Navaids/PositionedBinding.hxx | 63 ---------- src/Navaids/navrecord.cxx | 9 -- src/Navaids/navrecord.hxx | 2 - src/Navaids/positioned.cxx | 7 -- src/Navaids/positioned.hxx | 8 -- 14 files changed, 4 insertions(+), 343 deletions(-) delete mode 100644 src/Navaids/PositionedBinding.cxx delete mode 100644 src/Navaids/PositionedBinding.hxx diff --git a/src/ATC/CommStation.cxx b/src/ATC/CommStation.cxx index 45bc2cc08..98c7ab0a3 100644 --- a/src/ATC/CommStation.cxx +++ b/src/ATC/CommStation.cxx @@ -2,8 +2,6 @@ #include -#include - namespace { typedef std::multimap FrequencyMap; @@ -36,12 +34,6 @@ double CommStation::freqMHz() const return mFreqKhz / 100.0; } -PositionedBinding* -CommStation::createBinding(SGPropertyNode* nd) const -{ - return new CommStationBinding(this, nd); -} - CommStation* CommStation::findByFreq(int freqKhz, const SGGeod& pos, FGPositioned::Filter* filt) { diff --git a/src/ATC/CommStation.hxx b/src/ATC/CommStation.hxx index 89c0d1f43..01783febe 100644 --- a/src/ATC/CommStation.hxx +++ b/src/ATC/CommStation.hxx @@ -15,8 +15,6 @@ public: void setAirport(FGAirport* apt); FGAirport* airport() const { return mAirport; } - - virtual flightgear::PositionedBinding* createBinding(SGPropertyNode* nd) const; int rangeNm() const { return mRangeNM; } diff --git a/src/Airports/runways.cxx b/src/Airports/runways.cxx index bd2df3038..adbd22600 100644 --- a/src/Airports/runways.cxx +++ b/src/Airports/runways.cxx @@ -40,7 +40,6 @@ #include #include #include -#include using std::string; @@ -199,9 +198,3 @@ std::vector FGRunway::getSTARs() return result; } -flightgear::PositionedBinding* -FGRunway::createBinding(SGPropertyNode* nd) const -{ - return new flightgear::RunwayBinding(this, nd); -} - diff --git a/src/Airports/runways.hxx b/src/Airports/runways.hxx index 2cdc2e495..9ae89aa7d 100644 --- a/src/Airports/runways.hxx +++ b/src/Airports/runways.hxx @@ -115,9 +115,7 @@ public: FGRunway* reciprocalRunway() const { return _reciprocal; } void setReciprocalRunway(FGRunway* other); - - virtual flightgear::PositionedBinding* createBinding(SGPropertyNode* nd) const; - + /** * Helper to process property data loaded from an ICAO.threshold.xml file */ diff --git a/src/Airports/simple.cxx b/src/Airports/simple.cxx index 1cf962607..7ef5b642b 100644 --- a/src/Airports/simple.cxx +++ b/src/Airports/simple.cxx @@ -47,7 +47,6 @@ #include #include #include -#include #include using std::vector; @@ -667,41 +666,6 @@ Approach* FGAirport::getApproachByIndex(unsigned int aIndex) const return mApproaches[aIndex]; } -class AirportNodeListener : public SGPropertyChangeListener -{ -public: - AirportNodeListener() - { - SGPropertyNode* airports = fgGetNode("/sim/airport"); - airports->addChangeListener(this, false); - } - - virtual void valueChanged(SGPropertyNode*) - { - } - - virtual void childAdded(SGPropertyNode* pr, SGPropertyNode* child) - { - FGAirport* apt = FGAirport::findByIdent(child->getName()); - if (!apt) { - return; - } - - flightgear::PositionedBinding::bind(apt, child); - } -}; - -void FGAirport::installPropertyListener() -{ - new AirportNodeListener; -} - -flightgear::PositionedBinding* -FGAirport::createBinding(SGPropertyNode* nd) const -{ - return new flightgear::AirportBinding(this, nd); -} - void FGAirport::setCommStations(CommStationList& comms) { mCommStations.swap(comms); diff --git a/src/Airports/simple.hxx b/src/Airports/simple.hxx index d90f3ce9e..c2eafbbe1 100644 --- a/src/Airports/simple.hxx +++ b/src/Airports/simple.hxx @@ -188,8 +188,6 @@ public: unsigned int numApproaches() const; flightgear::Approach* getApproachByIndex(unsigned int aIndex) const; - - static void installPropertyListener(); /** * Syntactic wrapper around FGPositioned::findClosest - find the closest @@ -233,9 +231,7 @@ public: * returns (NULL, NULL) is no suitable STAR is exists */ std::pair selectSTAR(const SGGeod& aOrigin, FGRunway* aRwy); - - virtual flightgear::PositionedBinding* createBinding(SGPropertyNode* nd) const; - + void setCommStations(flightgear::CommStationList& comms); flightgear::CommStationList commStationsOfType(FGPositioned::Type aTy) const; diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index e1bcc0621..ea323425c 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -823,7 +823,6 @@ fgInitNav () p_metar.append( "Airports/metar.dat" ); fgAirportDBLoad( aptdb.str(), p_metar.str() ); - FGAirport::installPropertyListener(); FGNavList *navlist = new FGNavList; FGNavList *loclist = new FGNavList; diff --git a/src/Navaids/CMakeLists.txt b/src/Navaids/CMakeLists.txt index 05a999cb3..bd5cce9b7 100644 --- a/src/Navaids/CMakeLists.txt +++ b/src/Navaids/CMakeLists.txt @@ -12,8 +12,7 @@ set(SOURCES route.cxx routePath.cxx waypoint.cxx - PositionedBinding.cxx - ) +) set(HEADERS airways.hxx @@ -27,7 +26,6 @@ set(HEADERS route.hxx routePath.hxx waypoint.hxx - PositionedBinding.hxx - ) +) flightgear_component(Navaids "${SOURCES}" "${HEADERS}") \ No newline at end of file diff --git a/src/Navaids/PositionedBinding.cxx b/src/Navaids/PositionedBinding.cxx deleted file mode 100644 index 8a2f23f6f..000000000 --- a/src/Navaids/PositionedBinding.cxx +++ /dev/null @@ -1,188 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "PositionedBinding.hxx" - -#include - -#include -#include -#include - -#include
-#include -#include -#include -#include - -typedef std::map BindingMap; -static BindingMap static_bindings; - -namespace { - -class PropertyDeleteObserver : public SGPropertyChangeListener -{ -public: - virtual void childRemoved(SGPropertyNode*, SGPropertyNode* node) - { - BindingMap::iterator it = static_bindings.find(node); - if (it != static_bindings.end()) { - SG_LOG(SG_GENERAL, SG_INFO, "saw remove of:" << node->getPath() << ", deleting binding"); - delete it->second; - static_bindings.erase(it); - } - } -}; - -static PropertyDeleteObserver* static_deleteObserver = NULL; - -} // of anonymous namespace - -namespace flightgear -{ - -PositionedBinding::PositionedBinding(const FGPositioned* pos, SGPropertyNode* nd) : - p(const_cast(pos)), - tied(nd) -{ - if (!static_deleteObserver) { - static_deleteObserver = new PropertyDeleteObserver; - globals->get_props()->addChangeListener(static_deleteObserver, false); - } - - nd->setDoubleValue("latitude-deg", p->latitude()); - nd->setDoubleValue("longitude-deg", p->longitude()); - - if (p->elevation() > -1000) { - nd->setDoubleValue("elevation-ft", p->elevation()); - } - - nd->setStringValue("ident", p->ident()); - if (!p->name().empty()) { - nd->setStringValue("name", p->name()); - } - - nd->setStringValue("type", FGPositioned::nameForType(p->type())); -} - -PositionedBinding::~PositionedBinding() -{ - tied.Untie(); -} - -void PositionedBinding::bind(FGPositioned* pos, SGPropertyNode* node) -{ - BindingMap::iterator it = static_bindings.find(node); - if (it != static_bindings.end()) { - throw sg_exception("duplicate positioned binding", node->getPath()); - } - - PositionedBinding* binding = pos->createBinding(node); - static_bindings.insert(it, std::make_pair(node, binding)); -} - -NavaidBinding::NavaidBinding(const FGNavRecord* nav, SGPropertyNode* nd) : - PositionedBinding(nav, nd) -{ - FGPositioned::Type ty = nav->type(); - if (ty == FGPositioned::NDB) { - nd->setDoubleValue("frequency-khz", nav->get_freq() / 100.0); - } else { - nd->setDoubleValue("frequency-mhz", nav->get_freq() / 100.0); - } - - if ((ty == FGPositioned::LOC) || (ty == FGPositioned::ILS)) { - nd->setDoubleValue("loc-course-deg", nav->get_multiuse()); - } - - if (ty == FGPositioned::GS) { - nd->setDoubleValue("gs-angle-deg", nav->get_multiuse()); - } - - nd->setDoubleValue("range-nm", nav->get_range()); - - if (nav->runway()) { - // don't want to create a cycle in the graph, so we don't re-bind - // the airport/runway node here - just expose the IDs - nd->setStringValue("airport", nav->runway()->airport()->ident()); - nd->setStringValue("runway", nav->runway()->ident()); - } -}; - -RunwayBinding::RunwayBinding(const FGRunway* rwy, SGPropertyNode* nd) : - PositionedBinding(rwy, nd) -{ - nd->setDoubleValue("length-ft", rwy->lengthFt()); - nd->setDoubleValue("length-m", rwy->lengthM()); - nd->setDoubleValue("width-ft", rwy->widthFt()); - nd->setDoubleValue("width-m", rwy->widthM()); - nd->setDoubleValue("heading-deg", rwy->headingDeg()); - nd->setBoolValue("hard-surface", rwy->isHardSurface()); - - nd->setDoubleValue("threshold-displacement-m", rwy->displacedThresholdM()); - nd->setDoubleValue("stopway-m", rwy->stopwayM()); - - if (rwy->ILS()) { - SGPropertyNode* ilsNode = nd->getChild("ils", 0, true); - PositionedBinding::bind(rwy->ILS(), ilsNode); - } -} - -AirportBinding::AirportBinding(const FGAirport* apt, SGPropertyNode* nd) : - PositionedBinding(apt, nd) -{ - nd->setIntValue("num-runways", apt->numRunways()); - - SGGeod tower = apt->getTowerLocation(); - nd->setDoubleValue("tower/latitude-deg", tower.getLatitudeDeg()); - nd->setDoubleValue("tower/longitude-deg", tower.getLongitudeDeg()); - nd->setDoubleValue("tower/elevation-ft", tower.getElevationFt()); - - for (unsigned int r=0; rnumRunways(); ++r) { - SGPropertyNode* rn = nd->getChild("runway", r, true); - FGRunway* rwy = apt->getRunwayByIndex(r); - PositionedBinding::bind(rwy, rn); - } - - for (unsigned int c=0; ccommStations().size(); ++c) { - flightgear::CommStation* comm = apt->commStations()[c]; - std::string tynm = FGPositioned::nameForType(comm->type()); - - // for some standard frequence types, we don't care about the ident, - // so just list the frequencies under one group. - if ((comm->type() == FGPositioned::FREQ_ATIS) || - (comm->type() == FGPositioned::FREQ_AWOS) || - (comm->type() == FGPositioned::FREQ_TOWER) || - (comm->type() == FGPositioned::FREQ_GROUND)) - { - SGPropertyNode* commNode = nd->getChild(tynm, 0, true); - int count = nd->getChildren("frequency-mhz").size(); - SGPropertyNode* freqNode = commNode->getChild("frequency-mhz", count, true); - freqNode->setDoubleValue(comm->freqMHz()); - } else { - // for other kinds of frequency, there's more variation, so list the ID too - int count = nd->getChildren(tynm).size(); - SGPropertyNode* commNode = nd->getChild(tynm, count, true); - commNode->setStringValue("ident", comm->ident()); - commNode->setDoubleValue("frequency-mhz", comm->freqMHz()); - - } - } // of airprot comm stations iteration -} - -CommStationBinding::CommStationBinding(const CommStation* sta, SGPropertyNode* node) : - PositionedBinding(sta, node) -{ - node->setIntValue("range-nm", sta->rangeNm()); - node->setDoubleValue("frequency-mhz", sta->freqMHz()); - - if (sta->airport()) { - // don't want to create a cycle in the graph, so we don't re-bind - // the airport/runway node here - just expose the IDs - node->setStringValue("airport", sta->airport()->ident()); - } -} - -} // of namespace flightgear - diff --git a/src/Navaids/PositionedBinding.hxx b/src/Navaids/PositionedBinding.hxx deleted file mode 100644 index ee4df7d19..000000000 --- a/src/Navaids/PositionedBinding.hxx +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef FG_POSITIONED_BINDING_HXX -#define FG_POSITIONED_BINDING_HXX - -#include - -#include "positioned.hxx" - -// forward decls -class FGNavRecord; -class FGRunway; -class FGAirport; - -namespace flightgear -{ - -// forward decls -class CommStation; - -class PositionedBinding -{ -public: - virtual ~PositionedBinding(); - - static void bind(FGPositioned* pos, SGPropertyNode* node); - - - PositionedBinding(const FGPositioned* pos, SGPropertyNode* node); - -protected: - FGPositionedRef p; // bindings own a reference to their positioned - simgear::TiedPropertyList tied; - -private: - -}; - -class NavaidBinding : public PositionedBinding -{ -public: - NavaidBinding(const FGNavRecord* nav, SGPropertyNode* node); -}; - -class RunwayBinding : public PositionedBinding -{ -public: - RunwayBinding(const FGRunway* rwy, SGPropertyNode* node); -}; - -class AirportBinding : public PositionedBinding -{ -public: - AirportBinding(const FGAirport* apt, SGPropertyNode* node); -}; - -class CommStationBinding : public PositionedBinding -{ -public: - CommStationBinding(const CommStation* sta, SGPropertyNode* node); -}; - -} // of namespace flightgear - -#endif // of FG_POSITIONED_BINDING_HXX diff --git a/src/Navaids/navrecord.cxx b/src/Navaids/navrecord.cxx index d30635303..d0549f26b 100644 --- a/src/Navaids/navrecord.cxx +++ b/src/Navaids/navrecord.cxx @@ -39,9 +39,7 @@ #include #include #include - #include
-#include FGNavRecord::FGNavRecord(Type aTy, const std::string& aIdent, const std::string& aName, const SGGeod& aPos, @@ -187,13 +185,6 @@ double FGNavRecord::localizerWidth() const } -flightgear::PositionedBinding* -FGNavRecord::createBinding(SGPropertyNode* nd) const -{ - return new flightgear::NavaidBinding(this, nd); -} - - FGTACANRecord::FGTACANRecord(void) : channel(""), freq(0) diff --git a/src/Navaids/navrecord.hxx b/src/Navaids/navrecord.hxx index a77896caf..982292e63 100644 --- a/src/Navaids/navrecord.hxx +++ b/src/Navaids/navrecord.hxx @@ -88,8 +88,6 @@ public: */ FGRunway* runway() const { return mRunway; } - virtual flightgear::PositionedBinding* createBinding(SGPropertyNode* nd) const; - /** * return the localizer width, in degrees * computation is based up ICAO stdandard width at the runway threshold diff --git a/src/Navaids/positioned.cxx b/src/Navaids/positioned.cxx index 6193d7b2f..a3f93bf75 100644 --- a/src/Navaids/positioned.cxx +++ b/src/Navaids/positioned.cxx @@ -43,7 +43,6 @@ #include #include -#include "PositionedBinding.hxx" #include "Airports/simple.hxx" #include "Main/fg_props.hxx" @@ -701,12 +700,6 @@ const char* FGPositioned::nameForType(Type aTy) } } -flightgear::PositionedBinding* -FGPositioned::createBinding(SGPropertyNode* node) const -{ - return new flightgear::PositionedBinding(this, node); -} - /////////////////////////////////////////////////////////////////////////////// // search / query functions diff --git a/src/Navaids/positioned.hxx b/src/Navaids/positioned.hxx index 1ed162523..5f8d90e6f 100644 --- a/src/Navaids/positioned.hxx +++ b/src/Navaids/positioned.hxx @@ -32,11 +32,6 @@ class SGPropertyNode; typedef SGSharedPtr FGPositionedRef; -namespace flightgear -{ - class PositionedBinding; -} - class FGPositioned : public SGReferenced { public: @@ -109,9 +104,6 @@ public: double elevation() const { return mPosition.getElevationFt(); } - - virtual flightgear::PositionedBinding* createBinding(SGPropertyNode* nd) const; - /** * Predicate class to support custom filtering of FGPositioned queries * Default implementation of this passes any FGPositioned instance.