| 1 | // This program is free software; you can redistribute it and/or |
| 2 | // modify it under the terms of the GNU General Public License as |
| 3 | // published by the Free Software Foundation; either version 2 of the |
| 4 | // License, or (at your option) any later version. |
| 5 | // |
| 6 | // This program is distributed in the hope that it will be useful, but |
| 7 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
| 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 9 | // General Public License for more details. |
| 10 | // |
| 11 | // You should have received a copy of the GNU General Public License |
| 12 | // along with this program; if not, write to the Free Software |
| 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 14 | // |
| 15 | |
| 16 | #ifndef _DYNAMIC_LOADER_HXX_ |
| 17 | #define _DYNAMIC_LOADER_HXX_ |
| 18 | |
| 19 | #include <set> |
| 20 | |
| 21 | #include <simgear/xml/easyxml.hxx> |
| 22 | |
| 23 | #include "groundnetwork.hxx" |
| 24 | #include <Airports/parking.hxx> |
| 25 | |
| 26 | class FGGroundNetXMLLoader : public XMLVisitor { |
| 27 | public: |
| 28 | explicit FGGroundNetXMLLoader(FGGroundNetwork* gn); |
| 29 | |
| 30 | bool hasErrors() const |
| 31 | { |
| 32 | return _hasErrors; |
| 33 | } |
| 34 | |
| 35 | protected: |
| 36 | virtual void startXML (); |
| 37 | virtual void endXML (); |
| 38 | virtual void startElement (const char * name, const XMLAttributes &atts); |
| 39 | virtual void endElement (const char * name); |
| 40 | virtual void data (const char * s, int len); |
| 41 | virtual void pi (const char * target, const char * data); |
| 42 | virtual void warning (const char * message, int line, int column); |
| 43 | virtual void error (const char * message, int line, int column); |
| 44 | |
| 45 | private: |
| 46 | void startParking(const XMLAttributes &atts); |
| 47 | void startNode(const XMLAttributes &atts); |
| 48 | void startArc(const XMLAttributes &atts); |
| 49 | |
| 50 | FGGroundNetwork* _groundNetwork; |
| 51 | |
| 52 | // we set this flag if the ground-network has any problems |
| 53 | bool _hasErrors = false; |
| 54 | |
| 55 | std::string value; |
| 56 | |
| 57 | // map from local (groundnet.xml) ids to parking instances |
| 58 | typedef std::map<int, FGTaxiNodeRef> NodeIndexMap; |
| 59 | NodeIndexMap _indexMap; |
| 60 | |
| 61 | // data integrity - watch for unreferenced nodes and duplicated edges |
| 62 | typedef std::pair<int, int> IntPair; |
| 63 | std::set<IntPair> _arcSet; |
| 64 | |
| 65 | std::set<FGTaxiNodeRef> _unreferencedNodes; |
| 66 | |
| 67 | // map from allocated parking position to its local push-back node |
| 68 | // used to defer binding the push-back node until we've processed |
| 69 | // all nodes |
| 70 | typedef std::map<FGParkingRef, int> ParkingPushbackIndex; |
| 71 | ParkingPushbackIndex _parkingPushbacks; |
| 72 | }; |
| 73 | |
| 74 | #endif |