]> git.mxchange.org Git - flightgear.git/commitdiff
Simplify subsystem handling through FGGlobals.
authordavid <david>
Thu, 16 Jan 2003 16:01:26 +0000 (16:01 +0000)
committerdavid <david>
Thu, 16 Jan 2003 16:01:26 +0000 (16:01 +0000)
src/Main/fg_init.cxx
src/Main/fgfs.cxx
src/Main/fgfs.hxx
src/Main/globals.cxx
src/Main/globals.hxx

index 6728b5e363a2f5c628e84c39f5c2cbaf63760aae..b145aa6b162291b98256235e89540cbe8f273da4 100644 (file)
@@ -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);
 
 
     ////////////////////////////////////////////////////////////////////
index fda5ddf4ef2851a8a6a81cf81331a051ced0afec..e66db61ebd46e4700b67c635306a2b24aec833ad 100644 (file)
@@ -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);
index 08a335a6267d9feeaa888581c9baca4a38d65eab..4d97d23dfa43a8475b33b941702f235b8027c6a1 100644 (file)
@@ -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);
index ee093bada0d3be73cb19de97cad714e01823a5b0..f64bdbe256f342ca390d415773f2112b75429182 100644 (file)
@@ -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 ()
index e92cd7b7c78d7a90c9f94229712a94c1c569dc78..43d8ab94618ef435f8b198d225f108df9c688368 100644 (file)
@@ -29,6 +29,8 @@
 #include <vector>
 #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; }