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;
119 // Fullscreen mode for old 3DFX cards.
120 #if defined(FX) && defined(XMESA)
124 // An offset in seconds from the true time. Allows us to adjust
125 // the effective time of day.
128 // How much to change the value of warp each iteration. Allows us
129 // to make time progress faster than normal (or even run in reverse.)
138 // Magnetic Variation
141 // Material properties library
142 SGMaterialLib *matlib;
144 // Global autopilot "route"
145 FGRouteMgr *route_mgr;
148 FGPanel *current_panel;
151 SGSoundMgr *soundmgr;
153 // Simple Airport List
154 FGAirportList *airports;
157 FGRunwayList *runways;
165 // control input state
166 FGControls *controls;
171 SGCommandMgr *commands;
173 //FGFlightPlanDispatcher *fpDispatcher;
175 FGAircraftModel *acmodel;
177 FGModelMgr * model_mgr;
179 // list of serial port-like configurations
180 string_list *channel_options_list;
182 // A list of initial waypoints that are read from the command line
183 // and or flight-plan file during initialization
184 string_list *initial_waypoints;
186 // FlightGear scenery manager
192 // Input/Ouput subsystem
195 FGFontCache *fontcache;
203 FGNavList *tacanlist;
204 FGNavList *carrierlist;
205 FGTACANList *channellist;
207 FGAirwayNetwork *airwaynet;
209 //Mulitplayer managers
210 FGMultiplayMgr *multiplayer_mgr;
215 virtual ~FGGlobals();
217 virtual FGRenderer *get_renderer () const;
219 virtual SGSubsystemMgr *get_subsystem_mgr () const;
221 virtual SGSubsystem *get_subsystem (const char * name);
223 virtual void add_subsystem (const char * name,
224 SGSubsystem * subsystem,
225 SGSubsystemMgr::GroupType
226 type = SGSubsystemMgr::GENERAL,
227 double min_time_sec = 0);
229 virtual SGEventMgr *get_event_mgr () const;
231 inline double get_sim_time_sec () const { return sim_time_sec; }
232 inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
233 inline void set_sim_time_sec (double t) { sim_time_sec = t; }
235 inline const string &get_fg_root () const { return fg_root; }
236 void set_fg_root (const string &root);
238 inline const string_list &get_fg_scenery () const { return fg_scenery; }
239 void set_fg_scenery (const string &scenery);
241 #if defined(FX) && defined(XMESA)
242 inline bool get_fullscreen() const { return fullscreen; }
243 inline bool set_fullscreen( bool f ) { fullscreen = f; }
246 inline long int get_warp() const { return warp; }
247 inline void set_warp( long int w ) { warp = w; }
248 inline void inc_warp( long int w ) { warp += w; }
250 inline long int get_warp_delta() const { return warp_delta; }
251 inline void set_warp_delta( long int d ) { warp_delta = d; }
252 inline void inc_warp_delta( long int d ) { warp_delta += d; }
254 inline SGTime *get_time_params() const { return time_params; }
255 inline void set_time_params( SGTime *t ) { time_params = t; }
257 inline SGEphemeris *get_ephem() const { return ephem; }
258 inline void set_ephem( SGEphemeris *e ) { ephem = e; }
260 inline SGMagVar *get_mag() const { return mag; }
261 inline void set_mag( SGMagVar *m ) { mag = m; }
263 inline SGMaterialLib *get_matlib() const { return matlib; }
264 inline void set_matlib( SGMaterialLib *m ) { matlib = m; }
266 inline FGAirportList *get_airports() const { return airports; }
267 inline void set_airports( FGAirportList *a ) {airports = a; }
269 inline FGRunwayList *get_runways() const { return runways; }
270 inline void set_runways( FGRunwayList *r ) {runways = r; }
272 inline FGATCMgr *get_ATC_mgr() const { return ATC_mgr; }
273 inline void set_ATC_mgr( FGATCMgr *a ) {ATC_mgr = a; }
275 inline FGAIMgr *get_AI_mgr() const { return AI_mgr; }
276 inline void set_AI_mgr( FGAIMgr *a ) {AI_mgr = a; }
278 inline FGPanel *get_current_panel() const { return current_panel; }
279 inline void set_current_panel( FGPanel *cp ) { current_panel = cp; }
281 inline SGSoundMgr *get_soundmgr() const { return soundmgr; }
282 inline void set_soundmgr( SGSoundMgr *sm ) { soundmgr = sm; }
284 inline FGControls *get_controls() const { return controls; }
285 inline void set_controls( FGControls *c ) { controls = c; }
287 inline FGViewMgr *get_viewmgr() const { return viewmgr; }
288 inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
289 FGViewer *get_current_view() const;
291 inline SGPropertyNode *get_props () { return props; }
292 inline void set_props( SGPropertyNode *n ) { props = n; }
294 inline SGPropertyNode *get_locale () { return locale; }
295 inline void set_locale( SGPropertyNode *n ) { locale = n; }
297 inline SGCommandMgr *get_commands () { return commands; }
299 inline FGAircraftModel *get_aircraft_model () { return acmodel; }
301 inline void set_aircraft_model (FGAircraftModel * model)
306 inline FGModelMgr *get_model_mgr () { return model_mgr; }
308 inline void set_model_mgr (FGModelMgr * mgr)
313 inline FGMultiplayMgr *get_multiplayer_mgr () { return multiplayer_mgr; }
315 inline void set_multiplayer_mgr (FGMultiplayMgr * mgr)
317 multiplayer_mgr = mgr;
320 inline string_list *get_channel_options_list () {
321 return channel_options_list;
323 inline void set_channel_options_list( string_list *l ) {
324 channel_options_list = l;
327 inline string_list *get_initial_waypoints () {
328 return initial_waypoints;
331 inline void set_initial_waypoints (string_list *list) {
332 initial_waypoints = list;
335 inline FGScenery * get_scenery () const { return scenery; }
336 inline void set_scenery ( FGScenery *s ) { scenery = s; }
338 inline FGTileMgr * get_tile_mgr () const { return tile_mgr; }
339 inline void set_tile_mgr ( FGTileMgr *t ) { tile_mgr = t; }
341 inline FGIO* get_io() const { return io; }
342 inline FGFontCache *get_fontcache() const { return fontcache; }
344 inline FGNavList *get_navlist() const { return navlist; }
345 inline void set_navlist( FGNavList *n ) { navlist = n; }
346 inline FGNavList *get_loclist() const { return loclist; }
347 inline void set_loclist( FGNavList *n ) { loclist = n; }
348 inline FGNavList *get_gslist() const { return gslist; }
349 inline void set_gslist( FGNavList *n ) { gslist = n; }
350 inline FGNavList *get_dmelist() const { return dmelist; }
351 inline void set_dmelist( FGNavList *n ) { dmelist = n; }
352 inline FGNavList *get_tacanlist() const { return tacanlist; }
353 inline void set_tacanlist( FGNavList *n ) { tacanlist = n; }
354 inline FGNavList *get_carrierlist() const { return carrierlist; }
355 inline void set_carrierlist( FGNavList *n ) { carrierlist = n; }
356 inline FGNavList *get_mkrlist() const { return mkrlist; }
357 inline void set_mkrlist( FGNavList *n ) { mkrlist = n; }
358 inline FGFixList *get_fixlist() const { return fixlist; }
359 inline void set_fixlist( FGFixList *f ) { fixlist = f; }
360 inline FGTACANList *get_channellist() const { return channellist; }
361 inline void set_channellist( FGTACANList *c ) { channellist = c; }
363 inline FGAirwayNetwork *get_airwaynet() const { return airwaynet; }
364 inline void set_airwaynet( FGAirwayNetwork *a ) { airwaynet = a; }
368 * Save the current state as the initial state.
370 void saveInitialState ();
374 * Restore the saved initial state, if any.
376 void restoreInitialState ();
381 extern FGGlobals *globals;
384 #endif // _GLOBALS_HXX