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>
30 #include <simgear/misc/sg_path.hxx>
35 typedef std::vector<std::string> string_list;
37 // Forward declarations
39 // This file is included, directly or indirectly, almost everywhere in
40 // FlightGear, so if any of its dependencies changes, most of the sim
41 // has to be recompiled. Using these forward declarations helps us to
42 // avoid including a lot of header files (and thus, a lot of
43 // dependencies). Since Most of the methods simply set or return
44 // pointers, we don't need to know anything about the class details
59 class FGAircraftModel;
61 class FGFlightPlanDispatcher;
76 * Bucket for subsystem pointers representing the sim's state.
84 // properties, destroy last
85 SGPropertyNode_ptr props;
86 SGPropertyNode_ptr initial_state;
89 SGPropertyNode_ptr locale;
92 SGSubsystemMgr *subsystem_mgr;
93 SGEventMgr *event_mgr;
95 // Number of milliseconds elapsed since the start of the program.
98 // Root of FlightGear data tree
101 // Roots of FlightGear scenery tree
102 string_list fg_scenery;
112 // Magnetic Variation
115 // Material properties library
116 SGMaterialLib *matlib;
118 // Global autopilot "route"
119 FGRouteMgr *route_mgr;
122 FGPanel *current_panel;
127 // control input state
128 FGControls *controls;
133 SGCommandMgr *commands;
135 //FGFlightPlanDispatcher *fpDispatcher;
137 FGAircraftModel *acmodel;
139 FGModelMgr * model_mgr;
141 // list of serial port-like configurations
142 string_list *channel_options_list;
144 // A list of initial waypoints that are read from the command line
145 // and or flight-plan file during initialization
146 string_list *initial_waypoints;
148 // FlightGear scenery manager
154 FGFontCache *fontcache;
161 FGNavList *tacanlist;
162 FGNavList *carrierlist;
163 FGTACANList *channellist;
165 /// roots of Aircraft trees
166 string_list fg_aircraft_dirs;
170 virtual ~FGGlobals();
172 virtual FGRenderer *get_renderer () const;
174 virtual SGSubsystemMgr *get_subsystem_mgr () const;
176 virtual SGSubsystem *get_subsystem (const char * name);
178 virtual void add_subsystem (const char * name,
179 SGSubsystem * subsystem,
180 SGSubsystemMgr::GroupType
181 type = SGSubsystemMgr::GENERAL,
182 double min_time_sec = 0);
184 virtual SGEventMgr *get_event_mgr () const;
186 virtual SGSoundMgr *get_soundmgr () const;
188 inline double get_sim_time_sec () const { return sim_time_sec; }
189 inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
190 inline void set_sim_time_sec (double t) { sim_time_sec = t; }
192 inline const std::string &get_fg_root () const { return fg_root; }
193 void set_fg_root (const std::string &root);
195 inline const string_list &get_fg_scenery () const { return fg_scenery; }
196 void append_fg_scenery (const std::string &scenery);
198 const string_list& get_aircraft_paths() const { return fg_aircraft_dirs; }
199 void append_aircraft_path(const std::string& path);
200 void append_aircraft_paths(const std::string& path);
203 * Given a path to an aircraft-related resource file, resolve it
204 * against the appropriate root. This means looking at the location
205 * defined by /sim/aircraft-dir, and then aircraft_path in turn,
206 * finishing with fg_root/Aircraft.
208 * if the path could not be resolved, an empty path is returned.
210 SGPath resolve_aircraft_path(const std::string& branch) const;
213 * Same as above, but test for non 'Aircraft/' branch paths, and
214 * always resolve them against fg_root.
216 SGPath resolve_maybe_aircraft_path(const std::string& branch) const;
218 inline const std::string &get_browser () const { return browser; }
219 void set_browser (const std::string &b) { browser = b; }
221 long int get_warp() const;
222 void set_warp( long int w );
224 long int get_warp_delta() const;
225 void set_warp_delta( long int d );
227 inline SGTime *get_time_params() const { return time_params; }
228 inline void set_time_params( SGTime *t ) { time_params = t; }
230 inline SGEphemeris *get_ephem() const { return ephem; }
231 inline void set_ephem( SGEphemeris *e ) { ephem = e; }
233 inline SGMagVar *get_mag() const { return mag; }
234 inline void set_mag( SGMagVar *m ) { mag = m; }
236 inline SGMaterialLib *get_matlib() const { return matlib; }
237 inline void set_matlib( SGMaterialLib *m ) { matlib = m; }
239 inline FGATCMgr *get_ATC_mgr() const { return ATC_mgr; }
240 inline void set_ATC_mgr( FGATCMgr *a ) {ATC_mgr = a; }
242 inline FGPanel *get_current_panel() const { return current_panel; }
243 inline void set_current_panel( FGPanel *cp ) { current_panel = cp; }
245 inline FGControls *get_controls() const { return controls; }
246 inline void set_controls( FGControls *c ) { controls = c; }
248 inline FGViewMgr *get_viewmgr() const { return viewmgr; }
249 inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
250 FGViewer *get_current_view() const;
252 inline SGPropertyNode *get_props () { return props; }
253 inline void set_props( SGPropertyNode *n ) { props = n; }
255 inline SGPropertyNode *get_locale () { return locale; }
256 inline void set_locale( SGPropertyNode *n ) { locale = n; }
258 inline SGCommandMgr *get_commands () { return commands; }
260 inline FGAircraftModel *get_aircraft_model () { return acmodel; }
262 inline void set_aircraft_model (FGAircraftModel * model)
267 const SGGeod & get_aircraft_position() const;
269 SGVec3d get_aircraft_positon_cart() const;
271 inline FGModelMgr *get_model_mgr () { return model_mgr; }
273 inline void set_model_mgr (FGModelMgr * mgr)
278 inline string_list *get_channel_options_list () {
279 return channel_options_list;
281 inline void set_channel_options_list( string_list *l ) {
282 channel_options_list = l;
285 inline string_list *get_initial_waypoints () {
286 return initial_waypoints;
289 inline void set_initial_waypoints (string_list *list) {
290 initial_waypoints = list;
293 inline FGScenery * get_scenery () const { return scenery; }
294 inline void set_scenery ( FGScenery *s ) { scenery = s; }
296 inline FGTileMgr * get_tile_mgr () const { return tile_mgr; }
297 inline void set_tile_mgr ( FGTileMgr *t ) { tile_mgr = t; }
299 inline FGFontCache *get_fontcache() const { return fontcache; }
301 inline FGNavList *get_navlist() const { return navlist; }
302 inline void set_navlist( FGNavList *n ) { navlist = n; }
303 inline FGNavList *get_loclist() const { return loclist; }
304 inline void set_loclist( FGNavList *n ) { loclist = n; }
305 inline FGNavList *get_gslist() const { return gslist; }
306 inline void set_gslist( FGNavList *n ) { gslist = n; }
307 inline FGNavList *get_dmelist() const { return dmelist; }
308 inline void set_dmelist( FGNavList *n ) { dmelist = n; }
309 inline FGNavList *get_tacanlist() const { return tacanlist; }
310 inline void set_tacanlist( FGNavList *n ) { tacanlist = n; }
311 inline FGNavList *get_carrierlist() const { return carrierlist; }
312 inline void set_carrierlist( FGNavList *n ) { carrierlist = n; }
313 inline FGTACANList *get_channellist() const { return channellist; }
314 inline void set_channellist( FGTACANList *c ) { channellist = c; }
317 * Save the current state as the initial state.
319 void saveInitialState ();
323 * Restore the saved initial state, if any.
325 void restoreInitialState ();
330 extern FGGlobals *globals;
333 #endif // _GLOBALS_HXX