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