]> git.mxchange.org Git - flightgear.git/blobdiff - src/Traffic/TrafficMgr.hxx
Close dialogs on GUI shutdown
[flightgear.git] / src / Traffic / TrafficMgr.hxx
index 41d31de8480c6b25576472b326ec5f766afd5445..15a3467c8ef6df9ec223e9f68f1a11881f2e1356 100644 (file)
 #define _TRAFFICMGR_HXX_
 
 #include <set>
+#include <memory>
+
 #include <simgear/structure/subsystem_mgr.hxx>
 #include <simgear/props/propertyObject.hxx>
-#include <simgear/xml/easyxml.hxx>
 #include <simgear/misc/sg_path.hxx>
-#include <simgear/misc/sg_dir.hxx>
 
 #include "SchedFlight.hxx"
 #include "Schedule.hxx"
 
-
-typedef std::vector<int> IdList;
-typedef std::vector<int>::iterator IdListIterator;
-
 class Heuristic
 {
 public:
@@ -77,68 +73,52 @@ typedef HeuristicMap::iterator             HeuristicMapIterator;
 
 
 
+class ScheduleParseThread;
 
-class FGTrafficManager : public SGSubsystem, public XMLVisitor
+class FGTrafficManager : public SGSubsystem
 {
 private:
   bool inited;
   bool doingInit;
+    bool trafficSyncRequested;
+    
+  double waitingMetarTime;
+  std::string waitingMetarStation;
   
   ScheduleVector scheduledAircraft;
   ScheduleVectorIterator currAircraft, currAircraftClosest;
-  vector<string> elementValueStack;
-
-  // record model paths which are missing, to avoid duplicate
-  // warnings when parsing traffic schedules.
-  std::set<std::string> missingModels;
-    
-  std::string mdl, livery, registration, callsign, fltrules, 
-    port, timeString, departurePort, departureTime, arrivalPort, arrivalTime,
-    repeat, acType, airline, m_class, flighttype, requiredAircraft, homePort;
-  int cruiseAlt;
-  int score, runCount, acCounter;
-  double radius, offset;
-  bool heavy;
-
-  IdList releaseList;
     
   FGScheduledFlightMap flights;
 
   void readTimeTableFromFile(SGPath infilename);
-  void Tokenize(const string& str, vector<string>& tokens, const string& delimiters = " ");
+    void Tokenize(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters = " ");
 
   simgear::PropertyObject<bool> enabled, aiEnabled, realWxEnabled, metarValid;
   
   void loadHeuristics();
   
-  void initStep();
   void finishInit();
   void shutdown();
   
-  // during incremental init, contains the XML files still be read in
-  simgear::PathList schedulesToRead;
+  friend class ScheduleParseThread;
+  std::auto_ptr<ScheduleParseThread> scheduleParser;
+  
+  // helper to read and parse the schedule data.
+  // this is run on a helper thread, so be careful about
+  // accessing properties during parsing
+  void parseSchedule(const SGPath& path);
+  
+  bool metarReady(double dt);
+
 public:
   FGTrafficManager();
   ~FGTrafficManager();
   void init();
   void update(double time);
-  void release(int ref);
-  bool isReleased(int id);
 
-  FGScheduledFlightVecIterator getFirstFlight(const string &ref) { return flights[ref].begin(); }
-  FGScheduledFlightVecIterator getLastFlight(const string &ref) { return flights[ref].end(); }
+    FGScheduledFlightVecIterator getFirstFlight(const std::string &ref) { return flights[ref].begin(); }
+    FGScheduledFlightVecIterator getLastFlight(const std::string &ref) { return flights[ref].end(); }
 
-  void endAircraft();
-  
-  // Some overloaded virtual XMLVisitor members
-  virtual void startXML (); 
-  virtual void endXML   ();
-  virtual void startElement (const char * name, const XMLAttributes &atts);
-  virtual void endElement (const char * name);
-  virtual void data (const char * s, int len);
-  virtual void pi (const char * target, const char * data);
-  virtual void warning (const char * message, int line, int column);
-  virtual void error (const char * message, int line, int column);
 };
 
 #endif