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