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