]> git.mxchange.org Git - flightgear.git/blob - src/Main/globals.hxx
Add the alpha test back in so the instruments won't disappear after changing the...
[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 #include <simgear/compiler.h>
28 #include <simgear/props/props.hxx>
29 #include <simgear/structure/subsystem_mgr.hxx>
30
31 #include <vector>
32 #include <string>
33
34 typedef std::vector<std::string> string_list;
35
36 // Forward declarations
37
38 // This file is included, directly or indirectly, almost everywhere in
39 // FlightGear, so if any of its dependencies changes, most of the sim
40 // has to be recompiled.  Using these forward declarations helps us to
41 // avoid including a lot of header files (and thus, a lot of
42 // dependencies).  Since Most of the methods simply set or return
43 // pointers, we don't need to know anything about the class details
44 // anyway.
45
46 class SGEphemeris;
47 class SGCommandMgr;
48 class SGMagVar;
49 class SGMaterialLib;
50 class SGPropertyNode;
51 class SGTime;
52 class SGSoundMgr;
53 class SGEventMgr;
54 class SGSubsystemMgr;
55 class SGSubsystem;
56
57 class FGAirportList;
58 class FGAIMgr;
59 class FGATCMgr;
60 class FGAircraftModel;
61 class FGControls;
62 class FGFlightPlanDispatcher;
63 class FGIO;
64 class FGNavList;
65 class FGAirwayNetwork;
66 class FGTACANList;
67 class FGFixList;
68 class FGLight;
69 class FGModelMgr;
70 class FGRouteMgr;
71 class FGScenery;
72 class FGMultiplayMgr;
73 class FGPanel;
74 class FGTileMgr;
75 class FGViewMgr;
76 class FGViewer;
77 class FGRenderer;
78 class FGFontCache;
79
80
81 /**
82  * Bucket for subsystem pointers representing the sim's state.
83  */
84
85 class FGGlobals
86 {
87
88 private:
89
90     // properties, destroy last
91     SGPropertyNode_ptr props;
92     SGPropertyNode_ptr initial_state;
93
94     // localization
95     SGPropertyNode_ptr locale;
96
97     FGRenderer *renderer;
98     SGSubsystemMgr *subsystem_mgr;
99     SGEventMgr *event_mgr;
100
101     // Number of milliseconds elapsed since the start of the program.
102     double sim_time_sec;
103
104     // Root of FlightGear data tree
105     std::string fg_root;
106
107     // Roots of FlightGear scenery tree
108     string_list fg_scenery;
109
110     std::string browser;
111
112     // An offset in seconds from the true time.  Allows us to adjust
113     // the effective time of day.
114     long int warp;
115
116     // How much to change the value of warp each iteration.  Allows us
117     // to make time progress faster than normal (or even run in reverse.)
118     long int warp_delta;
119
120     // Time structure
121     SGTime *time_params;
122
123     // Sky structures
124     SGEphemeris *ephem;
125
126     // Magnetic Variation
127     SGMagVar *mag;
128
129     // Material properties library
130     SGMaterialLib *matlib;
131
132     // Global autopilot "route"
133     FGRouteMgr *route_mgr;
134
135     // 2D panel
136     FGPanel *current_panel;
137
138     // sound manager
139     SGSoundMgr *soundmgr;
140
141     // Simple Airport List
142     FGAirportList *airports;
143
144     // ATC manager
145     FGATCMgr *ATC_mgr;
146
147     // AI manager
148     FGAIMgr *AI_mgr;
149
150     // control input state
151     FGControls *controls;
152
153     // viewer manager
154     FGViewMgr *viewmgr;
155
156     SGCommandMgr *commands;
157
158   //FGFlightPlanDispatcher *fpDispatcher;
159
160     FGAircraftModel *acmodel;
161
162     FGModelMgr * model_mgr;
163
164     // list of serial port-like configurations
165     string_list *channel_options_list;
166
167     // A list of initial waypoints that are read from the command line
168     // and or flight-plan file during initialization
169     string_list *initial_waypoints;
170
171     // FlightGear scenery manager
172     FGScenery *scenery;
173
174     // Tile manager
175     FGTileMgr *tile_mgr;
176
177     // Input/Ouput subsystem
178     FGIO *io;
179
180     FGFontCache *fontcache;
181
182     // Navigational Aids
183     FGNavList *navlist;
184     FGNavList *loclist;
185     FGNavList *gslist;
186     FGNavList *dmelist;
187     FGNavList *mkrlist;
188     FGNavList *tacanlist;
189     FGNavList *carrierlist;
190     FGTACANList *channellist;
191     FGFixList *fixlist;
192     FGAirwayNetwork *airwaynet;
193
194     //Mulitplayer managers
195     FGMultiplayMgr *multiplayer_mgr;
196
197 public:
198
199     FGGlobals();
200     virtual ~FGGlobals();
201
202     virtual FGRenderer *get_renderer () const;
203
204     virtual SGSubsystemMgr *get_subsystem_mgr () const;
205
206     virtual SGSubsystem *get_subsystem (const char * name);
207
208     virtual void add_subsystem (const char * name,
209                                 SGSubsystem * subsystem,
210                                 SGSubsystemMgr::GroupType
211                                 type = SGSubsystemMgr::GENERAL,
212                                 double min_time_sec = 0);
213
214     virtual SGEventMgr *get_event_mgr () const;
215
216     inline double get_sim_time_sec () const { return sim_time_sec; }
217     inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
218     inline void set_sim_time_sec (double t) { sim_time_sec = t; }
219
220     inline const std::string &get_fg_root () const { return fg_root; }
221     void set_fg_root (const std::string &root);
222
223     inline const string_list &get_fg_scenery () const { return fg_scenery; }
224     void set_fg_scenery (const std::string &scenery);
225
226     inline const std::string &get_browser () const { return browser; }
227     void set_browser (const std::string &b) { browser = b; }
228
229     inline long int get_warp() const { return warp; }
230     inline void set_warp( long int w ) { warp = w; }
231     inline void inc_warp( long int w ) { warp += w; }
232
233     inline long int get_warp_delta() const { return warp_delta; }
234     inline void set_warp_delta( long int d ) { warp_delta = d; }
235     inline void inc_warp_delta( long int d ) { warp_delta += d; }
236
237     inline SGTime *get_time_params() const { return time_params; }
238     inline void set_time_params( SGTime *t ) { time_params = t; }
239
240     inline SGEphemeris *get_ephem() const { return ephem; }
241     inline void set_ephem( SGEphemeris *e ) { ephem = e; }
242
243     inline SGMagVar *get_mag() const { return mag; }
244     inline void set_mag( SGMagVar *m ) { mag = m; }
245
246     inline SGMaterialLib *get_matlib() const { return matlib; }
247     inline void set_matlib( SGMaterialLib *m ) { matlib = m; }
248
249     inline FGAirportList *get_airports() const { return airports; }
250     inline void set_airports( FGAirportList *a ) {airports = a; }
251
252     inline FGATCMgr *get_ATC_mgr() const { return ATC_mgr; }
253     inline void set_ATC_mgr( FGATCMgr *a ) {ATC_mgr = a; }
254
255     inline FGAIMgr *get_AI_mgr() const { return AI_mgr; }
256     inline void set_AI_mgr( FGAIMgr *a ) {AI_mgr = a; }
257
258     inline FGPanel *get_current_panel() const { return current_panel; }
259     inline void set_current_panel( FGPanel *cp ) { current_panel = cp; }
260
261     inline SGSoundMgr *get_soundmgr() const { return soundmgr; }
262     inline void set_soundmgr( SGSoundMgr *sm ) { soundmgr = sm; }
263
264     inline FGControls *get_controls() const { return controls; }
265     inline void set_controls( FGControls *c ) { controls = c; }
266
267     inline FGViewMgr *get_viewmgr() const { return viewmgr; }
268     inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
269     FGViewer *get_current_view() const;
270
271     inline SGPropertyNode *get_props () { return props; }
272     inline void set_props( SGPropertyNode *n ) { props = n; }
273
274     inline SGPropertyNode *get_locale () { return locale; }
275     inline void set_locale( SGPropertyNode *n ) { locale = n; }
276
277     inline SGCommandMgr *get_commands () { return commands; }
278
279     inline FGAircraftModel *get_aircraft_model () { return acmodel; }
280
281     inline void set_aircraft_model (FGAircraftModel * model)
282     {
283         acmodel = model;
284     }
285
286     inline FGModelMgr *get_model_mgr () { return model_mgr; }
287
288     inline void set_model_mgr (FGModelMgr * mgr)
289     {
290       model_mgr = mgr;
291     }
292
293     inline FGMultiplayMgr *get_multiplayer_mgr () { return multiplayer_mgr; }
294
295     inline void set_multiplayer_mgr (FGMultiplayMgr * mgr)
296     {
297       multiplayer_mgr = mgr;
298     }
299
300     inline string_list *get_channel_options_list () {
301         return channel_options_list;
302     }
303     inline void set_channel_options_list( string_list *l ) {
304         channel_options_list = l;
305     }
306
307     inline string_list *get_initial_waypoints () {
308         return initial_waypoints;
309     }
310   
311     inline void set_initial_waypoints (string_list *list) {
312         initial_waypoints = list;
313     }
314
315     inline FGScenery * get_scenery () const { return scenery; }
316     inline void set_scenery ( FGScenery *s ) { scenery = s; }
317
318     inline FGTileMgr * get_tile_mgr () const { return tile_mgr; }
319     inline void set_tile_mgr ( FGTileMgr *t ) { tile_mgr = t; }
320
321     inline FGIO* get_io() const { return io; }
322     inline FGFontCache *get_fontcache() const { return fontcache; }
323     
324     inline FGNavList *get_navlist() const { return navlist; }
325     inline void set_navlist( FGNavList *n ) { navlist = n; }
326     inline FGNavList *get_loclist() const { return loclist; }
327     inline void set_loclist( FGNavList *n ) { loclist = n; }
328     inline FGNavList *get_gslist() const { return gslist; }
329     inline void set_gslist( FGNavList *n ) { gslist = n; }
330     inline FGNavList *get_dmelist() const { return dmelist; }
331     inline void set_dmelist( FGNavList *n ) { dmelist = n; }
332     inline FGNavList *get_tacanlist() const { return tacanlist; }
333     inline void set_tacanlist( FGNavList *n ) { tacanlist = n; }
334     inline FGNavList *get_carrierlist() const { return carrierlist; }
335     inline void set_carrierlist( FGNavList *n ) { carrierlist = n; }
336     inline FGNavList *get_mkrlist() const { return mkrlist; }
337     inline void set_mkrlist( FGNavList *n ) { mkrlist = n; }
338     inline FGFixList *get_fixlist() const { return fixlist; }
339     inline void set_fixlist( FGFixList *f ) { fixlist = f; }
340     inline FGTACANList *get_channellist() const { return channellist; }
341     inline void set_channellist( FGTACANList *c ) { channellist = c; }
342
343     inline FGAirwayNetwork *get_airwaynet() const { return airwaynet; }
344     inline void set_airwaynet( FGAirwayNetwork *a ) { airwaynet = a; }
345
346
347    /**
348      * Save the current state as the initial state.
349      */
350     void saveInitialState ();
351
352
353     /**
354      * Restore the saved initial state, if any.
355      */
356     void restoreInitialState ();
357
358 };
359
360
361 extern FGGlobals *globals;
362
363
364 #endif // _GLOBALS_HXX