From: david Date: Thu, 16 Jan 2003 16:01:26 +0000 (+0000) Subject: Simplify subsystem handling through FGGlobals. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2256c3d5fdc5fd92eb7465864627cf0985b7c402;p=flightgear.git Simplify subsystem handling through FGGlobals. --- diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 6728b5e36..b145aa6b1 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -1475,27 +1475,21 @@ bool fgInitSubsystems() { // Create and register the logger. //////////////////////////////////////////////////////////////////// - globals->get_subsystem_mgr()->add(FGSubsystemMgr::GENERAL, - "logger", - new FGLogger); + globals->add_subsystem("logger", new FGLogger); //////////////////////////////////////////////////////////////////// // Create and register the script manager. //////////////////////////////////////////////////////////////////// - globals->get_subsystem_mgr()->add(FGSubsystemMgr::GENERAL, - "scripting", - new FGScriptMgr); + globals->add_subsystem("scripting", new FGScriptMgr); //////////////////////////////////////////////////////////////////// // Create and register the XML GUI. //////////////////////////////////////////////////////////////////// - globals->get_subsystem_mgr()->add(FGSubsystemMgr::INIT, - "gui", - new NewGUI); + globals->add_subsystem("gui", new NewGUI, FGSubsystemMgr::INIT); //////////////////////////////////////////////////////////////////// @@ -1664,26 +1658,17 @@ bool fgInitSubsystems() { // Initialize the sound-effects subsystem. //////////////////////////////////////////////////////////////////// - globals->get_subsystem_mgr()->add(FGSubsystemMgr::GENERAL, - "fx", - new FGFX); + globals->add_subsystem("fx", new FGFX); - #endif - globals->get_subsystem_mgr()->add(FGSubsystemMgr::GENERAL, - "instrumentation", - new FGInstrumentMgr); - globals->get_subsystem_mgr()->add(FGSubsystemMgr::GENERAL, - "systems", - new FGSystemMgr); + globals->add_subsystem("instrumentation", new FGInstrumentMgr); + globals->add_subsystem("systems", new FGSystemMgr); //////////////////////////////////////////////////////////////////// // Initialize the radio stack subsystem. //////////////////////////////////////////////////////////////////// - // A textbook example of how FGSubsystem - // should work... current_radiostack = new FGRadioStack; current_radiostack->init(); current_radiostack->bind(); @@ -1764,9 +1749,7 @@ bool fgInitSubsystems() { // Initialize the input subsystem. //////////////////////////////////////////////////////////////////// - globals->get_subsystem_mgr()->add(FGSubsystemMgr::GENERAL, - "input", - new FGInput); + globals->add_subsystem("input", new FGInput); //////////////////////////////////////////////////////////////////// diff --git a/src/Main/fgfs.cxx b/src/Main/fgfs.cxx index fda5ddf4e..e66db61eb 100644 --- a/src/Main/fgfs.cxx +++ b/src/Main/fgfs.cxx @@ -309,8 +309,8 @@ FGSubsystemMgr::is_suspended () const } void -FGSubsystemMgr::add (GroupType group, const string &name, - FGSubsystem * subsystem, double min_time_sec) +FGSubsystemMgr::add (const char * name, FGSubsystem * subsystem, + GroupType group, double min_time_sec) { SG_LOG(SG_GENERAL, SG_INFO, "Adding subsystem " << name); get_group(group)->set_subsystem(name, subsystem, min_time_sec); diff --git a/src/Main/fgfs.hxx b/src/Main/fgfs.hxx index 08a335a62..4d97d23df 100644 --- a/src/Main/fgfs.hxx +++ b/src/Main/fgfs.hxx @@ -332,8 +332,9 @@ public: virtual void resume (); virtual bool is_suspended () const; - virtual void add (GroupType group, const string &name, + virtual void add (const char * name, FGSubsystem * subsystem, + GroupType group = GENERAL, double min_time_sec = 0); virtual FGSubsystemGroup * get_group (GroupType group); diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index ee093bada..f64bdbe25 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -91,6 +91,28 @@ FGGlobals::~FGGlobals() } +FGSubsystemMgr * +FGGlobals::get_subsystem_mgr () const +{ + return subsystem_mgr; +} + +FGSubsystem * +FGGlobals::get_subsystem (const char * name) +{ + return subsystem_mgr->get_subsystem(name); +} + +void +FGGlobals::add_subsystem (const char * name, + FGSubsystem * subsystem, + FGSubsystemMgr::GroupType type, + double min_time_sec) +{ + subsystem_mgr->add(name, subsystem, type, min_time_sec); +} + + // Save the current state as the initial state. void FGGlobals::saveInitialState () diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index e92cd7b7c..43d8ab946 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -29,6 +29,8 @@ #include #include STL_STRING +#include "fgfs.hxx" + SG_USING_STD( vector ); SG_USING_STD( string ); @@ -67,7 +69,6 @@ class FGModelMgr; class FGScenery; class FGSoundMgr; class FGSteam; -class FGSubsystemMgr; class FGTextureLoader; class FGTileMgr; class FGViewMgr; @@ -178,9 +179,15 @@ public: FGGlobals(); ~FGGlobals(); - inline FGSubsystemMgr * get_subsystem_mgr () const { - return subsystem_mgr; - } + virtual FGSubsystemMgr * get_subsystem_mgr () const; + + virtual FGSubsystem * get_subsystem (const char * name); + + virtual void add_subsystem (const char * name, + FGSubsystem * subsystem, + FGSubsystemMgr::GroupType + type = FGSubsystemMgr::GENERAL, + double min_time_sec = 0); inline double get_sim_time_sec () const { return sim_time_sec; } inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }