]> git.mxchange.org Git - flightgear.git/blob - src/Main/globals.hxx
e4ac10732b42d4fc39960e52a969378b25e65fb0
[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 - curt@flightgear.org
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 #include <simgear/compiler.h>
28
29 #include <vector>
30 #include STL_STRING
31
32 #include "fgfs.hxx"
33
34
35 SG_USING_STD( vector );
36 SG_USING_STD( string );
37
38 typedef vector<string> string_list;
39
40
41 // Forward declarations
42
43 // This file is included, directly or indirectly, almost everywhere in
44 // FlightGear, so if any of its dependencies changes, most of the sim
45 // has to be recompiled.  Using these forward declarations helps us to
46 // avoid including a lot of header files (and thus, a lot of
47 // dependencies).  Since Most of the methods simply set or return
48 // pointers, we don't need to know anything about the class details
49 // anyway.
50
51 class SGEphemeris;
52
53 class SGCommandMgr;
54 class SGMagVar;
55 class SGPropertyNode;
56 class SGRoute;
57 class SGTime;
58 class SoundMgr;
59
60 class FGAIMgr;
61 class FGATCMgr;
62 class FGATCDisplay;
63 class FGAircraftModel;
64 class FGAutopilot;
65 class FGControls;
66 class FGEnvironment;
67 class FGEnvironmentMgr;
68 class FGIO;
69 class FGModelLoader;
70 class FGModelMgr;
71 class FGScenery;
72 #ifdef FG_MPLAYER_AS
73 class FGMultiplayRxMgr;
74 class FGMultiplayTxMgr;
75 #endif
76 class FGPanel;
77 class FGTileMgr;
78 class FGViewMgr;
79 class FGViewer;
80
81
82 /**
83  * Bucket for subsystem pointers representing the sim's state.
84  */
85 class FGGlobals
86 {
87
88 private:
89
90     FGSubsystemMgr * subsystem_mgr;
91
92     // Number of milliseconds elapsed since the start of the program.
93     double sim_time_sec;
94
95     // Root of FlightGear data tree
96     string fg_root;
97
98     // Root of FlightGear scenery tree
99     string fg_scenery;
100
101     // Fullscreen mode for old 3DFX cards.
102 #if defined(FX) && defined(XMESA)
103     bool fullscreen;
104 #endif
105
106     // An offset in seconds from the true time.  Allows us to adjust
107     // the effective time of day.
108     long int warp;
109
110     // How much to change the value of warp each iteration.  Allows us
111     // to make time progress faster than normal (or even run in reverse.)
112     long int warp_delta;
113
114     // Time structure
115     SGTime *time_params;
116
117     // Sky structures
118     SGEphemeris *ephem;
119
120     // Magnetic Variation
121     SGMagVar *mag;
122
123     // Current autopilot
124     FGAutopilot *autopilot;
125
126     // Global autopilot "route"
127     SGRoute *route;
128
129     // 2D panel
130     FGPanel *current_panel;
131
132     // sound manager
133     SoundMgr *soundmgr;
134
135     // environment information
136     FGEnvironmentMgr * environment_mgr;
137
138     // ATC manager
139     FGATCMgr *ATC_mgr;
140
141     // ATC Renderer
142     FGATCDisplay *ATC_display;
143
144     // AI manager
145     FGAIMgr *AI_mgr;
146
147     // control input state
148     FGControls *controls;
149
150     // viewer manager
151     FGViewMgr *viewmgr;
152
153     // properties
154     SGPropertyNode *props;
155     SGPropertyNode *initial_state;
156
157     // localization
158     SGPropertyNode *locale;
159
160     SGCommandMgr *commands;
161
162     FGModelLoader * model_loader;
163
164     FGAircraftModel *acmodel;
165
166     FGModelMgr * model_mgr;
167
168     // list of serial port-like configurations
169     string_list *channel_options_list;
170
171     // FlightGear scenery manager
172     FGScenery *scenery;
173
174     // Tile manager
175     FGTileMgr *tile_mgr;
176
177     FGIO* io;
178
179 #ifdef FG_MPLAYER_AS
180     //Mulitplayer managers
181     FGMultiplayTxMgr *multiplayer_tx_mgr;
182
183     FGMultiplayRxMgr *multiplayer_rx_mgr;
184 #endif
185
186 public:
187
188     FGGlobals();
189     virtual ~FGGlobals();
190
191     virtual FGSubsystemMgr * get_subsystem_mgr () const;
192
193     virtual FGSubsystem * get_subsystem (const char * name);
194
195     virtual void add_subsystem (const char * name,
196                                 FGSubsystem * subsystem,
197                                 FGSubsystemMgr::GroupType
198                                   type = FGSubsystemMgr::GENERAL,
199                                 double min_time_sec = 0);
200
201     inline double get_sim_time_sec () const { return sim_time_sec; }
202     inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
203     inline void set_sim_time_sec (double t) { sim_time_sec = t; }
204
205     inline const string &get_fg_root () const { return fg_root; }
206     void set_fg_root (const string &root);
207
208     inline const string &get_fg_scenery () const { return fg_scenery; }
209     inline void set_fg_scenery (const string &scenery) {
210       fg_scenery = scenery;
211     }
212
213 #if defined(FX) && defined(XMESA)
214     inline bool get_fullscreen() const { return fullscreen; }
215     inline bool set_fullscreen( bool f ) { fullscreen = f; }
216 #endif
217
218     inline long int get_warp() const { return warp; }
219     inline void set_warp( long int w ) { warp = w; }
220     inline void inc_warp( long int w ) { warp += w; }
221
222     inline long int get_warp_delta() const { return warp_delta; }
223     inline void set_warp_delta( long int d ) { warp_delta = d; }
224     inline void inc_warp_delta( long int d ) { warp_delta += d; }
225
226     inline SGTime *get_time_params() const { return time_params; }
227     inline void set_time_params( SGTime *t ) { time_params = t; }
228
229     inline SGEphemeris *get_ephem() const { return ephem; }
230     inline void set_ephem( SGEphemeris *e ) { ephem = e; }
231
232     inline SGMagVar *get_mag() const { return mag; }
233     inline void set_mag( SGMagVar *m ) { mag = m; }
234
235     inline FGAutopilot *get_autopilot() const { return autopilot; }
236     inline void set_autopilot( FGAutopilot *ap) { autopilot = ap; }
237
238     inline SGRoute *get_route() const { return route; }
239     inline void set_route( SGRoute *r ) { route = r; }
240
241     inline FGEnvironmentMgr * get_environment_mgr() {
242       return environment_mgr;
243     }
244     inline void set_environment_mgr(FGEnvironmentMgr * mgr) {
245       environment_mgr = mgr;
246     }
247
248     inline FGATCMgr *get_ATC_mgr() const { return ATC_mgr; }
249     inline void set_ATC_mgr( FGATCMgr *a ) {ATC_mgr = a; }
250
251     inline FGATCDisplay *get_ATC_display() const { return ATC_display; }
252     inline void set_ATC_display( FGATCDisplay *d ) {ATC_display = d; }
253
254     inline FGAIMgr *get_AI_mgr() const { return AI_mgr; }
255     inline void set_AI_mgr( FGAIMgr *a ) {AI_mgr = a; }
256
257     inline FGPanel *get_current_panel() const { return current_panel; }
258     inline void set_current_panel( FGPanel *cp ) { current_panel = cp; }
259
260     inline SoundMgr *get_soundmgr() const { return soundmgr; }
261     inline void set_soundmgr( SoundMgr *sm ) { soundmgr = sm; }
262
263     inline FGControls *get_controls() const { return controls; }
264     inline void set_controls( FGControls *c ) { controls = c; }
265
266     inline FGViewMgr *get_viewmgr() const { return viewmgr; }
267     inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
268     FGViewer *get_current_view() const;
269
270     inline SGPropertyNode *get_props () { return props; }
271     inline void set_props( SGPropertyNode *n ) { props = n; }
272
273     inline SGPropertyNode *get_locale () { return locale; }
274     inline void set_locale( SGPropertyNode *n ) { locale = n; }
275
276     inline SGCommandMgr *get_commands () { return commands; }
277
278     inline FGModelLoader * get_model_loader () { return model_loader; }
279
280     inline void set_model_loader (FGModelLoader * loader) {
281         model_loader = loader;
282     }
283
284     inline FGAircraftModel *get_aircraft_model () { return acmodel; }
285
286     inline void set_aircraft_model (FGAircraftModel * model)
287     {
288         acmodel = model;
289     }
290
291     inline FGModelMgr *get_model_mgr () { return model_mgr; }
292
293     inline void set_model_mgr (FGModelMgr * mgr)
294     {
295       model_mgr = mgr;
296     }
297
298 #ifdef FG_MPLAYER_AS
299     inline FGMultiplayTxMgr *get_multiplayer_tx_mgr () { return multiplayer_tx_mgr; }
300
301     inline void set_multiplayer_tx_mgr (FGMultiplayTxMgr * mgr)
302     {
303       multiplayer_tx_mgr = mgr;
304     }
305
306     inline FGMultiplayRxMgr *get_multiplayer_rx_mgr () { return multiplayer_rx_mgr; }
307
308     inline void set_multiplayer_rx_mgr (FGMultiplayRxMgr * mgr)
309     {
310       multiplayer_rx_mgr = mgr;
311     }
312 #endif
313
314     inline string_list *get_channel_options_list () {
315         return channel_options_list;
316     }
317     inline void set_channel_options_list( string_list *l ) {
318         channel_options_list = l;
319     }
320
321     inline FGScenery * get_scenery () const { return scenery; }
322     inline void set_scenery ( FGScenery *s ) { scenery = s; }
323
324     inline FGTileMgr * get_tile_mgr () const { return tile_mgr; }
325     inline void set_tile_mgr ( FGTileMgr *t ) { tile_mgr = t; }
326
327     FGIO* get_io() const { return io; }
328
329
330     /**
331      * Save the current state as the initial state.
332      */
333     void saveInitialState ();
334
335
336     /**
337      * Restore the saved initial state, if any.
338      */
339     void restoreInitialState ();
340
341 };
342
343
344 extern FGGlobals *globals;
345
346
347 #endif // _GLOBALS_HXX