]> git.mxchange.org Git - flightgear.git/blob - src/Traffic/Schedule.hxx
Clean up namespace issues
[flightgear.git] / src / Traffic / Schedule.hxx
1 /* -*- Mode: C++ -*- *****************************************************
2  * Schedule.hxx
3  * Written by Durk Talsma. Started May 5, 2004
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  *
19  *
20  **************************************************************************/
21
22 /**************************************************************************
23  * This file contains the definition of the class Shedule.
24  *
25  * A schedule is basically a number of scheduled flights, wich can be
26  * assigned to an AI aircraft. 
27  **************************************************************************/
28
29 #ifndef _FGSCHEDULE_HXX_
30 #define _FGSCHEDULE_HXX_
31
32 #define TRAFFICTOAIDISTTOSTART 150.0
33 #define TRAFFICTOAIDISTTODIE   200.0
34
35 // forward decls
36 class FGAIAircraft;
37
38 class FGAISchedule
39 {
40  private:
41   std::string modelPath;
42   std::string homePort;
43   std::string livery;
44   std::string registration;
45   std::string airline;
46   std::string acType;
47   std::string m_class;
48   std::string flightType;
49   std::string flightIdentifier;
50   std::string currentDestination;
51   bool heavy;
52   FGScheduledFlightVec flights;
53   SGGeod position;
54   double radius;
55   double groundOffset;
56   double distanceToUser;
57   double score;
58   unsigned int runCount;
59   unsigned int hits;
60   unsigned int lastRun;
61   bool firstRun;
62   double courseToDest;
63   bool initialized;
64   bool valid;
65
66   void scheduleFlights(time_t now);
67   int groundTimeFromRadius();
68   
69   /**
70    * Transition this schedule from distant mode to AI mode;
71    * create the AIAircraft (and flight plan) and register with the AIManager
72    */
73   bool createAIAircraft(FGScheduledFlight* flight, double speedKnots, time_t deptime);
74   
75   // the aiAircraft associated with us
76   SGSharedPtr<FGAIAircraft> aiAircraft;
77  public:
78   FGAISchedule();                                           // constructor
79   FGAISchedule(string model, 
80                string livery,
81                string homePort, 
82                string registration, 
83                string flightId,
84                bool   heavy, 
85                string acType, 
86                string airline, 
87                string m_class, 
88                string flight_type, 
89                double radius, 
90                double offset);                              // construct & init
91   FGAISchedule(const FGAISchedule &other);                  // copy constructor
92
93
94
95   ~FGAISchedule(); //destructor
96
97     static bool validModelPath(const std::string& model);
98     
99   bool update(time_t now, const SGVec3d& userCart);
100   bool init();
101
102   double getSpeed         ();
103   //void setClosestDistanceToUser();
104   bool next();   // forces the schedule to move on to the next flight.
105
106   // TODO: rework these four functions
107    time_t      getDepartureTime    () { return (*flights.begin())->getDepartureTime   (); };
108   FGAirport * getDepartureAirport () { return (*flights.begin())->getDepartureAirport(); };
109   FGAirport * getArrivalAirport   () { return (*flights.begin())->getArrivalAirport  (); };
110   int         getCruiseAlt        () { return (*flights.begin())->getCruiseAlt       (); };
111   double      getRadius           () { return radius; };
112   double      getGroundOffset     () { return groundOffset;};
113   const string& getFlightType     () { return flightType;};
114   const string& getAirline        () { return airline; };
115   const string& getAircraft       () { return acType; };
116   const string& getCallSign       () { return (*flights.begin())->getCallSign (); };
117   const string& getRegistration   () { return registration;};
118   const string& getFlightRules    () { return (*flights.begin())->getFlightRules (); };
119   bool getHeavy                   () { return heavy; };
120   double getCourse                () { return courseToDest; };
121   unsigned int getRunCount        () { return runCount; };
122   unsigned int getHits            () { return hits; };
123
124   void         setrunCount(unsigned int count) { runCount = count; };
125   void         setHits    (unsigned int count) { hits     = count; };
126   void         setScore   ();
127   double       getScore   () { return score; };
128   void         setHeading (); 
129   void         assign         (FGScheduledFlight *ref) { flights.push_back(ref); };
130   void         setFlightType  (string val            ) { flightType = val; };
131   FGScheduledFlight*findAvailableFlight (const string &currentDestination, const string &req, time_t min=0, time_t max=0);
132   // used to sort in decending order of score: I've probably found a better way to
133   // decending order sorting, but still need to test that.
134   bool operator< (const FGAISchedule &other) const;
135     void taint() { valid = false; };
136     int getLastUsed() { return lastRun; };
137     void setLastUsed(unsigned int val) {lastRun = val; }; 
138   //void * getAiRef                 () { return AIManagerRef; };
139   //FGAISchedule* getAddress        () { return this;};
140
141 };
142
143 typedef vector<FGAISchedule*>           ScheduleVector;
144 typedef vector<FGAISchedule*>::iterator ScheduleVectorIterator;
145
146 bool compareSchedules(FGAISchedule*a, FGAISchedule*b);
147
148 #endif
149