]> git.mxchange.org Git - flightgear.git/blob - src/Main/globals.hxx
0d830b3bb7ada01763d25fae814cc5dfe8c86ba0
[flightgear.git] / src / Main / globals.hxx
1 // globals.hxx -- Global state that needs to be shared among the sim modules
2 //
3 // Written by Curtis Olson, started July 2000.
4 //
5 // Copyright (C) 2000  Curtis L. Olson - http://www.flightgear.org/~curt
6 //
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.
11 //
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.
16 //
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.
20 //
21 // $Id$
22
23
24 #ifndef _GLOBALS_HXX
25 #define _GLOBALS_HXX
26
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif
30
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>
35
36 #include <vector>
37 #include STL_STRING
38
39 SG_USING_STD( vector );
40 SG_USING_STD( string );
41
42 typedef vector<string> string_list;
43
44
45 // Forward declarations
46
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
53 // anyway.
54
55 class SGEphemeris;
56
57 class SGCommandMgr;
58 class SGMagVar;
59 class SGMaterialLib;
60 class SGPropertyNode;
61 class SGTime;
62 class SGSoundMgr;
63
64
65 class FGAirportList;
66 class FGRunwayList;
67 class FGAIMgr;
68 class FGATCMgr;
69 class FGAircraftModel;
70 class FGControls;
71 class FGFlightPlanDispatcher;
72 class FGIO;
73 class FGNavList;
74 class FGAirwayNetwork;
75 class FGTACANList;
76 class FGFixList;
77 class FGLight;
78 class FGModelMgr;
79 class FGRouteMgr;
80 class FGScenery;
81 class FGMultiplayMgr;
82 class FGPanel;
83 class FGTileMgr;
84 class FGViewMgr;
85 class FGViewer;
86 class FGRenderer;
87 class FGFontCache;
88
89
90 /**
91  * Bucket for subsystem pointers representing the sim's state.
92  */
93
94 class FGGlobals
95 {
96
97 private:
98
99     // properties, destroy last
100     SGPropertyNode_ptr props;
101     SGPropertyNode_ptr initial_state;
102
103     // localization
104     SGPropertyNode_ptr locale;
105
106     FGRenderer *renderer;
107     SGSubsystemMgr *subsystem_mgr;
108     SGEventMgr *event_mgr;
109
110     // Number of milliseconds elapsed since the start of the program.
111     double sim_time_sec;
112
113     // Root of FlightGear data tree
114     string fg_root;
115
116     // Roots of FlightGear scenery tree
117     string_list fg_scenery;
118
119     string browser;
120
121     // Fullscreen mode for old 3DFX cards.
122 #if defined(FX) && defined(XMESA)
123     bool fullscreen;
124 #endif
125
126     // An offset in seconds from the true time.  Allows us to adjust
127     // the effective time of day.
128     long int warp;
129
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.)
132     long int warp_delta;
133
134     // Time structure
135     SGTime *time_params;
136
137     // Sky structures
138     SGEphemeris *ephem;
139
140     // Magnetic Variation
141     SGMagVar *mag;
142
143     // Material properties library
144     SGMaterialLib *matlib;
145
146     // Global autopilot "route"
147     FGRouteMgr *route_mgr;
148
149     // 2D panel
150     FGPanel *current_panel;
151
152     // sound manager
153     SGSoundMgr *soundmgr;
154
155     // Simple Airport List
156     FGAirportList *airports;
157
158     // Runway List
159     FGRunwayList *runways;
160
161     // ATC manager
162     FGATCMgr *ATC_mgr;
163
164     // AI manager
165     FGAIMgr *AI_mgr;
166
167     // control input state
168     FGControls *controls;
169
170     // viewer manager
171     FGViewMgr *viewmgr;
172
173     SGCommandMgr *commands;
174
175   //FGFlightPlanDispatcher *fpDispatcher;
176
177     FGAircraftModel *acmodel;
178
179     FGModelMgr * model_mgr;
180
181     // list of serial port-like configurations
182     string_list *channel_options_list;
183
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;
187
188     // FlightGear scenery manager
189     FGScenery *scenery;
190
191     // Tile manager
192     FGTileMgr *tile_mgr;
193
194     // Input/Ouput subsystem
195     FGIO *io;
196
197     FGFontCache *fontcache;
198
199     // Navigational Aids
200     FGNavList *navlist;
201     FGNavList *loclist;
202     FGNavList *gslist;
203     FGNavList *dmelist;
204     FGNavList *mkrlist;
205     FGNavList *tacanlist;
206     FGNavList *carrierlist;
207     FGTACANList *channellist;
208     FGFixList *fixlist;
209     FGAirwayNetwork *airwaynet;
210
211     //Mulitplayer managers
212     FGMultiplayMgr *multiplayer_mgr;
213
214 public:
215
216     FGGlobals();
217     virtual ~FGGlobals();
218
219     virtual FGRenderer *get_renderer () const;
220
221     virtual SGSubsystemMgr *get_subsystem_mgr () const;
222
223     virtual SGSubsystem *get_subsystem (const char * name);
224
225     virtual void add_subsystem (const char * name,
226                                 SGSubsystem * subsystem,
227                                 SGSubsystemMgr::GroupType
228                                 type = SGSubsystemMgr::GENERAL,
229                                 double min_time_sec = 0);
230
231     virtual SGEventMgr *get_event_mgr () const;
232
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; }
236
237     inline const string &get_fg_root () const { return fg_root; }
238     void set_fg_root (const string &root);
239
240     inline const string_list &get_fg_scenery () const { return fg_scenery; }
241     void set_fg_scenery (const string &scenery);
242
243     inline const string &get_browser () const { return browser; }
244     void set_browser (const string &b) { browser = b; }
245
246 #if defined(FX) && defined(XMESA)
247     inline bool get_fullscreen() const { return fullscreen; }
248     inline bool set_fullscreen( bool f ) { fullscreen = f; }
249 #endif
250
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; }
254
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; }
258
259     inline SGTime *get_time_params() const { return time_params; }
260     inline void set_time_params( SGTime *t ) { time_params = t; }
261
262     inline SGEphemeris *get_ephem() const { return ephem; }
263     inline void set_ephem( SGEphemeris *e ) { ephem = e; }
264
265     inline SGMagVar *get_mag() const { return mag; }
266     inline void set_mag( SGMagVar *m ) { mag = m; }
267
268     inline SGMaterialLib *get_matlib() const { return matlib; }
269     inline void set_matlib( SGMaterialLib *m ) { matlib = m; }
270
271     inline FGAirportList *get_airports() const { return airports; }
272     inline void set_airports( FGAirportList *a ) {airports = a; }
273
274     inline FGRunwayList *get_runways() const { return runways; }
275     inline void set_runways( FGRunwayList *r ) {runways = r; }
276
277     inline FGATCMgr *get_ATC_mgr() const { return ATC_mgr; }
278     inline void set_ATC_mgr( FGATCMgr *a ) {ATC_mgr = a; }
279
280     inline FGAIMgr *get_AI_mgr() const { return AI_mgr; }
281     inline void set_AI_mgr( FGAIMgr *a ) {AI_mgr = a; }
282
283     inline FGPanel *get_current_panel() const { return current_panel; }
284     inline void set_current_panel( FGPanel *cp ) { current_panel = cp; }
285
286     inline SGSoundMgr *get_soundmgr() const { return soundmgr; }
287     inline void set_soundmgr( SGSoundMgr *sm ) { soundmgr = sm; }
288
289     inline FGControls *get_controls() const { return controls; }
290     inline void set_controls( FGControls *c ) { controls = c; }
291
292     inline FGViewMgr *get_viewmgr() const { return viewmgr; }
293     inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
294     FGViewer *get_current_view() const;
295
296     inline SGPropertyNode *get_props () { return props; }
297     inline void set_props( SGPropertyNode *n ) { props = n; }
298
299     inline SGPropertyNode *get_locale () { return locale; }
300     inline void set_locale( SGPropertyNode *n ) { locale = n; }
301
302     inline SGCommandMgr *get_commands () { return commands; }
303
304     inline FGAircraftModel *get_aircraft_model () { return acmodel; }
305
306     inline void set_aircraft_model (FGAircraftModel * model)
307     {
308         acmodel = model;
309     }
310
311     inline FGModelMgr *get_model_mgr () { return model_mgr; }
312
313     inline void set_model_mgr (FGModelMgr * mgr)
314     {
315       model_mgr = mgr;
316     }
317
318     inline FGMultiplayMgr *get_multiplayer_mgr () { return multiplayer_mgr; }
319
320     inline void set_multiplayer_mgr (FGMultiplayMgr * mgr)
321     {
322       multiplayer_mgr = mgr;
323     }
324
325     inline string_list *get_channel_options_list () {
326         return channel_options_list;
327     }
328     inline void set_channel_options_list( string_list *l ) {
329         channel_options_list = l;
330     }
331
332     inline string_list *get_initial_waypoints () {
333         return initial_waypoints;
334     }
335   
336     inline void set_initial_waypoints (string_list *list) {
337         initial_waypoints = list;
338     }
339
340     inline FGScenery * get_scenery () const { return scenery; }
341     inline void set_scenery ( FGScenery *s ) { scenery = s; }
342
343     inline FGTileMgr * get_tile_mgr () const { return tile_mgr; }
344     inline void set_tile_mgr ( FGTileMgr *t ) { tile_mgr = t; }
345
346     inline FGIO* get_io() const { return io; }
347     inline FGFontCache *get_fontcache() const { return fontcache; }
348     
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; }
367
368     inline FGAirwayNetwork *get_airwaynet() const { return airwaynet; }
369     inline void set_airwaynet( FGAirwayNetwork *a ) { airwaynet = a; }
370
371
372    /**
373      * Save the current state as the initial state.
374      */
375     void saveInitialState ();
376
377
378     /**
379      * Restore the saved initial state, if any.
380      */
381     void restoreInitialState ();
382
383 };
384
385
386 extern FGGlobals *globals;
387
388
389 #endif // _GLOBALS_HXX