1 // globals.hxx -- Global state that needs to be shared among the sim modules
3 // Written by Curtis Olson, started July 2000.
5 // Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
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.
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.
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.
27 #include <simgear/compiler.h>
28 #include <simgear/props/props.hxx>
29 #include <simgear/structure/subsystem_mgr.hxx>
34 typedef std::vector<std::string> string_list;
36 // Forward declarations
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
59 class FGAircraftModel;
61 class FGFlightPlanDispatcher;
64 class FGAirwayNetwork;
80 * Bucket for subsystem pointers representing the sim's state.
88 // properties, destroy last
89 SGPropertyNode_ptr props;
90 SGPropertyNode_ptr initial_state;
93 SGPropertyNode_ptr locale;
96 SGSubsystemMgr *subsystem_mgr;
97 SGEventMgr *event_mgr;
99 // Number of milliseconds elapsed since the start of the program.
102 // Root of FlightGear data tree
105 // Roots of FlightGear scenery tree
106 string_list fg_scenery;
110 // An offset in seconds from the true time. Allows us to adjust
111 // the effective time of day.
114 // How much to change the value of warp each iteration. Allows us
115 // to make time progress faster than normal (or even run in reverse.)
124 // Magnetic Variation
127 // Material properties library
128 SGMaterialLib *matlib;
130 // Global autopilot "route"
131 FGRouteMgr *route_mgr;
134 FGPanel *current_panel;
137 SGSoundMgr *soundmgr;
145 // control input state
146 FGControls *controls;
151 SGCommandMgr *commands;
153 //FGFlightPlanDispatcher *fpDispatcher;
155 FGAircraftModel *acmodel;
157 FGModelMgr * model_mgr;
159 // list of serial port-like configurations
160 string_list *channel_options_list;
162 // A list of initial waypoints that are read from the command line
163 // and or flight-plan file during initialization
164 string_list *initial_waypoints;
166 // FlightGear scenery manager
172 // Input/Ouput subsystem
175 FGFontCache *fontcache;
182 FGNavList *tacanlist;
183 FGNavList *carrierlist;
184 FGTACANList *channellist;
185 FGAirwayNetwork *airwaynet;
187 //Mulitplayer managers
188 FGMultiplayMgr *multiplayer_mgr;
193 virtual ~FGGlobals();
195 virtual FGRenderer *get_renderer () const;
197 virtual SGSubsystemMgr *get_subsystem_mgr () const;
199 virtual SGSubsystem *get_subsystem (const char * name);
201 virtual void add_subsystem (const char * name,
202 SGSubsystem * subsystem,
203 SGSubsystemMgr::GroupType
204 type = SGSubsystemMgr::GENERAL,
205 double min_time_sec = 0);
207 virtual SGEventMgr *get_event_mgr () const;
209 inline double get_sim_time_sec () const { return sim_time_sec; }
210 inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
211 inline void set_sim_time_sec (double t) { sim_time_sec = t; }
213 inline const std::string &get_fg_root () const { return fg_root; }
214 void set_fg_root (const std::string &root);
216 inline const string_list &get_fg_scenery () const { return fg_scenery; }
217 void set_fg_scenery (const std::string &scenery);
219 inline const std::string &get_browser () const { return browser; }
220 void set_browser (const std::string &b) { browser = b; }
222 inline long int get_warp() const { return warp; }
223 inline void set_warp( long int w ) { warp = w; }
224 inline void inc_warp( long int w ) { warp += w; }
226 inline long int get_warp_delta() const { return warp_delta; }
227 inline void set_warp_delta( long int d ) { warp_delta = d; }
228 inline void inc_warp_delta( long int d ) { warp_delta += d; }
230 inline SGTime *get_time_params() const { return time_params; }
231 inline void set_time_params( SGTime *t ) { time_params = t; }
233 inline SGEphemeris *get_ephem() const { return ephem; }
234 inline void set_ephem( SGEphemeris *e ) { ephem = e; }
236 inline SGMagVar *get_mag() const { return mag; }
237 inline void set_mag( SGMagVar *m ) { mag = m; }
239 inline SGMaterialLib *get_matlib() const { return matlib; }
240 inline void set_matlib( SGMaterialLib *m ) { matlib = m; }
242 inline FGATCMgr *get_ATC_mgr() const { return ATC_mgr; }
243 inline void set_ATC_mgr( FGATCMgr *a ) {ATC_mgr = a; }
245 inline FGAIMgr *get_AI_mgr() const { return AI_mgr; }
246 inline void set_AI_mgr( FGAIMgr *a ) {AI_mgr = a; }
248 inline FGPanel *get_current_panel() const { return current_panel; }
249 inline void set_current_panel( FGPanel *cp ) { current_panel = cp; }
251 inline SGSoundMgr *get_soundmgr() const { return soundmgr; }
252 inline void set_soundmgr( SGSoundMgr *sm ) { soundmgr = sm; }
254 inline FGControls *get_controls() const { return controls; }
255 inline void set_controls( FGControls *c ) { controls = c; }
257 inline FGViewMgr *get_viewmgr() const { return viewmgr; }
258 inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
259 FGViewer *get_current_view() const;
261 inline SGPropertyNode *get_props () { return props; }
262 inline void set_props( SGPropertyNode *n ) { props = n; }
264 inline SGPropertyNode *get_locale () { return locale; }
265 inline void set_locale( SGPropertyNode *n ) { locale = n; }
267 inline SGCommandMgr *get_commands () { return commands; }
269 inline FGAircraftModel *get_aircraft_model () { return acmodel; }
271 inline void set_aircraft_model (FGAircraftModel * model)
276 inline FGModelMgr *get_model_mgr () { return model_mgr; }
278 inline void set_model_mgr (FGModelMgr * mgr)
283 inline FGMultiplayMgr *get_multiplayer_mgr () { return multiplayer_mgr; }
285 inline void set_multiplayer_mgr (FGMultiplayMgr * mgr)
287 multiplayer_mgr = mgr;
290 inline string_list *get_channel_options_list () {
291 return channel_options_list;
293 inline void set_channel_options_list( string_list *l ) {
294 channel_options_list = l;
297 inline string_list *get_initial_waypoints () {
298 return initial_waypoints;
301 inline void set_initial_waypoints (string_list *list) {
302 initial_waypoints = list;
305 inline FGScenery * get_scenery () const { return scenery; }
306 inline void set_scenery ( FGScenery *s ) { scenery = s; }
308 inline FGTileMgr * get_tile_mgr () const { return tile_mgr; }
309 inline void set_tile_mgr ( FGTileMgr *t ) { tile_mgr = t; }
311 inline FGIO* get_io() const { return io; }
312 inline FGFontCache *get_fontcache() const { return fontcache; }
314 inline FGNavList *get_navlist() const { return navlist; }
315 inline void set_navlist( FGNavList *n ) { navlist = n; }
316 inline FGNavList *get_loclist() const { return loclist; }
317 inline void set_loclist( FGNavList *n ) { loclist = n; }
318 inline FGNavList *get_gslist() const { return gslist; }
319 inline void set_gslist( FGNavList *n ) { gslist = n; }
320 inline FGNavList *get_dmelist() const { return dmelist; }
321 inline void set_dmelist( FGNavList *n ) { dmelist = n; }
322 inline FGNavList *get_tacanlist() const { return tacanlist; }
323 inline void set_tacanlist( FGNavList *n ) { tacanlist = n; }
324 inline FGNavList *get_carrierlist() const { return carrierlist; }
325 inline void set_carrierlist( FGNavList *n ) { carrierlist = n; }
326 inline FGTACANList *get_channellist() const { return channellist; }
327 inline void set_channellist( FGTACANList *c ) { channellist = c; }
329 inline FGAirwayNetwork *get_airwaynet() const { return airwaynet; }
330 inline void set_airwaynet( FGAirwayNetwork *a ) { airwaynet = a; }
334 * Save the current state as the initial state.
336 void saveInitialState ();
340 * Restore the saved initial state, if any.
342 void restoreInitialState ();
347 extern FGGlobals *globals;
350 #endif // _GLOBALS_HXX