]> git.mxchange.org Git - flightgear.git/blob - src/Main/globals.hxx
- implement progress information (enabled by default; can be turned off via
[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., 675 Mass Ave, Cambridge, MA 02139, 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 SGModelLib;
61 class SGPropertyNode;
62 class SGTime;
63 class SGSoundMgr;
64
65
66 class FGAirportList;
67 class FGRunwayList;
68 class FGAIMgr;
69 class FGATCMgr;
70 class FGATCDisplay;
71 class FGAircraftModel;
72 class FGControls;
73 class FGFlightPlanDispatcher;
74 class FGIO;
75 class FGNavList;
76 class FGFixList;
77 class FGLight;
78 class FGModelMgr;
79 class FGRouteMgr;
80 class FGScenery;
81 #ifdef FG_MPLAYER_AS
82 class FGMultiplayRxMgr;
83 class FGMultiplayTxMgr;
84 #endif
85 class FGPanel;
86 class FGTileMgr;
87 class FGViewMgr;
88 class FGViewer;
89 class FGRenderer;
90
91
92 /**
93  * Bucket for subsystem pointers representing the sim's state.
94  */
95
96 class FGGlobals
97 {
98
99 private:
100
101     FGRenderer *renderer;
102     SGSubsystemMgr *subsystem_mgr;
103     SGEventMgr *event_mgr;
104
105     // Number of milliseconds elapsed since the start of the program.
106     double sim_time_sec;
107
108     // Root of FlightGear data tree
109     string fg_root;
110
111     // Roots of FlightGear scenery tree
112     string_list fg_scenery;
113
114     // Fullscreen mode for old 3DFX cards.
115 #if defined(FX) && defined(XMESA)
116     bool fullscreen;
117 #endif
118
119     // An offset in seconds from the true time.  Allows us to adjust
120     // the effective time of day.
121     long int warp;
122
123     // How much to change the value of warp each iteration.  Allows us
124     // to make time progress faster than normal (or even run in reverse.)
125     long int warp_delta;
126
127     // Time structure
128     SGTime *time_params;
129
130     // Sky structures
131     SGEphemeris *ephem;
132
133     // Magnetic Variation
134     SGMagVar *mag;
135
136     // Material properties library
137     SGMaterialLib *matlib;
138
139     // Global autopilot "route"
140     FGRouteMgr *route_mgr;
141
142     // 2D panel
143     FGPanel *current_panel;
144
145     // sound manager
146     SGSoundMgr *soundmgr;
147
148     // Simple Airport List
149     FGAirportList *airports;
150
151     // Runway List
152     FGRunwayList *runways;
153
154     // ATC manager
155     FGATCMgr *ATC_mgr;
156
157     // ATC Renderer
158     FGATCDisplay *ATC_display;
159
160     // AI manager
161     FGAIMgr *AI_mgr;
162
163     // control input state
164     FGControls *controls;
165
166     // viewer manager
167     FGViewMgr *viewmgr;
168
169     // properties
170     SGPropertyNode *props;
171     SGPropertyNode *initial_state;
172
173     // localization
174     SGPropertyNode *locale;
175
176     SGCommandMgr *commands;
177
178     SGModelLib *model_lib;
179
180   //FGFlightPlanDispatcher *fpDispatcher;
181
182     FGAircraftModel *acmodel;
183
184     FGModelMgr * model_mgr;
185
186     // list of serial port-like configurations
187     string_list *channel_options_list;
188
189     // A list of initial waypoints that are read from the command line
190     // and or flight-plan file during initialization
191     string_list *initial_waypoints;
192
193     // FlightGear scenery manager
194     FGScenery *scenery;
195
196     // Tile manager
197     FGTileMgr *tile_mgr;
198
199     // Input/Ouput subsystem
200     FGIO *io;
201
202     // Navigational Aids
203     FGNavList *navlist;
204     FGNavList *loclist;
205     FGNavList *gslist;
206     FGNavList *dmelist;
207     FGNavList *mkrlist;
208     FGFixList *fixlist;
209
210 #ifdef FG_MPLAYER_AS
211     //Mulitplayer managers
212     FGMultiplayTxMgr *multiplayer_tx_mgr;
213
214     FGMultiplayRxMgr *multiplayer_rx_mgr;
215 #endif
216
217 public:
218
219     FGGlobals();
220     virtual ~FGGlobals();
221
222     virtual FGRenderer *get_renderer () const;
223
224     virtual SGSubsystemMgr *get_subsystem_mgr () const;
225
226     virtual SGSubsystem *get_subsystem (const char * name);
227
228     virtual void add_subsystem (const char * name,
229                                 SGSubsystem * subsystem,
230                                 SGSubsystemMgr::GroupType
231                                 type = SGSubsystemMgr::GENERAL,
232                                 double min_time_sec = 0);
233
234     virtual SGEventMgr *get_event_mgr () const;
235
236     inline double get_sim_time_sec () const { return sim_time_sec; }
237     inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
238     inline void set_sim_time_sec (double t) { sim_time_sec = t; }
239
240     inline const string &get_fg_root () const { return fg_root; }
241     void set_fg_root (const string &root);
242
243     inline const string_list &get_fg_scenery () const { return fg_scenery; }
244     void set_fg_scenery (const string &scenery);
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 FGATCDisplay *get_ATC_display() const { return ATC_display; }
281     inline void set_ATC_display( FGATCDisplay *d ) {ATC_display = d; }
282
283     inline FGAIMgr *get_AI_mgr() const { return AI_mgr; }
284     inline void set_AI_mgr( FGAIMgr *a ) {AI_mgr = a; }
285
286     inline FGPanel *get_current_panel() const { return current_panel; }
287     inline void set_current_panel( FGPanel *cp ) { current_panel = cp; }
288
289     inline SGSoundMgr *get_soundmgr() const { return soundmgr; }
290     inline void set_soundmgr( SGSoundMgr *sm ) { soundmgr = sm; }
291
292     inline FGControls *get_controls() const { return controls; }
293     inline void set_controls( FGControls *c ) { controls = c; }
294
295     inline FGViewMgr *get_viewmgr() const { return viewmgr; }
296     inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
297     FGViewer *get_current_view() const;
298
299     inline SGPropertyNode *get_props () { return props; }
300     inline void set_props( SGPropertyNode *n ) { props = n; }
301
302     inline SGPropertyNode *get_locale () { return locale; }
303     inline void set_locale( SGPropertyNode *n ) { locale = n; }
304
305     inline SGCommandMgr *get_commands () { return commands; }
306
307     inline SGModelLib * get_model_lib () { return model_lib; }
308
309     inline void set_model_lib (SGModelLib *m) {
310         model_lib = m;
311     }
312
313     inline FGAircraftModel *get_aircraft_model () { return acmodel; }
314
315     inline void set_aircraft_model (FGAircraftModel * model)
316     {
317         acmodel = model;
318     }
319
320     inline FGModelMgr *get_model_mgr () { return model_mgr; }
321
322     inline void set_model_mgr (FGModelMgr * mgr)
323     {
324       model_mgr = mgr;
325     }
326
327 #ifdef FG_MPLAYER_AS
328     inline FGMultiplayTxMgr *get_multiplayer_tx_mgr () { return multiplayer_tx_mgr; }
329
330     inline void set_multiplayer_tx_mgr (FGMultiplayTxMgr * mgr)
331     {
332       multiplayer_tx_mgr = mgr;
333     }
334
335     inline FGMultiplayRxMgr *get_multiplayer_rx_mgr () { return multiplayer_rx_mgr; }
336
337     inline void set_multiplayer_rx_mgr (FGMultiplayRxMgr * mgr)
338     {
339       multiplayer_rx_mgr = mgr;
340     }
341 #endif
342
343     inline string_list *get_channel_options_list () {
344         return channel_options_list;
345     }
346     inline void set_channel_options_list( string_list *l ) {
347         channel_options_list = l;
348     }
349
350     inline string_list *get_initial_waypoints () {
351         return initial_waypoints;
352     }
353   
354     inline void set_initial_waypoints (string_list *list) {
355         initial_waypoints = list;
356     }
357
358     inline FGScenery * get_scenery () const { return scenery; }
359     inline void set_scenery ( FGScenery *s ) { scenery = s; }
360
361     inline FGTileMgr * get_tile_mgr () const { return tile_mgr; }
362     inline void set_tile_mgr ( FGTileMgr *t ) { tile_mgr = t; }
363
364     inline FGIO* get_io() const { return io; }
365
366     inline FGNavList *get_navlist() const { return navlist; }
367     inline void set_navlist( FGNavList *n ) { navlist = n; }
368     inline FGNavList *get_loclist() const { return loclist; }
369     inline void set_loclist( FGNavList *n ) { loclist = n; }
370     inline FGNavList *get_gslist() const { return gslist; }
371     inline void set_gslist( FGNavList *n ) { gslist = n; }
372     inline FGNavList *get_dmelist() const { return dmelist; }
373     inline void set_dmelist( FGNavList *n ) { dmelist = n; }
374     inline FGNavList *get_mkrlist() const { return mkrlist; }
375     inline void set_mkrlist( FGNavList *n ) { mkrlist = n; }
376
377     inline FGFixList *get_fixlist() const { return fixlist; }
378     inline void set_fixlist( FGFixList *f ) { fixlist = f; }
379
380    /**
381      * Save the current state as the initial state.
382      */
383     void saveInitialState ();
384
385
386     /**
387      * Restore the saved initial state, if any.
388      */
389     void restoreInitialState ();
390
391 };
392
393
394 extern FGGlobals *globals;
395
396
397 #endif // _GLOBALS_HXX