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.
31 #include <simgear/compiler.h>
32 #include <simgear/structure/callback.hxx>
33 #include <simgear/structure/subsystem_mgr.hxx>
34 #include <simgear/structure/event_mgr.hxx>
39 SG_USING_STD( vector );
40 SG_USING_STD( string );
42 typedef vector<string> string_list;
45 // Forward declarations
47 // This file is included, directly or indirectly, almost everywhere in
48 // FlightGear, so if any of its dependencies changes, most of the sim
49 // has to be recompiled. Using these forward declarations helps us to
50 // avoid including a lot of header files (and thus, a lot of
51 // dependencies). Since Most of the methods simply set or return
52 // pointers, we don't need to know anything about the class details
69 class FGAircraftModel;
71 class FGFlightPlanDispatcher;
74 class FGAirwayNetwork;
91 * Bucket for subsystem pointers representing the sim's state.
99 // properties, destroy last
100 SGPropertyNode_ptr props;
101 SGPropertyNode_ptr initial_state;
104 SGPropertyNode_ptr locale;
106 FGRenderer *renderer;
107 SGSubsystemMgr *subsystem_mgr;
108 SGEventMgr *event_mgr;
110 // Number of milliseconds elapsed since the start of the program.
113 // Root of FlightGear data tree
116 // Roots of FlightGear scenery tree
117 string_list fg_scenery;
121 // Fullscreen mode for old 3DFX cards.
122 #if defined(FX) && defined(XMESA)
126 // An offset in seconds from the true time. Allows us to adjust
127 // the effective time of day.
130 // How much to change the value of warp each iteration. Allows us
131 // to make time progress faster than normal (or even run in reverse.)
140 // Magnetic Variation
143 // Material properties library
144 SGMaterialLib *matlib;
146 // Global autopilot "route"
147 FGRouteMgr *route_mgr;
150 FGPanel *current_panel;
153 SGSoundMgr *soundmgr;
155 // Simple Airport List
156 FGAirportList *airports;
159 FGRunwayList *runways;
167 // control input state
168 FGControls *controls;
173 SGCommandMgr *commands;
175 //FGFlightPlanDispatcher *fpDispatcher;
177 FGAircraftModel *acmodel;
179 FGModelMgr * model_mgr;
181 // list of serial port-like configurations
182 string_list *channel_options_list;
184 // A list of initial waypoints that are read from the command line
185 // and or flight-plan file during initialization
186 string_list *initial_waypoints;
188 // FlightGear scenery manager
194 // Input/Ouput subsystem
197 FGFontCache *fontcache;
205 FGNavList *tacanlist;
206 FGNavList *carrierlist;
207 FGTACANList *channellist;
209 FGAirwayNetwork *airwaynet;
211 //Mulitplayer managers
212 FGMultiplayMgr *multiplayer_mgr;
217 virtual ~FGGlobals();
219 virtual FGRenderer *get_renderer () const;
221 virtual SGSubsystemMgr *get_subsystem_mgr () const;
223 virtual SGSubsystem *get_subsystem (const char * name);
225 virtual void add_subsystem (const char * name,
226 SGSubsystem * subsystem,
227 SGSubsystemMgr::GroupType
228 type = SGSubsystemMgr::GENERAL,
229 double min_time_sec = 0);
231 virtual SGEventMgr *get_event_mgr () const;
233 inline double get_sim_time_sec () const { return sim_time_sec; }
234 inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
235 inline void set_sim_time_sec (double t) { sim_time_sec = t; }
237 inline const string &get_fg_root () const { return fg_root; }
238 void set_fg_root (const string &root);
240 inline const string_list &get_fg_scenery () const { return fg_scenery; }
241 void set_fg_scenery (const string &scenery);
243 inline const string &get_browser () const { return browser; }
244 void set_browser (const string &b) { browser = b; }
246 #if defined(FX) && defined(XMESA)
247 inline bool get_fullscreen() const { return fullscreen; }
248 inline bool set_fullscreen( bool f ) { fullscreen = f; }
251 inline long int get_warp() const { return warp; }
252 inline void set_warp( long int w ) { warp = w; }
253 inline void inc_warp( long int w ) { warp += w; }
255 inline long int get_warp_delta() const { return warp_delta; }
256 inline void set_warp_delta( long int d ) { warp_delta = d; }
257 inline void inc_warp_delta( long int d ) { warp_delta += d; }
259 inline SGTime *get_time_params() const { return time_params; }
260 inline void set_time_params( SGTime *t ) { time_params = t; }
262 inline SGEphemeris *get_ephem() const { return ephem; }
263 inline void set_ephem( SGEphemeris *e ) { ephem = e; }
265 inline SGMagVar *get_mag() const { return mag; }
266 inline void set_mag( SGMagVar *m ) { mag = m; }
268 inline SGMaterialLib *get_matlib() const { return matlib; }
269 inline void set_matlib( SGMaterialLib *m ) { matlib = m; }
271 inline FGAirportList *get_airports() const { return airports; }
272 inline void set_airports( FGAirportList *a ) {airports = a; }
274 inline FGRunwayList *get_runways() const { return runways; }
275 inline void set_runways( FGRunwayList *r ) {runways = r; }
277 inline FGATCMgr *get_ATC_mgr() const { return ATC_mgr; }
278 inline void set_ATC_mgr( FGATCMgr *a ) {ATC_mgr = a; }
280 inline FGAIMgr *get_AI_mgr() const { return AI_mgr; }
281 inline void set_AI_mgr( FGAIMgr *a ) {AI_mgr = a; }
283 inline FGPanel *get_current_panel() const { return current_panel; }
284 inline void set_current_panel( FGPanel *cp ) { current_panel = cp; }
286 inline SGSoundMgr *get_soundmgr() const { return soundmgr; }
287 inline void set_soundmgr( SGSoundMgr *sm ) { soundmgr = sm; }
289 inline FGControls *get_controls() const { return controls; }
290 inline void set_controls( FGControls *c ) { controls = c; }
292 inline FGViewMgr *get_viewmgr() const { return viewmgr; }
293 inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
294 FGViewer *get_current_view() const;
296 inline SGPropertyNode *get_props () { return props; }
297 inline void set_props( SGPropertyNode *n ) { props = n; }
299 inline SGPropertyNode *get_locale () { return locale; }
300 inline void set_locale( SGPropertyNode *n ) { locale = n; }
302 inline SGCommandMgr *get_commands () { return commands; }
304 inline FGAircraftModel *get_aircraft_model () { return acmodel; }
306 inline void set_aircraft_model (FGAircraftModel * model)
311 inline FGModelMgr *get_model_mgr () { return model_mgr; }
313 inline void set_model_mgr (FGModelMgr * mgr)
318 inline FGMultiplayMgr *get_multiplayer_mgr () { return multiplayer_mgr; }
320 inline void set_multiplayer_mgr (FGMultiplayMgr * mgr)
322 multiplayer_mgr = mgr;
325 inline string_list *get_channel_options_list () {
326 return channel_options_list;
328 inline void set_channel_options_list( string_list *l ) {
329 channel_options_list = l;
332 inline string_list *get_initial_waypoints () {
333 return initial_waypoints;
336 inline void set_initial_waypoints (string_list *list) {
337 initial_waypoints = list;
340 inline FGScenery * get_scenery () const { return scenery; }
341 inline void set_scenery ( FGScenery *s ) { scenery = s; }
343 inline FGTileMgr * get_tile_mgr () const { return tile_mgr; }
344 inline void set_tile_mgr ( FGTileMgr *t ) { tile_mgr = t; }
346 inline FGIO* get_io() const { return io; }
347 inline FGFontCache *get_fontcache() const { return fontcache; }
349 inline FGNavList *get_navlist() const { return navlist; }
350 inline void set_navlist( FGNavList *n ) { navlist = n; }
351 inline FGNavList *get_loclist() const { return loclist; }
352 inline void set_loclist( FGNavList *n ) { loclist = n; }
353 inline FGNavList *get_gslist() const { return gslist; }
354 inline void set_gslist( FGNavList *n ) { gslist = n; }
355 inline FGNavList *get_dmelist() const { return dmelist; }
356 inline void set_dmelist( FGNavList *n ) { dmelist = n; }
357 inline FGNavList *get_tacanlist() const { return tacanlist; }
358 inline void set_tacanlist( FGNavList *n ) { tacanlist = n; }
359 inline FGNavList *get_carrierlist() const { return carrierlist; }
360 inline void set_carrierlist( FGNavList *n ) { carrierlist = n; }
361 inline FGNavList *get_mkrlist() const { return mkrlist; }
362 inline void set_mkrlist( FGNavList *n ) { mkrlist = n; }
363 inline FGFixList *get_fixlist() const { return fixlist; }
364 inline void set_fixlist( FGFixList *f ) { fixlist = f; }
365 inline FGTACANList *get_channellist() const { return channellist; }
366 inline void set_channellist( FGTACANList *c ) { channellist = c; }
368 inline FGAirwayNetwork *get_airwaynet() const { return airwaynet; }
369 inline void set_airwaynet( FGAirwayNetwork *a ) { airwaynet = a; }
373 * Save the current state as the initial state.
375 void saveInitialState ();
379 * Restore the saved initial state, if any.
381 void restoreInitialState ();
386 extern FGGlobals *globals;
389 #endif // _GLOBALS_HXX