1
0
Fork 0

Simplify subsystem handling through FGGlobals.

This commit is contained in:
david 2003-01-16 16:01:26 +00:00
parent b2518a0056
commit 2256c3d5fd
5 changed files with 44 additions and 31 deletions

View 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);
////////////////////////////////////////////////////////////////////

View 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);

View 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);

View 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 ()

View 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; }