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