1 // globals.hxx -- Global state that needs to be shared among the sim modules
3 // Written by Curtis Olson, started July 2000.
5 // Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 #include <simgear/compiler.h>
28 #include <simgear/props/props.hxx>
29 #include <simgear/structure/subsystem_mgr.hxx>
34 typedef std::vector<std::string> string_list;
36 // Forward declarations
38 // This file is included, directly or indirectly, almost everywhere in
39 // FlightGear, so if any of its dependencies changes, most of the sim
40 // has to be recompiled. Using these forward declarations helps us to
41 // avoid including a lot of header files (and thus, a lot of
42 // dependencies). Since Most of the methods simply set or return
43 // pointers, we don't need to know anything about the class details
60 class FGAircraftModel;
62 class FGFlightPlanDispatcher;
65 class FGAirwayNetwork;
81 * Bucket for subsystem pointers representing the sim's state.
89 // properties, destroy last
90 SGPropertyNode_ptr props;
91 SGPropertyNode_ptr initial_state;
94 SGPropertyNode_ptr locale;
97 SGSubsystemMgr *subsystem_mgr;
98 SGEventMgr *event_mgr;
100 // Number of milliseconds elapsed since the start of the program.
103 // Root of FlightGear data tree
106 // Roots of FlightGear scenery tree
107 string_list fg_scenery;
111 // An offset in seconds from the true time. Allows us to adjust
112 // the effective time of day.
115 // How much to change the value of warp each iteration. Allows us
116 // to make time progress faster than normal (or even run in reverse.)
125 // Magnetic Variation
128 // Material properties library
129 SGMaterialLib *matlib;
131 // Global autopilot "route"
132 FGRouteMgr *route_mgr;
135 FGPanel *current_panel;
138 SGSoundMgr *soundmgr;
140 // Simple Airport List
141 FGAirportList *airports;
149 // control input state
150 FGControls *controls;
155 SGCommandMgr *commands;
157 //FGFlightPlanDispatcher *fpDispatcher;
159 FGAircraftModel *acmodel;
161 FGModelMgr * model_mgr;
163 // list of serial port-like configurations
164 string_list *channel_options_list;
166 // A list of initial waypoints that are read from the command line
167 // and or flight-plan file during initialization
168 string_list *initial_waypoints;
170 // FlightGear scenery manager
176 // Input/Ouput subsystem
179 FGFontCache *fontcache;
186 FGNavList *tacanlist;
187 FGNavList *carrierlist;
188 FGTACANList *channellist;
189 FGAirwayNetwork *airwaynet;
191 //Mulitplayer managers
192 FGMultiplayMgr *multiplayer_mgr;
197 virtual ~FGGlobals();
199 virtual FGRenderer *get_renderer () const;
201 virtual SGSubsystemMgr *get_subsystem_mgr () const;
203 virtual SGSubsystem *get_subsystem (const char * name);
205 virtual void add_subsystem (const char * name,
206 SGSubsystem * subsystem,
207 SGSubsystemMgr::GroupType
208 type = SGSubsystemMgr::GENERAL,
209 double min_time_sec = 0);
211 virtual SGEventMgr *get_event_mgr () const;
213 inline double get_sim_time_sec () const { return sim_time_sec; }
214 inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
215 inline void set_sim_time_sec (double t) { sim_time_sec = t; }
217 inline const std::string &get_fg_root () const { return fg_root; }
218 void set_fg_root (const std::string &root);
220 inline const string_list &get_fg_scenery () const { return fg_scenery; }
221 void set_fg_scenery (const std::string &scenery);
223 inline const std::string &get_browser () const { return browser; }
224 void set_browser (const std::string &b) { browser = b; }
226 inline long int get_warp() const { return warp; }
227 inline void set_warp( long int w ) { warp = w; }
228 inline void inc_warp( long int w ) { warp += w; }
230 inline long int get_warp_delta() const { return warp_delta; }
231 inline void set_warp_delta( long int d ) { warp_delta = d; }
232 inline void inc_warp_delta( long int d ) { warp_delta += d; }
234 inline SGTime *get_time_params() const { return time_params; }
235 inline void set_time_params( SGTime *t ) { time_params = t; }
237 inline SGEphemeris *get_ephem() const { return ephem; }
238 inline void set_ephem( SGEphemeris *e ) { ephem = e; }
240 inline SGMagVar *get_mag() const { return mag; }
241 inline void set_mag( SGMagVar *m ) { mag = m; }
243 inline SGMaterialLib *get_matlib() const { return matlib; }
244 inline void set_matlib( SGMaterialLib *m ) { matlib = m; }
246 inline FGAirportList *get_airports() const { return airports; }
247 inline void set_airports( FGAirportList *a ) {airports = a; }
249 inline FGATCMgr *get_ATC_mgr() const { return ATC_mgr; }
250 inline void set_ATC_mgr( FGATCMgr *a ) {ATC_mgr = a; }
252 inline FGAIMgr *get_AI_mgr() const { return AI_mgr; }
253 inline void set_AI_mgr( FGAIMgr *a ) {AI_mgr = a; }
255 inline FGPanel *get_current_panel() const { return current_panel; }
256 inline void set_current_panel( FGPanel *cp ) { current_panel = cp; }
258 inline SGSoundMgr *get_soundmgr() const { return soundmgr; }
259 inline void set_soundmgr( SGSoundMgr *sm ) { soundmgr = sm; }
261 inline FGControls *get_controls() const { return controls; }
262 inline void set_controls( FGControls *c ) { controls = c; }
264 inline FGViewMgr *get_viewmgr() const { return viewmgr; }
265 inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
266 FGViewer *get_current_view() const;
268 inline SGPropertyNode *get_props () { return props; }
269 inline void set_props( SGPropertyNode *n ) { props = n; }
271 inline SGPropertyNode *get_locale () { return locale; }
272 inline void set_locale( SGPropertyNode *n ) { locale = n; }
274 inline SGCommandMgr *get_commands () { return commands; }
276 inline FGAircraftModel *get_aircraft_model () { return acmodel; }
278 inline void set_aircraft_model (FGAircraftModel * model)
283 inline FGModelMgr *get_model_mgr () { return model_mgr; }
285 inline void set_model_mgr (FGModelMgr * mgr)
290 inline FGMultiplayMgr *get_multiplayer_mgr () { return multiplayer_mgr; }
292 inline void set_multiplayer_mgr (FGMultiplayMgr * mgr)
294 multiplayer_mgr = mgr;
297 inline string_list *get_channel_options_list () {
298 return channel_options_list;
300 inline void set_channel_options_list( string_list *l ) {
301 channel_options_list = l;
304 inline string_list *get_initial_waypoints () {
305 return initial_waypoints;
308 inline void set_initial_waypoints (string_list *list) {
309 initial_waypoints = list;
312 inline FGScenery * get_scenery () const { return scenery; }
313 inline void set_scenery ( FGScenery *s ) { scenery = s; }
315 inline FGTileMgr * get_tile_mgr () const { return tile_mgr; }
316 inline void set_tile_mgr ( FGTileMgr *t ) { tile_mgr = t; }
318 inline FGIO* get_io() const { return io; }
319 inline FGFontCache *get_fontcache() const { return fontcache; }
321 inline FGNavList *get_navlist() const { return navlist; }
322 inline void set_navlist( FGNavList *n ) { navlist = n; }
323 inline FGNavList *get_loclist() const { return loclist; }
324 inline void set_loclist( FGNavList *n ) { loclist = n; }
325 inline FGNavList *get_gslist() const { return gslist; }
326 inline void set_gslist( FGNavList *n ) { gslist = n; }
327 inline FGNavList *get_dmelist() const { return dmelist; }
328 inline void set_dmelist( FGNavList *n ) { dmelist = n; }
329 inline FGNavList *get_tacanlist() const { return tacanlist; }
330 inline void set_tacanlist( FGNavList *n ) { tacanlist = n; }
331 inline FGNavList *get_carrierlist() const { return carrierlist; }
332 inline void set_carrierlist( FGNavList *n ) { carrierlist = n; }
333 inline FGTACANList *get_channellist() const { return channellist; }
334 inline void set_channellist( FGTACANList *c ) { channellist = c; }
336 inline FGAirwayNetwork *get_airwaynet() const { return airwaynet; }
337 inline void set_airwaynet( FGAirwayNetwork *a ) { airwaynet = a; }
341 * Save the current state as the initial state.
343 void saveInitialState ();
347 * Restore the saved initial state, if any.
349 void restoreInitialState ();
354 extern FGGlobals *globals;
357 #endif // _GLOBALS_HXX