]> git.mxchange.org Git - flightgear.git/blob - src/Main/globals.cxx
af88f381e34bb22096f7f6520d764d3295219d1e
[flightgear.git] / src / Main / globals.cxx
1 // globals.cxx -- 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 Foundation,
19 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23 #ifdef HAVE_CONFIG_H
24 #  include <config.h>
25 #endif
26
27 #include <boost/foreach.hpp>
28 #include <algorithm>
29
30 #include <osgViewer/Viewer>
31 #include <osgDB/Registry>
32
33 #include <simgear/structure/commands.hxx>
34 #include <simgear/misc/sg_path.hxx>
35 #include <simgear/misc/sg_dir.hxx>
36 #include <simgear/timing/sg_time.hxx>
37 #include <simgear/ephemeris/ephemeris.hxx>
38 #include <simgear/scene/material/matlib.hxx>
39 #include <simgear/structure/subsystem_mgr.hxx>
40 #include <simgear/structure/event_mgr.hxx>
41 #include <simgear/sound/soundmgr_openal.hxx>
42 #include <simgear/misc/ResourceManager.hxx>
43 #include <simgear/props/propertyObject.hxx>
44 #include <simgear/props/props_io.hxx>
45 #include <simgear/scene/model/modellib.hxx>
46 #include <simgear/package/Root.hxx>
47
48 #include <Aircraft/controls.hxx>
49 #include <Airports/runways.hxx>
50 #include <Autopilot/route_mgr.hxx>
51 #include <GUI/FGFontCache.hxx>
52 #include <GUI/gui.h>
53 #include <MultiPlayer/multiplaymgr.hxx>
54 #include <Scenery/scenery.hxx>
55 #include <Scenery/tilemgr.hxx>
56 #include <Navaids/navlist.hxx>
57 #include <Viewer/renderer.hxx>
58 #include <Viewer/viewmgr.hxx>
59 #include <Sound/sample_queue.hxx>
60
61 #include "globals.hxx"
62 #include "locale.hxx"
63
64 #include "fg_props.hxx"
65 #include "fg_io.hxx"
66
67 class AircraftResourceProvider : public simgear::ResourceProvider
68 {
69 public:
70   AircraftResourceProvider() :
71     simgear::ResourceProvider(simgear::ResourceManager::PRIORITY_HIGH)
72   {
73   }
74   
75   virtual SGPath resolve(const std::string& aResource, SGPath&) const
76   {
77     string_list pieces(sgPathBranchSplit(aResource));
78     if ((pieces.size() < 3) || (pieces.front() != "Aircraft")) {
79       return SGPath(); // not an Aircraft path
80     }
81     
82   // test against the aircraft-dir property
83     const char* aircraftDir = fgGetString("/sim/aircraft-dir");
84     string_list aircraftDirPieces(sgPathBranchSplit(aircraftDir));
85     if (!aircraftDirPieces.empty() && (aircraftDirPieces.back() == pieces[1])) {
86         // current aircraft-dir matches resource aircraft
87         SGPath r(aircraftDir);
88         for (unsigned int i=2; i<pieces.size(); ++i) {
89           r.append(pieces[i]);
90         }
91         
92         if (r.exists()) {
93           return r;
94         }
95     }
96   
97   // try each aircraft dir in turn
98     std::string res(aResource, 9); // resource path with 'Aircraft/' removed
99     const string_list& dirs(globals->get_aircraft_paths());
100     string_list::const_iterator it = dirs.begin();
101     for (; it != dirs.end(); ++it) {
102       SGPath p(*it, res);
103       if (p.exists()) {
104         return p;
105       }
106     } // of aircraft path iteration
107     
108     return SGPath(); // not found
109   }
110 };
111
112 class CurrentAircraftDirProvider : public simgear::ResourceProvider
113 {
114 public:
115   CurrentAircraftDirProvider() :
116     simgear::ResourceProvider(simgear::ResourceManager::PRIORITY_HIGH)
117   {
118   }
119   
120   virtual SGPath resolve(const std::string& aResource, SGPath&) const
121   {
122     const char* aircraftDir = fgGetString("/sim/aircraft-dir");
123     SGPath p(aircraftDir);
124     p.append(aResource);
125     return p.exists() ? p : SGPath();
126   }
127 };
128
129 ////////////////////////////////////////////////////////////////////////
130 // Implementation of FGGlobals.
131 ////////////////////////////////////////////////////////////////////////
132
133 // global global :-)
134 FGGlobals *globals = NULL;
135
136
137 // Constructor
138 FGGlobals::FGGlobals() :
139     renderer( new FGRenderer ),
140     subsystem_mgr( new SGSubsystemMgr ),
141     event_mgr( new SGEventMgr ),
142     sim_time_sec( 0.0 ),
143     fg_root( "" ),
144     fg_home( "" ),
145     time_params( NULL ),
146     ephem( NULL ),
147     route_mgr( NULL ),
148     controls( NULL ),
149     viewmgr( NULL ),
150     commands( SGCommandMgr::instance() ),
151     channel_options_list( NULL ),
152     initial_waypoints( NULL ),
153     fontcache ( new FGFontCache ),
154     channellist( NULL ),
155     haveUserSettings(false),
156     _chatter_queue(NULL)
157 {
158     SGPropertyNode* root = new SGPropertyNode;
159     props = SGPropertyNode_ptr(root);
160     locale = new FGLocale(props);
161     
162     simgear::ResourceManager::instance()->addProvider(new AircraftResourceProvider);
163     simgear::ResourceManager::instance()->addProvider(new CurrentAircraftDirProvider);
164     initProperties();
165 }
166
167 void FGGlobals::initProperties()
168 {
169     simgear::PropertyObjectBase::setDefaultRoot(props);
170     
171     positionLon = props->getNode("position/longitude-deg", true);
172     positionLat = props->getNode("position/latitude-deg", true);
173     positionAlt = props->getNode("position/altitude-ft", true);
174     
175     viewLon = props->getNode("sim/current-view/viewer-lon-deg", true);
176     viewLat = props->getNode("sim/current-view/viewer-lat-deg", true);
177     viewAlt = props->getNode("sim/current-view/viewer-elev-ft", true);
178     
179     orientPitch = props->getNode("orientation/pitch-deg", true);
180     orientHeading = props->getNode("orientation/heading-deg", true);
181     orientRoll = props->getNode("orientation/roll-deg", true);
182
183 }
184
185 // Destructor
186 FGGlobals::~FGGlobals() 
187 {
188     // save user settings (unless already saved)
189     saveUserSettings();
190
191     // The AIModels manager performs a number of actions upon
192     // Shutdown that implicitly assume that other subsystems
193     // are still operational (Due to the dynamic allocation and
194     // deallocation of AIModel objects. To ensure we can safely
195     // shut down all subsystems, make sure we take down the 
196     // AIModels system first.
197     SGSubsystemRef ai = subsystem_mgr->get_subsystem("ai-model");
198     if (ai) {
199         subsystem_mgr->remove("ai-model");
200         ai->unbind();
201         ai.clear(); // ensure AI is deleted now, not at end of this method
202     }
203     
204     subsystem_mgr->shutdown();
205     subsystem_mgr->unbind();    
206
207     subsystem_mgr->remove("aircraft-model");
208     subsystem_mgr->remove("tile-manager");
209     subsystem_mgr->remove("model-manager");
210     _tile_mgr.clear();
211
212     osg::ref_ptr<osgViewer::Viewer> vw(renderer->getViewer());
213     if (vw) {
214         // https://code.google.com/p/flightgear-bugs/issues/detail?id=1291
215         // explicitly stop trheading before we delete the renderer or
216         // viewMgr (which ultimately holds refs to the CameraGroup, and
217         // GraphicsContext)
218         vw->stopThreading();
219     }
220     
221     // don't cancel the pager until after shutdown, since AIModels (and
222     // potentially others) can queue delete requests on the pager.
223     if (vw && vw->getDatabasePager()) {
224         vw->getDatabasePager()->cancel();
225         vw->getDatabasePager()->clear();
226     }
227     
228     osgDB::Registry::instance()->clearObjectCache();
229     
230     // renderer touches subsystems during its destruction
231     set_renderer(NULL);
232     _scenery.clear();
233     _chatter_queue.clear();
234     
235     delete subsystem_mgr;
236     subsystem_mgr = NULL; // important so ::get_subsystem returns NULL
237     vw = 0; // don't delete the viewer until now
238
239     delete time_params;
240     set_matlib(NULL);
241     delete route_mgr;
242     delete channel_options_list;
243     delete initial_waypoints;
244     delete fontcache;
245     delete channellist;
246
247     simgear::PropertyObjectBase::setDefaultRoot(NULL);
248     simgear::SGModelLib::resetPropertyRoot();
249     
250     delete locale;
251     locale = NULL;
252     
253     cleanupListeners();
254     
255     props.clear();
256     
257     delete commands;
258 }
259
260 // set the fg_root path
261 void FGGlobals::set_fg_root (const std::string &root) {
262     SGPath tmp(root);
263     fg_root = tmp.realpath();
264
265     // append /data to root if it exists
266     tmp.append( "data" );
267     tmp.append( "version" );
268     if ( tmp.exists() ) {
269         fgGetNode("BAD_FG_ROOT", true)->setStringValue(fg_root);
270         fg_root += "/data";
271         fgGetNode("GOOD_FG_ROOT", true)->setStringValue(fg_root);
272         SG_LOG(SG_GENERAL, SG_ALERT, "***\n***\n*** Warning: changing bad FG_ROOT/--fg-root to '"
273                 << fg_root << "'\n***\n***");
274     }
275
276     // remove /sim/fg-root before writing to prevent hijacking
277     SGPropertyNode *n = fgGetNode("/sim", true);
278     n->removeChild("fg-root", 0);
279     n = n->getChild("fg-root", 0, true);
280     n->setStringValue(fg_root.c_str());
281     n->setAttribute(SGPropertyNode::WRITE, false);
282     
283     simgear::ResourceManager::instance()->addBasePath(fg_root, 
284       simgear::ResourceManager::PRIORITY_DEFAULT);
285 }
286
287 // set the fg_home path
288 void FGGlobals::set_fg_home (const std::string &home) {
289     SGPath tmp(home);
290     fg_home = tmp.realpath();
291 }
292
293 PathList FGGlobals::get_data_paths() const
294 {
295     PathList r(additional_data_paths);
296     r.push_back(SGPath(fg_root));
297     return r;
298 }
299
300 PathList FGGlobals::get_data_paths(const std::string& suffix) const
301 {
302     PathList r;
303     BOOST_FOREACH(SGPath p, get_data_paths()) {
304         p.append(suffix);
305         if (p.exists()) {
306             r.push_back(p);
307         }
308     }
309
310     return r;
311 }
312
313 void FGGlobals::append_data_path(const SGPath& path)
314 {
315     if (!path.exists()) {
316         SG_LOG(SG_GENERAL, SG_WARN, "adding non-existant data path:" << path);
317     }
318     
319     additional_data_paths.push_back(path);
320 }
321
322 SGPath FGGlobals::find_data_dir(const std::string& pathSuffix) const
323 {
324     BOOST_FOREACH(SGPath p, additional_data_paths) {
325         p.append(pathSuffix);
326         if (p.exists()) {
327             return p;
328         }
329     }
330     
331     SGPath rootPath(fg_root);
332     rootPath.append(pathSuffix);
333     if (rootPath.exists()) {
334         return rootPath;
335     }
336     
337     SG_LOG(SG_GENERAL, SG_WARN, "dir not found in any data path:" << pathSuffix);
338     return SGPath();
339 }
340
341 void FGGlobals::append_fg_scenery (const std::string &paths)
342 {
343     SGPropertyNode* sim = fgGetNode("/sim", true);
344
345   // find first unused fg-scenery property in /sim
346     int propIndex = 0;
347     while (sim->getChild("fg-scenery", propIndex) != NULL) {
348       ++propIndex; 
349     }
350   
351     BOOST_FOREACH(const SGPath& path, sgPathSplit( paths )) {
352         SGPath abspath(path.realpath());
353         if (!abspath.exists()) {
354           SG_LOG(SG_GENERAL, SG_WARN, "scenery path not found:" << abspath.str());
355           continue;
356         }
357
358       // check for duplicates
359       string_list::const_iterator ex = std::find(fg_scenery.begin(), fg_scenery.end(), abspath.str());
360       if (ex != fg_scenery.end()) {
361         SG_LOG(SG_GENERAL, SG_INFO, "skipping duplicate add of scenery path:" << abspath.str());
362         continue;
363       }
364       
365         simgear::Dir dir(abspath);
366         SGPath terrainDir(dir.file("Terrain"));
367         SGPath objectsDir(dir.file("Objects"));
368         
369       // this code used to add *either* the base dir, OR add the 
370       // Terrain and Objects subdirs, but the conditional logic was commented
371       // out, such that all three dirs are added. Unfortunately there's
372       // no information as to why the change was made.
373         fg_scenery.push_back(abspath.str());
374         
375         if (terrainDir.exists()) {
376           fg_scenery.push_back(terrainDir.str());
377         }
378         
379         if (objectsDir.exists()) {
380           fg_scenery.push_back(objectsDir.str());
381         }
382         
383         // insert a marker for FGTileEntry::load(), so that
384         // FG_SCENERY=A:B becomes list ["A/Terrain", "A/Objects", "",
385         // "B/Terrain", "B/Objects", ""]
386         fg_scenery.push_back("");
387         
388       // make scenery dirs available to Nasal
389         SGPropertyNode* n = sim->getChild("fg-scenery", propIndex++, true);
390         n->setStringValue(abspath.str());
391         n->setAttribute(SGPropertyNode::WRITE, false);
392         
393         // temporary fix so these values survive reset
394         n->setAttribute(SGPropertyNode::PRESERVE, true);
395     } // of path list iteration
396 }
397
398 void FGGlobals::clear_fg_scenery()
399 {
400   fg_scenery.clear();
401 }
402
403 void FGGlobals::set_catalog_aircraft_path(const SGPath& path)
404 {
405     catalog_aircraft_dir = path;
406 }
407
408 string_list FGGlobals::get_aircraft_paths() const
409 {
410     string_list r;
411     if (!catalog_aircraft_dir.isNull()) {
412         r.push_back(catalog_aircraft_dir.str());
413     }
414
415     r.insert(r.end(), fg_aircraft_dirs.begin(), fg_aircraft_dirs.end());
416     return r;
417 }
418
419 void FGGlobals::append_aircraft_path(const std::string& path)
420 {
421   SGPath dirPath(path);
422   if (!dirPath.exists()) {
423     SG_LOG(SG_GENERAL, SG_ALERT, "aircraft path not found:" << path);
424     return;
425   }
426     
427   SGPath acSubdir(dirPath);
428   acSubdir.append("Aircraft");
429   if (acSubdir.exists()) {
430       SG_LOG(SG_GENERAL, SG_WARN, "Specified an aircraft-dir with an 'Aircraft' subdirectory:" << dirPath
431                  << ", will instead use child directory:" << acSubdir);
432       dirPath = acSubdir;
433   }
434     
435   std::string abspath = dirPath.realpath();
436   unsigned int index = fg_aircraft_dirs.size();  
437   fg_aircraft_dirs.push_back(abspath);
438 }
439
440 void FGGlobals::append_aircraft_paths(const std::string& path)
441 {
442   string_list paths = sgPathSplit(path);
443   for (unsigned int p = 0; p<paths.size(); ++p) {
444     append_aircraft_path(paths[p]);
445   }
446 }
447
448 SGPath FGGlobals::resolve_aircraft_path(const std::string& branch) const
449 {
450   return simgear::ResourceManager::instance()->findPath(branch);
451 }
452
453 SGPath FGGlobals::resolve_maybe_aircraft_path(const std::string& branch) const
454 {
455   return simgear::ResourceManager::instance()->findPath(branch);
456 }
457
458 SGPath FGGlobals::resolve_resource_path(const std::string& branch) const
459 {
460   return simgear::ResourceManager::instance()
461     ->findPath(branch, SGPath(fgGetString("/sim/aircraft-dir")));
462 }
463
464 FGRenderer *
465 FGGlobals::get_renderer () const
466 {
467    return renderer;
468 }
469
470 void FGGlobals::set_renderer(FGRenderer *render)
471 {
472     if (render == renderer) {
473         return;
474     }
475     
476     delete renderer;
477     renderer = render;
478 }
479
480 SGSubsystemMgr *
481 FGGlobals::get_subsystem_mgr () const
482 {
483     return subsystem_mgr;
484 }
485
486 SGSubsystem *
487 FGGlobals::get_subsystem (const char * name)
488 {
489     if (!subsystem_mgr) {
490         return NULL;
491     }
492     
493     return subsystem_mgr->get_subsystem(name);
494 }
495
496 void
497 FGGlobals::add_subsystem (const char * name,
498                           SGSubsystem * subsystem,
499                           SGSubsystemMgr::GroupType type,
500                           double min_time_sec)
501 {
502     subsystem_mgr->add(name, subsystem, type, min_time_sec);
503 }
504
505 SGSoundMgr *
506 FGGlobals::get_soundmgr () const
507 {
508     if (subsystem_mgr)
509         return (SGSoundMgr*) subsystem_mgr->get_subsystem("sound");
510
511     return NULL;
512 }
513
514 SGEventMgr *
515 FGGlobals::get_event_mgr () const
516 {
517     return event_mgr;
518 }
519
520 SGGeod
521 FGGlobals::get_aircraft_position() const
522 {
523   return SGGeod::fromDegFt(positionLon->getDoubleValue(),
524                            positionLat->getDoubleValue(),
525                            positionAlt->getDoubleValue());
526 }
527
528 SGVec3d
529 FGGlobals::get_aircraft_position_cart() const
530 {
531     return SGVec3d::fromGeod(get_aircraft_position());
532 }
533
534 void FGGlobals::get_aircraft_orientation(double& heading, double& pitch, double& roll)
535 {
536   heading = orientHeading->getDoubleValue();
537   pitch = orientPitch->getDoubleValue();
538   roll = orientRoll->getDoubleValue();
539 }
540
541 SGGeod
542 FGGlobals::get_view_position() const
543 {
544   return SGGeod::fromDegFt(viewLon->getDoubleValue(),
545                            viewLat->getDoubleValue(),
546                            viewAlt->getDoubleValue());
547 }
548
549 SGVec3d
550 FGGlobals::get_view_position_cart() const
551 {
552   return SGVec3d::fromGeod(get_view_position());
553 }
554
555 static void treeDumpRefCounts(int depth, SGPropertyNode* nd)
556 {
557     for (int i=0; i<nd->nChildren(); ++i) {
558         SGPropertyNode* cp = nd->getChild(i);
559         if (SGReferenced::count(cp) > 1) {
560             SG_LOG(SG_GENERAL, SG_INFO, "\t" << cp->getPath() << " refcount:" << SGReferenced::count(cp));
561         }
562         
563         treeDumpRefCounts(depth + 1, cp);
564     }
565 }
566
567 static void treeClearAliases(SGPropertyNode* nd)
568 {
569     if (nd->isAlias()) {
570         nd->unalias();
571     }
572     
573     for (int i=0; i<nd->nChildren(); ++i) {
574         SGPropertyNode* cp = nd->getChild(i);
575         treeClearAliases(cp);
576     }
577 }
578
579 void
580 FGGlobals::resetPropertyRoot()
581 {
582     delete locale;
583     
584     cleanupListeners();
585     
586     // we don't strictly need to clear these (they will be reset when we
587     // initProperties again), but trying to reduce false-positives when dumping
588     // ref-counts.
589     positionLon.clear();
590     positionLat.clear();
591     positionAlt.clear();
592     viewLon.clear();
593     viewLat.clear();
594     viewAlt.clear();
595     orientPitch.clear();
596     orientHeading.clear();
597     orientRoll.clear();
598     
599     // clear aliases so ref-counts are accurate when dumped
600     treeClearAliases(props);
601     
602     SG_LOG(SG_GENERAL, SG_INFO, "root props refcount:" << props.getNumRefs());
603     treeDumpRefCounts(0, props);
604
605     //BaseStackSnapshot::dumpAll(std::cout);
606     
607     props = new SGPropertyNode;
608     initProperties();
609     locale = new FGLocale(props);
610     
611     // remove /sim/fg-root before writing to prevent hijacking
612     SGPropertyNode *n = props->getNode("/sim", true);
613     n->removeChild("fg-root", 0);
614     n = n->getChild("fg-root", 0, true);
615     n->setStringValue(fg_root.c_str());
616     n->setAttribute(SGPropertyNode::WRITE, false);
617 }
618
619 static std::string autosaveName()
620 {
621     std::ostringstream os;
622     string_list versionParts = simgear::strutils::split(VERSION, ".");
623     if (versionParts.size() < 2) {
624         return "autosave.xml";
625     }
626     
627     os << "autosave_" << versionParts[0] << "_" << versionParts[1] << ".xml";
628     return os.str();
629 }
630
631 // Load user settings from autosave.xml
632 void
633 FGGlobals::loadUserSettings(const SGPath& dataPath)
634 {
635     // remember that we have (tried) to load any existing autsave.xml
636     haveUserSettings = true;
637
638     SGPath autosaveFile = simgear::Dir(dataPath).file(autosaveName());
639     SGPropertyNode autosave;
640     if (autosaveFile.exists()) {
641       SG_LOG(SG_INPUT, SG_INFO, "Reading user settings from " << autosaveFile.str());
642       try {
643           readProperties(autosaveFile.str(), &autosave, SGPropertyNode::USERARCHIVE);
644       } catch (sg_exception& e) {
645           SG_LOG(SG_INPUT, SG_WARN, "failed to read user settings:" << e.getMessage()
646             << "(from " << e.getOrigin() << ")");
647       }
648     }
649     copyProperties(&autosave, globals->get_props());
650 }
651
652 // Save user settings in autosave.xml
653 void
654 FGGlobals::saveUserSettings()
655 {
656     // only save settings when we have (tried) to load the previous
657     // settings (otherwise user data was lost)
658     if (!haveUserSettings)
659         return;
660
661     if (fgGetBool("/sim/startup/save-on-exit")) {
662       // don't save settings more than once on shutdown
663       haveUserSettings = false;
664
665       SGPath autosaveFile(globals->get_fg_home());
666       autosaveFile.append(autosaveName());
667       autosaveFile.create_dir( 0700 );
668       SG_LOG(SG_IO, SG_INFO, "Saving user settings to " << autosaveFile.str());
669       try {
670         writeProperties(autosaveFile.str(), globals->get_props(), false, SGPropertyNode::USERARCHIVE);
671       } catch (const sg_exception &e) {
672         guiErrorMessage("Error writing autosave:", e);
673       }
674       SG_LOG(SG_INPUT, SG_DEBUG, "Finished Saving user settings");
675     }
676 }
677
678 FGViewer *
679 FGGlobals::get_current_view () const
680 {
681   return viewmgr->get_current_view();
682 }
683
684 long int FGGlobals::get_warp() const
685 {
686   return fgGetInt("/sim/time/warp");
687 }
688
689 void FGGlobals::set_warp( long int w )
690 {
691   fgSetInt("/sim/time/warp", w);
692 }
693
694 long int FGGlobals::get_warp_delta() const
695 {
696   return fgGetInt("/sim/time/warp-delta");
697 }
698
699 void FGGlobals::set_warp_delta( long int d )
700 {
701   fgSetInt("/sim/time/warp-delta", d);
702 }
703
704 FGScenery* FGGlobals::get_scenery () const
705 {
706     return _scenery.get();
707 }
708
709 void FGGlobals::set_scenery ( FGScenery *s )
710 {
711     _scenery = s;
712 }
713
714 FGTileMgr* FGGlobals::get_tile_mgr () const
715 {
716     return _tile_mgr.get();
717 }
718
719 void FGGlobals::set_tile_mgr ( FGTileMgr *t )
720 {
721     _tile_mgr = t;
722 }
723
724 void FGGlobals::set_matlib( SGMaterialLib *m )
725 {
726     matlib = m;
727 }
728
729 FGSampleQueue* FGGlobals::get_chatter_queue() const
730 {
731     return _chatter_queue;
732 }
733
734 void FGGlobals::set_chatter_queue(FGSampleQueue* queue)
735 {
736     _chatter_queue = queue;
737 }
738
739 void FGGlobals::addListenerToCleanup(SGPropertyChangeListener* l)
740 {
741     _listeners_to_cleanup.push_back(l);
742 }
743
744 void FGGlobals::cleanupListeners()
745 {
746     SGPropertyChangeListenerVec::iterator i = _listeners_to_cleanup.begin();
747     for (; i != _listeners_to_cleanup.end(); ++i) {
748         delete *i;
749     }
750     _listeners_to_cleanup.clear();
751 }
752
753 simgear::pkg::Root* FGGlobals::packageRoot()
754 {
755   return _packageRoot.get();
756 }
757
758 void FGGlobals::setPackageRoot(const SGSharedPtr<simgear::pkg::Root>& p)
759 {
760   _packageRoot = p;
761 }
762
763 // end of globals.cxx