1
0
Fork 0

SGSubsystem classes: Switch to the new SGSubsystemMgr::add() functions.

Most subsystems are now created via the subsystem manager using the global
subsystem registrations.

The FGGlobals add_subsystem() and add_new_subsystem() methods have been removed
as the subsystem manager addition and creation function interface now exceeds
the functionality of these helper functions.
This commit is contained in:
Edward d'Auvergne 2018-05-07 09:09:20 +02:00 committed by James Turner
parent ad33e50324
commit c5aa3ca0f1
34 changed files with 127 additions and 142 deletions

View file

@ -91,7 +91,11 @@ The bind() and unbind() functions can be used to tie and untie properties.
Finally to create and have the subsystem managed: Finally to create and have the subsystem managed:
globals->add_subsystem("example", new FGSubsystemExample); globals->get_subsystem_mgr()->add<FGSubsystemExample>();
or:
globals->get_subsystem_mgr()->add("example");
Now the subsystem manager calls the update() function of this class every Now the subsystem manager calls the update() function of this class every
frame. dt is the time (in seconds) elapsed since the last call. frame. dt is the time (in seconds) elapsed since the last call.

View file

@ -782,7 +782,7 @@ readPanel (const SGPropertyNode * root, const SGPath& path)
KLN89* gps = (KLN89*)globals->get_subsystem("kln89"); KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
if (gps == NULL) { if (gps == NULL) {
gps = new KLN89(instrument); gps = new KLN89(instrument);
globals->add_subsystem("kln89", gps, SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add("kln89", gps);
} }
//gps->init(); // init seems to get called automagically. //gps->init(); // init seems to get called automagically.
FGSpecialInstrument* gpsinst = new FGSpecialInstrument(gps); FGSpecialInstrument* gpsinst = new FGSpecialInstrument(gps);

View file

@ -77,7 +77,6 @@
#include <simgear/package/Catalog.hxx> #include <simgear/package/Catalog.hxx>
#include <Add-ons/AddonManager.hxx> #include <Add-ons/AddonManager.hxx>
#include <Aircraft/controls.hxx> #include <Aircraft/controls.hxx>
#include <Aircraft/replay.hxx> #include <Aircraft/replay.hxx>
#include <Aircraft/FlightHistory.hxx> #include <Aircraft/FlightHistory.hxx>
@ -981,6 +980,9 @@ void fgCreateSubsystems(bool duringReset) {
SG_LOG( SG_GENERAL, SG_INFO, "== Creating Subsystems"); SG_LOG( SG_GENERAL, SG_INFO, "== Creating Subsystems");
// Fetch the subsystem manager.
auto mgr = globals->get_subsystem_mgr();
globals->get_event_mgr()->init(); globals->get_event_mgr()->init();
globals->get_event_mgr()->setRealtimeProperty(fgGetNode("/sim/time/delta-realtime-sec", true)); globals->get_event_mgr()->setRealtimeProperty(fgGetNode("/sim/time/delta-realtime-sec", true));
@ -988,21 +990,20 @@ void fgCreateSubsystems(bool duringReset) {
{ {
// Initialize the property interpolator subsystem. Put into the INIT // Initialize the property interpolator subsystem. Put into the INIT
// group because the "nasal" subsystem may need it at GENERAL take-down. // group because the "nasal" subsystem may need it at GENERAL take-down.
globals->add_subsystem("prop-interpolator", new FGInterpolator, SGSubsystemMgr::INIT); mgr->add<FGInterpolator>();
globals->add_new_subsystem<Highlight>(SGSubsystemMgr::INIT); mgr->add<Highlight>();
globals->add_subsystem("gui", new NewGUI, SGSubsystemMgr::INIT); mgr->add<NewGUI>();
} }
// SGSubsystemMgr::GENERAL // SGSubsystemMgr::GENERAL
{ {
globals->add_subsystem("properties", new FGProperties, SGSubsystemMgr::GENERAL); mgr->add<FGProperties>();
globals->add_new_subsystem<flightgear::AirportDynamicsManager>(SGSubsystemMgr::GENERAL); mgr->add<flightgear::AirportDynamicsManager>();
globals->add_subsystem("performance-mon", mgr->add("performance-mon",
new SGPerformanceMonitor( new SGPerformanceMonitor(
globals->get_subsystem_mgr(), mgr,
fgGetNode("/sim/performance-monitor", true) fgGetNode("/sim/performance-monitor", true)
), )
SGSubsystemMgr::GENERAL
); );
// Initialize the material property subsystem. // Initialize the material property subsystem.
@ -1014,54 +1015,54 @@ void fgCreateSubsystems(bool duringReset) {
// may exist already due to GUI startup or --load-tape=http... // may exist already due to GUI startup or --load-tape=http...
if (!globals->get_subsystem<FGHTTPClient>()) { if (!globals->get_subsystem<FGHTTPClient>()) {
globals->add_new_subsystem<FGHTTPClient>(SGSubsystemMgr::GENERAL); mgr->add<FGHTTPClient>();
} }
globals->add_new_subsystem<FGDNSClient>(SGSubsystemMgr::GENERAL); mgr->add<FGDNSClient>();
// Initialize the weather modeling subsystem // Initialize the weather modeling subsystem
globals->add_subsystem("environment", new FGEnvironmentMgr, SGSubsystemMgr::GENERAL); mgr->add<FGEnvironmentMgr>();
globals->add_new_subsystem<Ephemeris>(SGSubsystemMgr::GENERAL); mgr->add<Ephemeris>();
globals->add_subsystem( "xml-proprules", FGXMLAutopilotGroup::createInstance("property-rule"), SGSubsystemMgr::GENERAL ); mgr->add("xml-proprules", FGXMLAutopilotGroup::createInstance("property-rule"));
globals->add_new_subsystem<FGRouteMgr>(SGSubsystemMgr::GENERAL); mgr->add<FGRouteMgr>();
globals->add_subsystem( "io", new FGIO, SGSubsystemMgr::GENERAL ); mgr->add<FGIO>();
globals->add_subsystem("logger", new FGLogger, SGSubsystemMgr::GENERAL); mgr->add<FGLogger>();
globals->add_new_subsystem<FGControls>(SGSubsystemMgr::GENERAL); mgr->add<FGControls>();
globals->add_new_subsystem<FGInput>(SGSubsystemMgr::GENERAL); mgr->add<FGInput>();
globals->add_subsystem("history", new FGFlightHistory, SGSubsystemMgr::GENERAL); mgr->add<FGFlightHistory>();
{ {
SGSubsystem * httpd = flightgear::http::FGHttpd::createInstance( fgGetNode(flightgear::http::PROPERTY_ROOT) ); SGSubsystem * httpd = flightgear::http::FGHttpd::createInstance( fgGetNode(flightgear::http::PROPERTY_ROOT) );
if( NULL != httpd ) if( NULL != httpd )
globals->add_subsystem("httpd", httpd, SGSubsystemMgr::GENERAL ); mgr->add("httpd", httpd);
} }
if (!duringReset) { if (!duringReset) {
globals->add_subsystem("tides", new FGTide, SGSubsystemMgr::GENERAL ); mgr->add<FGTide>();
} }
} }
// SGSubsystemMgr::FDM // SGSubsystemMgr::FDM
{ {
globals->add_subsystem("flight", new FDMShell, SGSubsystemMgr::FDM); mgr->add<FDMShell>();
// Initialize the aircraft systems and instrumentation (before the // Initialize the aircraft systems and instrumentation (before the
// autopilot.) // autopilot.)
globals->add_subsystem("systems", new FGSystemMgr, SGSubsystemMgr::FDM); mgr->add<FGSystemMgr>();
globals->add_subsystem("instrumentation", new FGInstrumentMgr, SGSubsystemMgr::FDM); mgr->add<FGInstrumentMgr>();
globals->add_subsystem( "xml-autopilot", FGXMLAutopilotGroup::createInstance("autopilot"), SGSubsystemMgr::FDM ); mgr->add("xml-autopilot", FGXMLAutopilotGroup::createInstance("autopilot"));
} }
// SGSubsystemMgr::POST_FDM // SGSubsystemMgr::POST_FDM
{ {
globals->add_new_subsystem<PerformanceDB>(SGSubsystemMgr::POST_FDM); mgr->add<PerformanceDB>();
globals->add_subsystem("ATC", new FGATCManager, SGSubsystemMgr::POST_FDM); mgr->add<FGATCManager>();
globals->add_subsystem("ai-model", new FGAIManager, SGSubsystemMgr::POST_FDM); mgr->add<FGAIManager>();
globals->add_subsystem("mp", new FGMultiplayMgr, SGSubsystemMgr::POST_FDM); mgr->add<FGMultiplayMgr>();
#ifdef ENABLE_SWIFT #ifdef ENABLE_SWIFT
globals->add_subsystem("swift", new SwiftConnection, SGSubsystemMgr::POST_FDM); mgr->add<SwiftConnection>();
#endif #endif
// FGReplay. // FGReplay.
@ -1077,16 +1078,16 @@ void fgCreateSubsystems(bool duringReset) {
// problem where JSBSim appears to rely on FGReplay creating certain // problem where JSBSim appears to rely on FGReplay creating certain
// properties before it is initialised. This caused problems when // properties before it is initialised. This caused problems when
// FGReplay was changed to be POST_FDM. // FGReplay was changed to be POST_FDM.
globals->add_new_subsystem<FGReplay>(SGSubsystemMgr::POST_FDM) mgr->add<FGReplay>();
->init(); // Special case. mgr->get_subsystem("replay")->init(); // Special case.
//globals->add_subsystem("ai-model", new FGAIManager, SGSubsystemMgr::POST_FDM); //mgr->add<FGAIManager>();
globals->add_subsystem("submodel-mgr", new FGSubmodelMgr, SGSubsystemMgr::POST_FDM); mgr->add<FGSubmodelMgr>();
// It's probably a good idea to initialize the top level traffic manager // It's probably a good idea to initialize the top level traffic manager
// After the AI and ATC systems have been initialized properly. // After the AI and ATC systems have been initialized properly.
// AI Traffic manager // AI Traffic manager
globals->add_subsystem("traffic-manager", new FGTrafficManager, SGSubsystemMgr::POST_FDM); mgr->add<FGTrafficManager>();
fgSetArchivable("/sim/panel/visibility"); fgSetArchivable("/sim/panel/visibility");
fgSetArchivable("/sim/panel/x-offset"); fgSetArchivable("/sim/panel/x-offset");
@ -1096,32 +1097,32 @@ void fgCreateSubsystems(bool duringReset) {
// SGSubsystemMgr::DISPLAY // SGSubsystemMgr::DISPLAY
{ {
globals->add_subsystem("hud", new HUD, SGSubsystemMgr::DISPLAY); mgr->add<HUD>();
globals->add_subsystem("cockpit-displays", new flightgear::CockpitDisplayManager, SGSubsystemMgr::DISPLAY); mgr->add<flightgear::CockpitDisplayManager>();
simgear::canvas::Canvas::setSystemAdapter( simgear::canvas::Canvas::setSystemAdapter(
simgear::canvas::SystemAdapterPtr(new canvas::FGCanvasSystemAdapter) simgear::canvas::SystemAdapterPtr(new canvas::FGCanvasSystemAdapter)
); );
globals->add_subsystem("Canvas", new CanvasMgr, SGSubsystemMgr::DISPLAY); mgr->add<CanvasMgr>();
auto canvasGui = new GUIMgr; auto canvasGui = new GUIMgr;
globals->add_subsystem("CanvasGUI", canvasGui, SGSubsystemMgr::DISPLAY); mgr->add("CanvasGUI", canvasGui);
auto guiCamera = flightgear::getGUICamera(flightgear::CameraGroup::getDefault()); auto guiCamera = flightgear::getGUICamera(flightgear::CameraGroup::getDefault());
canvasGui->setGUIViewAndCamera(globals->get_renderer()->getView(), guiCamera); canvasGui->setGUIViewAndCamera(globals->get_renderer()->getView(), guiCamera);
#ifdef ENABLE_AUDIO_SUPPORT #ifdef ENABLE_AUDIO_SUPPORT
globals->add_subsystem("voice", new FGVoiceMgr, SGSubsystemMgr::DISPLAY); mgr->add<FGVoiceMgr>();
#endif #endif
// ordering here is important : Nasal (via events), then models, then views // ordering here is important : Nasal (via events), then models, then views
if (!duringReset) { if (!duringReset) {
globals->add_subsystem("lighting", new FGLight, SGSubsystemMgr::DISPLAY); mgr->add<FGLight>();
globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY); mgr->add("events", globals->get_event_mgr());
} }
globals->add_new_subsystem<FGAircraftModel>(SGSubsystemMgr::DISPLAY); mgr->add<FGAircraftModel>();
globals->add_new_subsystem<FGModelMgr>(SGSubsystemMgr::DISPLAY); mgr->add<FGModelMgr>();
globals->add_new_subsystem<FGViewMgr>(SGSubsystemMgr::DISPLAY); mgr->add<FGViewMgr>();
} }
// SGSubsystemMgr::SOUND // SGSubsystemMgr::SOUND
@ -1130,7 +1131,7 @@ void fgCreateSubsystems(bool duringReset) {
// to be updated in every loop. // to be updated in every loop.
// Sound manager is updated last so it can use the CPU while the GPU // Sound manager is updated last so it can use the CPU while the GPU
// is processing the scenery (doubled the frame-rate for me) -EMH- // is processing the scenery (doubled the frame-rate for me) -EMH-
globals->add_new_subsystem<FGSoundManager>(SGSubsystemMgr::SOUND); mgr->add<FGSoundManager>();
#ifdef ENABLE_IAX #ifdef ENABLE_IAX
// Initialize the FGCom subsystem. // Initialize the FGCom subsystem.
@ -1138,7 +1139,7 @@ void fgCreateSubsystems(bool duringReset) {
// depends on OpenAL, which is shutdown when the SOUND group // depends on OpenAL, which is shutdown when the SOUND group
// shutdown. // shutdown.
// Sentry: FLIGHTGEAR-66 // Sentry: FLIGHTGEAR-66
globals->add_new_subsystem<FGCom>(SGSubsystemMgr::SOUND); mgr->add<FGCom>();
#endif #endif
} }
} }
@ -1148,15 +1149,18 @@ void fgPostInitSubsystems()
SGTimeStamp st; SGTimeStamp st;
st.stamp(); st.stamp();
// Fetch the subsystem manager.
auto mgr = globals->get_subsystem_mgr();
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Initialize the Nasal interpreter. // Initialize the Nasal interpreter.
// Do this last, so that the loaded scripts see initialized state // Do this last, so that the loaded scripts see initialized state
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
globals->add_new_subsystem<FGNasalSys>(SGSubsystemMgr::INIT); mgr->add<FGNasalSys>();
// initialize methods that depend on other subsystems. // initialize methods that depend on other subsystems.
st.stamp(); st.stamp();
globals->get_subsystem_mgr()->postinit(); mgr->postinit();
SG_LOG(SG_GENERAL, SG_INFO, "Subsystems postinit took:" << st.elapsedMSec()); SG_LOG(SG_GENERAL, SG_INFO, "Subsystems postinit took:" << st.elapsedMSec());
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -1190,8 +1194,7 @@ void fgStartReposition()
fgSetBool("/sim/signals/reinit", true); fgSetBool("/sim/signals/reinit", true);
fgSetBool("/sim/crashed", false); fgSetBool("/sim/crashed", false);
FDMShell* fdm = globals->get_subsystem<FDMShell>(); globals->get_subsystem("flight")->unbind();
fdm->unbind();
// update our position based on current presets // update our position based on current presets
// this will mark position as needed finalized which we'll do in the // this will mark position as needed finalized which we'll do in the
@ -1227,7 +1230,7 @@ void fgStartReposition()
} }
// need to bind FDMshell again // need to bind FDMshell again
fdm->bind(); globals->get_subsystem("flight")->bind();
// need to reset aircraft (systems/instruments/autopilot) // need to reset aircraft (systems/instruments/autopilot)
// so they can adapt to current environment // so they can adapt to current environment

View file

@ -602,15 +602,6 @@ FGGlobals::get_subsystem (const char * name) const
return subsystem_mgr->get_subsystem(name); return subsystem_mgr->get_subsystem(name);
} }
void
FGGlobals::add_subsystem (const char * name,
SGSubsystem * subsystem,
SGSubsystemMgr::GroupType type,
double min_time_sec)
{
subsystem_mgr->add(name, subsystem, type, min_time_sec);
}
SGEventMgr * SGEventMgr *
FGGlobals::get_event_mgr () const FGGlobals::get_event_mgr () const
{ {

View file

@ -180,19 +180,6 @@ public:
} }
void add_subsystem (const char * name,
SGSubsystem * subsystem,
SGSubsystemMgr::GroupType type,
double min_time_sec = 0);
template<class T>
T* add_new_subsystem (SGSubsystemMgr::GroupType type, double min_time_sec = 0)
{
T* sub = new T;
add_subsystem(T::staticSubsystemClassId(), sub, type, min_time_sec);
return sub;
}
SGEventMgr *get_event_mgr () const; SGEventMgr *get_event_mgr () const;
inline double get_sim_time_sec () const { return sim_time_sec; } inline double get_sim_time_sec () const { return sim_time_sec; }

View file

@ -186,9 +186,8 @@ static void initTerrasync()
// hence not downloaded again. // hence not downloaded again.
fgSetString("/sim/terrasync/installation-dir", (globals->get_fg_root() / "Scenery").utf8Str()); fgSetString("/sim/terrasync/installation-dir", (globals->get_fg_root() / "Scenery").utf8Str());
simgear::SGTerraSync* terra_sync = new simgear::SGTerraSync(); auto terra_sync = globals->get_subsystem_mgr()->add<simgear::SGTerraSync>();
terra_sync->setRoot(globals->get_props()); terra_sync->setRoot(globals->get_props());
globals->add_subsystem("terrasync", terra_sync, SGSubsystemMgr::GENERAL);
terra_sync->bind(); terra_sync->bind();
terra_sync->init(); terra_sync->init();
@ -338,7 +337,7 @@ static void fgIdleFunction ( void ) {
} else if ( idle_state == 4 ) { } else if ( idle_state == 4 ) {
idle_state++; idle_state++;
globals->add_new_subsystem<TimeManager>(SGSubsystemMgr::INIT); globals->get_subsystem_mgr()->add<TimeManager>();
// Do some quick general initializations // Do some quick general initializations
if( !fgInitGeneral()) { if( !fgInitGeneral()) {
@ -375,9 +374,9 @@ static void fgIdleFunction ( void ) {
// Initialize the TG scenery subsystem. // Initialize the TG scenery subsystem.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
globals->add_new_subsystem<FGScenery>(SGSubsystemMgr::DISPLAY); auto scenery = globals->get_subsystem_mgr()->add<FGScenery>();
globals->get_scenery()->init(); scenery->init();
globals->get_scenery()->bind(); scenery->bind();
fgSplashProgress("creating-subsystems"); fgSplashProgress("creating-subsystems");
} else if (( idle_state == 7 ) || (idle_state == 2007)) { } else if (( idle_state == 7 ) || (idle_state == 2007)) {
@ -705,7 +704,7 @@ int fgMainInit( int argc, char **argv )
fgInitSecureMode(); fgInitSecureMode();
fgInitAircraftPaths(false); fgInitAircraftPaths(false);
auto errorManager = globals->add_new_subsystem<flightgear::ErrorReporter>(SGSubsystemMgr::GENERAL); auto errorManager = globals->get_subsystem_mgr()->add<flightgear::ErrorReporter>();
errorManager->preinit(); errorManager->preinit();
configResult = fgInitAircraft(false, didUseLauncher); configResult = fgInitAircraft(false, didUseLauncher);
@ -756,7 +755,7 @@ int fgMainInit( int argc, char **argv )
// Copy the property nodes for the menus added by registered add-ons // Copy the property nodes for the menus added by registered add-ons
addons::AddonManager::instance()->addAddonMenusToFGMenubar(); addons::AddonManager::instance()->addAddonMenusToFGMenubar();
auto presets = globals->add_new_subsystem<flightgear::GraphicsPresets>(SGSubsystemMgr::DISPLAY); auto presets = globals->get_subsystem_mgr()->add<flightgear::GraphicsPresets>();
presets->applyInitialPreset(); presets->applyInitialPreset();
// Initialize the Window/Graphics environment. // Initialize the Window/Graphics environment.

View file

@ -93,7 +93,7 @@ FGHTTPClient* FGHTTPClient::getOrCreate()
return ext; return ext;
} }
ext = globals->add_new_subsystem<FGHTTPClient>(SGSubsystemMgr::GENERAL); ext = globals->get_subsystem_mgr()->add<FGHTTPClient>();
ext->init(); ext->init();
return ext; return ext;
} }

View file

@ -228,7 +228,7 @@ fgviewerMain(int argc, char** argv)
// Now init the renderer, as we've got all the options, globals etc. // Now init the renderer, as we've got all the options, globals etc.
fgrenderer->init(); fgrenderer->init();
FGScenery* scenery = globals->add_new_subsystem<FGScenery>(SGSubsystemMgr::DISPLAY); auto scenery = globals->get_subsystem_mgr()->add<FGScenery>();
scenery->init(); scenery->init();
scenery->bind(); scenery->bind();

View file

@ -49,7 +49,7 @@ TestPilot::TestPilot(SGPropertyNode_ptr props) :
_groundspeedKnotsProp = _propRoot->getNode("velocities/groundspeed-kt", true); _groundspeedKnotsProp = _propRoot->getNode("velocities/groundspeed-kt", true);
_verticalFPMProp = _propRoot->getNode("velocities/vertical-fpm", true); _verticalFPMProp = _propRoot->getNode("velocities/vertical-fpm", true);
globals->add_subsystem("flight", this, SGSubsystemMgr::FDM); globals->get_subsystem_mgr()->add("flight", this);
} }
TestPilot::~TestPilot() TestPilot::~TestPilot()

View file

@ -48,7 +48,7 @@ void initScenery()
render->setView(viewer.get()); render->setView(viewer.get());
// Start up the scenery subsystem. // Start up the scenery subsystem.
globals->add_new_subsystem<FGScenery>(SGSubsystemMgr::DISPLAY); globals->get_subsystem_mgr()->add<FGScenery>();
globals->get_scenery()->init(); globals->get_scenery()->init();
globals->get_scenery()->bind(); globals->get_scenery()->bind();
} }

View file

@ -69,7 +69,7 @@ void initTestGlobals(const std::string& testName)
fgSetDefaults(); fgSetDefaults();
auto t = globals->add_new_subsystem<TimeManager>(SGSubsystemMgr::INIT); auto t = globals->get_subsystem_mgr()->add<TimeManager>();
t->bind(); t->bind();
t->init(); // establish mag-var data t->init(); // establish mag-var data
@ -79,7 +79,7 @@ void initTestGlobals(const std::string& testName)
* Here the event manager is added to the subsystem manager so it can be * Here the event manager is added to the subsystem manager so it can be
* destroyed via the subsystem manager. * destroyed via the subsystem manager.
*/ */
globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY); globals->get_subsystem_mgr()->add("events", globals->get_event_mgr());
// necessary to avoid asserts: mark FGLocale as initialized // necessary to avoid asserts: mark FGLocale as initialized
globals->get_locale()->selectLanguage({}); globals->get_locale()->selectLanguage({});
@ -169,10 +169,10 @@ void initStandardNasal(bool withCanvas)
nasalNode->setBoolValue("local_weather/enabled", false); nasalNode->setBoolValue("local_weather/enabled", false);
// Nasal needs the interpolator running // Nasal needs the interpolator running
globals->add_subsystem("prop-interpolator", new FGInterpolator, SGSubsystemMgr::INIT); globals->get_subsystem_mgr()->add<FGInterpolator>();
// will be inited, since we already did that // will be inited, since we already did that
globals->add_new_subsystem<FGNasalSys>(SGSubsystemMgr::INIT); globals->get_subsystem_mgr()->add<FGNasalSys>();
} }
void populateFPWithoutNasal(flightgear::FlightPlanRef f, void populateFPWithoutNasal(flightgear::FlightPlanRef f,

View file

@ -31,7 +31,7 @@ void CanvasTests::setUp()
simgear::canvas::SystemAdapterPtr(new canvas::FGCanvasSystemAdapter) simgear::canvas::SystemAdapterPtr(new canvas::FGCanvasSystemAdapter)
); );
globals->add_subsystem("Canvas", new CanvasMgr, SGSubsystemMgr::DISPLAY); globals->get_subsystem_mgr()->add<CanvasMgr>();
globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->bind();
globals->get_subsystem_mgr()->init(); globals->get_subsystem_mgr()->init();

View file

@ -85,9 +85,10 @@ void AeroMeshTests::testLiftComputation()
props->setDoubleValue("geometry/wing/chord-ft", c); props->setDoubleValue("geometry/wing/chord-ft", c);
props->setDoubleValue("geometry/weight-lbs", weight); props->setDoubleValue("geometry/weight-lbs", weight);
globals->add_new_subsystem<PerformanceDB>(SGSubsystemMgr::POST_FDM); auto subsystem_mgr = globals->get_subsystem_mgr();
globals->get_subsystem<PerformanceDB>()->bind(); subsystem_mgr->add<PerformanceDB>();
globals->get_subsystem<PerformanceDB>()->init(); subsystem_mgr->get_subsystem<PerformanceDB>()->bind();
subsystem_mgr->get_subsystem<PerformanceDB>()->init();
FGAIManager *aiManager = new FGAIManager; FGAIManager *aiManager = new FGAIManager;
FGAIAircraft *ai = new FGAIAircraft; FGAIAircraft *ai = new FGAIAircraft;

View file

@ -120,10 +120,10 @@ void GPSTests::testGPS()
FGRouteMgr* rm = new FGRouteMgr; FGRouteMgr* rm = new FGRouteMgr;
globals->add_subsystem( "route-manager", rm ); globals->get_subsystem_mgr()->add( "route-manager", rm );
// FGEnvironmentMgr* envMgr = new FGEnvironmentMgr; // FGEnvironmentMgr* envMgr = new FGEnvironmentMgr;
// globals->add_subsystem("environment", envMgr); // globals->get_subsystem_mgr()->add("environment", envMgr);
// envMgr->init(); // envMgr->init();
fgSetBool("/sim/realism/simple-gps", true); fgSetBool("/sim/realism/simple-gps", true);
@ -132,7 +132,7 @@ void GPSTests::testGPS()
SGPropertyNode* nd = fgGetNode("/instrumentation/gps", true); SGPropertyNode* nd = fgGetNode("/instrumentation/gps", true);
GPS* gps = new GPS(nd); GPS* gps = new GPS(nd);
globals->add_subsystem("gps", gps); globals->get_subsystem_mgr()->add("gps", gps);
const FGAirport* egph = fgFindAirportID("EGPH"); const FGAirport* egph = fgFindAirportID("EGPH");
testSetPosition(egph->geod()); testSetPosition(egph->geod());

View file

@ -49,7 +49,7 @@ void AIFlightPlanTests::setUp()
FGTestApi::setUp::initTestGlobals("AI"); FGTestApi::setUp::initTestGlobals("AI");
FGTestApi::setUp::initNavDataCache(); FGTestApi::setUp::initNavDataCache();
globals->add_new_subsystem<FGAIManager>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<FGAIManager>();
auto props = globals->get_props(); auto props = globals->get_props();
props->setBoolValue("sim/ai/enabled", true); props->setBoolValue("sim/ai/enabled", true);

View file

@ -45,7 +45,7 @@ void AIManagerTests::setUp()
FGTestApi::setUp::initTestGlobals("AI"); FGTestApi::setUp::initTestGlobals("AI");
FGTestApi::setUp::initNavDataCache(); FGTestApi::setUp::initNavDataCache();
globals->add_new_subsystem<FGAIManager>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<FGAIManager>();
auto props = globals->get_props(); auto props = globals->get_props();
props->setBoolValue("sim/ai/enabled", true); props->setBoolValue("sim/ai/enabled", true);

View file

@ -55,7 +55,7 @@ void TrafficMgrTests::tearDown()
} }
void TrafficMgrTests::testParse() { void TrafficMgrTests::testParse() {
globals->add_new_subsystem<FGTrafficManager>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<FGTrafficManager>();
globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->bind();
globals->get_subsystem_mgr()->init(); globals->get_subsystem_mgr()->init();
@ -107,7 +107,7 @@ void TrafficMgrTests::testTrafficManager()
FGTestApi::setPositionAndStabilise(egeo->geod()); FGTestApi::setPositionAndStabilise(egeo->geod());
auto tmgr = globals->add_new_subsystem<FGTrafficManager>(SGSubsystemMgr::GENERAL); auto tmgr = globals->get_subsystem_mgr()->add<FGTrafficManager>();
tmgr->bind(); tmgr->bind();
tmgr->init(); tmgr->init();

View file

@ -68,10 +68,10 @@ void GroundnetTests::setUp()
ybbn->testSuiteInjectGroundnetXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "YBBN.groundnet.xml"); ybbn->testSuiteInjectGroundnetXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "YBBN.groundnet.xml");
globals->add_new_subsystem<PerformanceDB>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<PerformanceDB>();
globals->add_new_subsystem<FGATCManager>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<FGATCManager>();
globals->add_new_subsystem<FGAIManager>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<FGAIManager>();
globals->add_new_subsystem<flightgear::AirportDynamicsManager>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<flightgear::AirportDynamicsManager>();
globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->bind();
globals->get_subsystem_mgr()->init(); globals->get_subsystem_mgr()->init();

View file

@ -49,8 +49,8 @@ void SubmodelsTests::setUp()
props->setBoolValue("sim/ai/enabled", true); props->setBoolValue("sim/ai/enabled", true);
props->setStringValue("sim/submodels/path", "Aircraft/Test/submodels.xml"); props->setStringValue("sim/submodels/path", "Aircraft/Test/submodels.xml");
globals->add_new_subsystem<FGAIManager>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<FGAIManager>();
globals->add_new_subsystem<FGSubmodelMgr>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<FGSubmodelMgr>();
globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->bind();
globals->get_subsystem_mgr()->init(); globals->get_subsystem_mgr()->init();

View file

@ -89,11 +89,11 @@ void TrafficTests::setUp()
FGAirportRef ybbn = FGAirport::getByIdent("YBBN"); FGAirportRef ybbn = FGAirport::getByIdent("YBBN");
ybbn->testSuiteInjectGroundnetXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "YBBN.groundnet.xml"); ybbn->testSuiteInjectGroundnetXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "YBBN.groundnet.xml");
globals->add_new_subsystem<PerformanceDB>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<PerformanceDB>();
globals->add_new_subsystem<FGATCManager>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<FGATCManager>();
globals->add_new_subsystem<FGAIManager>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<FGAIManager>();
globals->add_new_subsystem<flightgear::AirportDynamicsManager>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<flightgear::AirportDynamicsManager>();
globals->add_new_subsystem<FGTrafficManager>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<FGTrafficManager>();
globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->bind();
globals->get_subsystem_mgr()->init(); globals->get_subsystem_mgr()->init();

View file

@ -56,7 +56,7 @@ void DigitalFilterTests::testNoise()
auto ap = new FGXMLAutopilot::Autopilot(globals->get_props(), config); auto ap = new FGXMLAutopilot::Autopilot(globals->get_props(), config);
globals->add_subsystem("ap", ap, SGSubsystemMgr::FDM); globals->get_subsystem_mgr()->add("ap", ap);
ap->bind(); ap->bind();
ap->init(); ap->init();

View file

@ -102,7 +102,7 @@ void PidControllerTests::test(bool startup_current)
auto ap = new FGXMLAutopilot::Autopilot(globals->get_props(), config); auto ap = new FGXMLAutopilot::Autopilot(globals->get_props(), config);
globals->add_subsystem("ap", ap, SGSubsystemMgr::FDM); globals->get_subsystem_mgr()->add("ap", ap);
ap->bind(); ap->bind();
ap->init(); ap->init();

View file

@ -51,7 +51,7 @@ SGSubsystemRef CommRadioTests::setupStandardRadio(const std::string& name, int i
r->bind(); r->bind();
r->init(); r->init();
globals->add_subsystem("comm-radio", r, SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add("comm-radio", r);
return r; return r;
} }

View file

@ -104,13 +104,13 @@ GPS* GPSTests::setupStandardGPS(SGPropertyNode_ptr config,
gps->bind(); gps->bind();
gps->init(); gps->init();
globals->add_subsystem("gps", gps, SGSubsystemMgr::POST_FDM); globals->get_subsystem_mgr()->add("gps", gps);
return gps; return gps;
} }
void GPSTests::setupRouteManager() void GPSTests::setupRouteManager()
{ {
auto rm = globals->add_new_subsystem<FGRouteMgr>(SGSubsystemMgr::GENERAL); auto rm = globals->get_subsystem_mgr()->add<FGRouteMgr>();
rm->bind(); rm->bind();
rm->init(); rm->init();
rm->postinit(); rm->postinit();

View file

@ -111,13 +111,13 @@ GPS* HoldControllerTests::setupStandardGPS(SGPropertyNode_ptr config,
gps->bind(); gps->bind();
gps->init(); gps->init();
globals->add_subsystem("gps", gps, SGSubsystemMgr::POST_FDM); globals->get_subsystem_mgr()->add("gps", gps);
return gps; return gps;
} }
void HoldControllerTests::setupRouteManager() void HoldControllerTests::setupRouteManager()
{ {
auto rm = globals->add_new_subsystem<FGRouteMgr>(SGSubsystemMgr::GENERAL); auto rm = globals->get_subsystem_mgr()->add<FGRouteMgr>();
rm->bind(); rm->bind();
rm->init(); rm->init();
rm->postinit(); rm->postinit();

View file

@ -170,13 +170,13 @@ GPS* RNAVProcedureTests::setupStandardGPS(SGPropertyNode_ptr config,
gps->bind(); gps->bind();
gps->init(); gps->init();
globals->add_subsystem("gps", gps, SGSubsystemMgr::POST_FDM); globals->get_subsystem_mgr()->add("gps", gps);
return gps; return gps;
} }
void RNAVProcedureTests::setupRouteManager() void RNAVProcedureTests::setupRouteManager()
{ {
auto rm = globals->add_new_subsystem<FGRouteMgr>(SGSubsystemMgr::GENERAL); auto rm = globals->get_subsystem_mgr()->add<FGRouteMgr>();
rm->bind(); rm->bind();
rm->init(); rm->init();
rm->postinit(); rm->postinit();

View file

@ -40,7 +40,7 @@ SGSubsystemRef TransponderTests::setupStandardTransponder(const std::string& nam
r->bind(); r->bind();
r->init(); r->init();
globals->add_subsystem("transponder", r, SGSubsystemMgr::FDM); globals->get_subsystem_mgr()->add("transponder", r);
return r; return r;
} }

View file

@ -61,10 +61,10 @@ void PosInitTests::setUp()
apt->testSuiteInjectGroundnetXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "EDDF.groundnet.xml"); apt->testSuiteInjectGroundnetXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "EDDF.groundnet.xml");
globals->add_new_subsystem<flightgear::AirportDynamicsManager>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<flightgear::AirportDynamicsManager>();
globals->add_new_subsystem<PerformanceDB>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<PerformanceDB>();
globals->add_new_subsystem<FGATCManager>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<FGATCManager>();
globals->add_new_subsystem<FGAIManager>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<FGAIManager>();
} }

View file

@ -34,7 +34,7 @@ void FPNasalTests::setUp()
} }
// flightplan() acces needs the route manager // flightplan() acces needs the route manager
globals->add_new_subsystem<FGRouteMgr>(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->add<FGRouteMgr>();
globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->bind();
globals->get_subsystem_mgr()->init(); globals->get_subsystem_mgr()->init();

View file

@ -50,7 +50,7 @@ void RouteManagerTests::setUp()
globals->append_fg_scenery(proceduresPath); globals->append_fg_scenery(proceduresPath);
} }
globals->add_new_subsystem<FGRouteMgr>(SGSubsystemMgr::FDM); globals->get_subsystem_mgr()->add<FGRouteMgr>();
// setup the default GPS, which is needed for waypoint // setup the default GPS, which is needed for waypoint
// sequencing to work // sequencing to work
@ -63,7 +63,7 @@ void RouteManagerTests::setUp()
SGPropertyNode_ptr node = globals->get_props()->getNode("instrumentation", true)->getChild("gps", 0, true); SGPropertyNode_ptr node = globals->get_props()->getNode("instrumentation", true)->getChild("gps", 0, true);
// node->setBoolValue("serviceable", true); // node->setBoolValue("serviceable", true);
// globals->get_props()->setDoubleValue("systems/electrical/outputs/gps", 6.0); // globals->get_props()->setDoubleValue("systems/electrical/outputs/gps", 6.0);
globals->add_subsystem("gps", gps, SGSubsystemMgr::POST_FDM); globals->get_subsystem_mgr()->add("gps", gps);
globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->bind();
globals->get_subsystem_mgr()->init(); globals->get_subsystem_mgr()->init();

View file

@ -29,7 +29,7 @@ std::vector<SGSharedPtr<FGAIBase>> SwiftAircraftManagerTest::getAIList()
void SwiftAircraftManagerTest::testAircraftManager() void SwiftAircraftManagerTest::testAircraftManager()
{ {
globals->add_new_subsystem<FGAIManager>(SGSubsystemMgr::POST_FDM); globals->get_subsystem_mgr()->add<FGAIManager>();
globals->get_subsystem<FGAIManager>()->bind(); globals->get_subsystem<FGAIManager>()->bind();
globals->get_subsystem<FGAIManager>()->init(); globals->get_subsystem<FGAIManager>()->init();

View file

@ -38,13 +38,13 @@ void NasalGCTests::setUp()
fgInitAllowedPaths(); fgInitAllowedPaths();
auto nasalNode = globals->get_props()->getNode("nasal", true); auto nasalNode = globals->get_props()->getNode("nasal", true);
globals->add_subsystem("prop-interpolator", new FGInterpolator, SGSubsystemMgr::INIT); globals->get_subsystem_mgr()->add<FGInterpolator>();
globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->bind();
globals->get_subsystem_mgr()->init(); globals->get_subsystem_mgr()->init();
global_nasalMinimalInit = true; global_nasalMinimalInit = true;
globals->add_new_subsystem<FGNasalSys>(SGSubsystemMgr::INIT); globals->get_subsystem_mgr()->add<FGNasalSys>();
globals->get_subsystem_mgr()->postinit(); globals->get_subsystem_mgr()->postinit();
} }

View file

@ -42,12 +42,12 @@ void NasalSysTests::setUp()
fgInitAllowedPaths(); fgInitAllowedPaths();
globals->get_props()->getNode("nasal", true); globals->get_props()->getNode("nasal", true);
globals->add_subsystem("prop-interpolator", new FGInterpolator, SGSubsystemMgr::INIT); globals->get_subsystem_mgr()->add<FGInterpolator>();
globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->bind();
globals->get_subsystem_mgr()->init(); globals->get_subsystem_mgr()->init();
globals->add_new_subsystem<FGNasalSys>(SGSubsystemMgr::INIT); globals->get_subsystem_mgr()->add<FGNasalSys>();
globals->get_subsystem_mgr()->postinit(); globals->get_subsystem_mgr()->postinit();
} }

View file

@ -49,7 +49,7 @@ void ViewsTests::tearDown()
void ViewsTests::testBasic() void ViewsTests::testBasic()
{ {
auto vm = globals->add_new_subsystem<FGViewMgr>(SGSubsystemMgr::DISPLAY); auto vm = globals->get_subsystem_mgr()->add<FGViewMgr>();
CPPUNIT_ASSERT_EQUAL(static_cast<flightgear::View*>(nullptr), vm->get_current_view()); CPPUNIT_ASSERT_EQUAL(static_cast<flightgear::View*>(nullptr), vm->get_current_view());