1 // airportdynamicsmanager.cxx - manager for dynamic (changeable)
2 // part of airport state
4 // Written by James Turner, started December 2015
6 // Copyright (C) 2015 James Turner <zakalawe@mac.com>
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "airportdynamicsmanager.hxx"
24 #include <simgear/structure/exception.hxx>
26 #include "airport.hxx"
27 #include "xmlloader.hxx"
28 #include "dynamics.hxx"
29 #include "runwayprefs.hxx"
31 #include <Main/globals.hxx>
36 AirportDynamicsManager::AirportDynamicsManager()
42 AirportDynamicsManager::~AirportDynamicsManager()
48 void AirportDynamicsManager::init()
54 void AirportDynamicsManager::shutdown()
59 void AirportDynamicsManager::update(double dt)
64 void AirportDynamicsManager::reinit()
70 FGAirportDynamicsRef AirportDynamicsManager::dynamicsForICAO(const std::string &icao)
72 ICAODynamicsDict::iterator it = m_dynamics.find(icao);
73 if (it != m_dynamics.end()) {
77 FGAirportRef apt(FGAirport::findByIdent(icao));
79 throw sg_exception("dynamicsForICAO: Invalid ICAO:" + icao);
80 FGAirportDynamicsRef d(new FGAirportDynamics(apt));
82 XMLLoader::load(d.ptr());
85 FGRunwayPreference rwyPrefs(apt);
86 XMLLoader::load(&rwyPrefs);
87 d->setRwyUse(rwyPrefs);
93 FGAirportDynamicsRef AirportDynamicsManager::find(const std::string &icao)
95 AirportDynamicsManager* instance = static_cast<AirportDynamicsManager*>(globals->get_subsystem("airport-dynamics"));
97 return FGAirportDynamicsRef();
99 return instance->dynamicsForICAO(icao);
102 FGAirportDynamicsRef AirportDynamicsManager::find(const FGAirportRef& apt)
104 return find(apt->ident());
107 } // of namespace flightgear