FlightGear next
airportdynamicsmanager.cxx
Go to the documentation of this file.
1// airportdynamicsmanager.cxx - manager for dynamic (changeable)
2// part of airport state
3//
4// Written by James Turner, started December 2015
5//
6// Copyright (C) 2015 James Turner <zakalawe@mac.com>
7//
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.
12//
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.
17//
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.
21
23
24#include <simgear/structure/exception.hxx>
25
26#include "airport.hxx"
27#include "xmlloader.hxx"
28#include "dynamics.hxx"
29#include "runwayprefs.hxx"
30
31#include <Main/globals.hxx>
32
33namespace flightgear
34{
35
40
41
47
49{
50
51
52}
53
55{
56 m_dynamics.clear();
57}
58
60{
61 SG_UNUSED(dt);
62}
63
65{
66 shutdown();
67 init();
68}
69
71{
72 ICAODynamicsDict::iterator it = m_dynamics.find(icao);
73 if (it != m_dynamics.end()) {
74 return it->second;
75 }
76
78 if (!apt)
79 return FGAirportDynamicsRef();
80
82 d->init();
83
84 FGRunwayPreference rwyPrefs(apt);
85 XMLLoader::load(&rwyPrefs);
86 d->setRwyUse(rwyPrefs);
87
88 m_dynamics[icao] = d;
89 return d;
90}
91
93{
94 if (icao.empty())
95 return FGAirportDynamicsRef();
96
97 auto instance = globals->get_subsystem<AirportDynamicsManager>();
98 if (!instance)
99 return FGAirportDynamicsRef();
100
101 return instance->dynamicsForICAO(icao);
102}
103
105{
106 if (!apt)
107 return {};
108
109 return find(apt->ident());
110}
111
112// Register the subsystem.
113SGSubsystemMgr::Registrant<AirportDynamicsManager> registrantAirportDynamicsManager;
114
115} // of namespace flightgear
SGSharedPtr< FGAirportDynamics > FGAirportDynamicsRef
SGSharedPtr< FGAirport > FGAirportRef
static FGAirportRef findByIdent(const std::string &aIdent)
Helper to look up an FGAirport instance by unique ident.
Definition airport.cxx:489
static void load(FGRunwayPreference *p)
FGAirportDynamicsRef dynamicsForICAO(const std::string &icao)
static FGAirportDynamicsRef find(const std::string &icao)
FGGlobals * globals
Definition globals.cxx:142
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
Definition Addon.cxx:53
SGSubsystemMgr::Registrant< AirportDynamicsManager > registrantAirportDynamicsManager