#ifndef _AIRPORT_DYNAMICS_HXX_
#define _AIRPORT_DYNAMICS_HXX_
+#include <set>
+
+#include <simgear/structure/SGReferenced.hxx>
+
#include <ATC/trafficcontrol.hxx>
+#include <ATC/GroundController.hxx>
+
+#include "airports_fwd.hxx"
#include "parking.hxx"
-#include "groundnetwork.hxx"
#include "runwayprefs.hxx"
-// forward decls
-class FGAirport;
-class FGEnvironment;
+class ParkingAssignment
+{
+public:
+ ParkingAssignment();
+ ~ParkingAssignment();
+
+// create a parking assignment (and mark it as unavailable)
+ ParkingAssignment(FGParking* pk, FGAirportDynamics* apt);
+
+ ParkingAssignment(const ParkingAssignment& aOther);
+ void operator=(const ParkingAssignment& aOther);
+
+ bool isValid() const;
+ FGParking* parking() const;
+
+ void release();
+private:
+ void clear();
+
+ class ParkingAssignmentPrivate;
+ ParkingAssignmentPrivate* _sharedData;
+};
-class FGAirportDynamics {
+class FGAirportDynamics : public SGReferenced
+{
private:
FGAirport* _ap;
- FGParkingVec parkings;
+ typedef std::set<FGParkingRef> ParkingSet;
+ // if a parking item is in this set, it is occupied
+ ParkingSet occupiedParkings;
+
+
+ std::auto_ptr<FGGroundNetwork> groundNetwork;
+
FGRunwayPreference rwyPrefs;
FGStartupController startupController;
- FGGroundNetwork groundNetwork;
FGTowerController towerController;
FGApproachController approachController;
+ FGGroundController groundController;
time_t lastUpdate;
std::string prevTrafficType;
bool innerGetActiveRunway(const std::string &trafficType, int action, std::string &runway, double heading);
std::string chooseRwyByHeading(stringVec rwys, double heading);
- int innerGetAvailableParking(double radius, const std::string & flType,
- const std::string & acType, const std::string & airline,
+ FGParking* innerGetAvailableParking(double radius, const std::string & flType,
+ const std::string & airline,
bool skipEmptyAirlineCode);
public:
FGAirportDynamics(FGAirport* ap);
- ~FGAirportDynamics();
+ virtual ~FGAirportDynamics();
void addAwosFreq (int val) {
freqAwos.push_back(val);
FGAirport* parent() const
{ return _ap; }
- void getActiveRunway(const string& trafficType, int action, string& runway, double heading);
-
- void addParking(FGParking* park);
+ void getActiveRunway( const std::string& trafficType,
+ int action,
+ std::string& runway,
+ double heading );
/**
* retrieve an available parking by GateID, or -1 if no suitable
* parking location could be found.
*/
- int getAvailableParking(double radius, const std::string& fltype,
+ ParkingAssignment getAvailableParking(double radius, const std::string& fltype,
const std::string& acType, const std::string& airline);
- FGParking *getParking(int i);
- void releaseParking(int id);
- std::string getParkingName(int i);
- int getNrOfParkings() {
- return parkings.size();
- };
+ void setParkingAvailable(FGParking* park, bool available);
+
+ bool isParkingAvailable(FGParking* parking) const;
+
+ void releaseParking(FGParking* id);
+
+ FGParkingList getParkings(bool onlyAvailable, const std::string& type) const;
/**
* Find a parking gate index by name. Note names are often not unique
- * in our data, so will return the first match.
+ * in our data, so will return the first match. If the parking is found,
+ * it will be marked as in-use (unavailable)
*/
- int findParkingByName(const std::string& name) const;
+ ParkingAssignment getParkingByName(const std::string& name) const;
// ATC related functions.
FGStartupController *getStartupController() {
return &startupController;
};
- FGGroundNetwork *getGroundNetwork() {
- return &groundNetwork;
+ FGGroundController *getGroundController() {
+ return &groundController;
};
FGTowerController *getTowerController() {
return &towerController;
return &approachController;
};
+ FGGroundNetwork* getGroundNetwork() const
+ {
+ return groundNetwork.get();
+ }
+
int getGroundFrequency(unsigned leg);
int getTowerFrequency (unsigned nr);