From c5aa3ca0f16394067de071b11cedbf251fe62e3f Mon Sep 17 00:00:00 2001 From: Edward d'Auvergne Date: Mon, 7 May 2018 09:09:20 +0200 Subject: [PATCH] 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. --- docs-mini/README.introduction | 6 +- src/Cockpit/panel_io.cxx | 2 +- src/Main/fg_init.cxx | 117 +++++++++--------- src/Main/globals.cxx | 9 -- src/Main/globals.hxx | 13 -- src/Main/main.cxx | 15 ++- src/Network/HTTPClient.cxx | 2 +- src/Viewer/fgviewer.cxx | 2 +- test_suite/FGTestApi/TestPilot.cxx | 2 +- test_suite/FGTestApi/scene_graph.cxx | 2 +- test_suite/FGTestApi/testGlobals.cxx | 8 +- .../simgear_tests/canvas/testCanvas.cxx | 2 +- test_suite/system_tests/FDM/testAeroMesh.cxx | 7 +- .../system_tests/Instrumentation/testgps.cxx | 6 +- .../unit_tests/AI/test_AIFlightPlan.cxx | 2 +- test_suite/unit_tests/AI/test_AIManager.cxx | 2 +- test_suite/unit_tests/AI/test_TrafficMgr.cxx | 4 +- test_suite/unit_tests/AI/test_groundnet.cxx | 8 +- test_suite/unit_tests/AI/test_submodels.cxx | 4 +- test_suite/unit_tests/AI/test_traffic.cxx | 10 +- .../Autopilot/testDigitalFilter.cxx | 2 +- .../Autopilot/testPidController.cxx | 2 +- .../Instrumentation/test_commRadio.cxx | 2 +- .../unit_tests/Instrumentation/test_gps.cxx | 4 +- .../Instrumentation/test_hold_controller.cxx | 4 +- .../Instrumentation/test_rnav_procedures.cxx | 4 +- .../Instrumentation/test_transponder.cxx | 2 +- test_suite/unit_tests/Main/test_posinit.cxx | 8 +- .../unit_tests/Navaids/test_fpNasal.cxx | 2 +- .../unit_tests/Navaids/test_routeManager.cxx | 4 +- .../Network/test_swiftAircraftManager.cxx | 2 +- test_suite/unit_tests/Scripting/testGC.cxx | 4 +- .../unit_tests/Scripting/testNasalSys.cxx | 4 +- test_suite/unit_tests/general/test_Views.cxx | 2 +- 34 files changed, 127 insertions(+), 142 deletions(-) diff --git a/docs-mini/README.introduction b/docs-mini/README.introduction index e1732763b..e23d16ea4 100644 --- a/docs-mini/README.introduction +++ b/docs-mini/README.introduction @@ -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: - globals->add_subsystem("example", new FGSubsystemExample); + globals->get_subsystem_mgr()->add(); + +or: + + globals->get_subsystem_mgr()->add("example"); Now the subsystem manager calls the update() function of this class every frame. dt is the time (in seconds) elapsed since the last call. diff --git a/src/Cockpit/panel_io.cxx b/src/Cockpit/panel_io.cxx index fb40dc5ca..be26c75a7 100644 --- a/src/Cockpit/panel_io.cxx +++ b/src/Cockpit/panel_io.cxx @@ -782,7 +782,7 @@ readPanel (const SGPropertyNode * root, const SGPath& path) KLN89* gps = (KLN89*)globals->get_subsystem("kln89"); if (gps == NULL) { 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. FGSpecialInstrument* gpsinst = new FGSpecialInstrument(gps); diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 0b57a2676..94731fde9 100755 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -77,7 +77,6 @@ #include #include - #include #include #include @@ -981,6 +980,9 @@ void fgCreateSubsystems(bool duringReset) { 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()->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 // group because the "nasal" subsystem may need it at GENERAL take-down. - globals->add_subsystem("prop-interpolator", new FGInterpolator, SGSubsystemMgr::INIT); - globals->add_new_subsystem(SGSubsystemMgr::INIT); - globals->add_subsystem("gui", new NewGUI, SGSubsystemMgr::INIT); + mgr->add(); + mgr->add(); + mgr->add(); } // SGSubsystemMgr::GENERAL { - globals->add_subsystem("properties", new FGProperties, SGSubsystemMgr::GENERAL); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_subsystem("performance-mon", + mgr->add(); + mgr->add(); + mgr->add("performance-mon", new SGPerformanceMonitor( - globals->get_subsystem_mgr(), + mgr, fgGetNode("/sim/performance-monitor", true) - ), - SGSubsystemMgr::GENERAL + ) ); // Initialize the material property subsystem. @@ -1014,54 +1015,54 @@ void fgCreateSubsystems(bool duringReset) { // may exist already due to GUI startup or --load-tape=http... if (!globals->get_subsystem()) { - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + mgr->add(); } - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + mgr->add(); // Initialize the weather modeling subsystem - globals->add_subsystem("environment", new FGEnvironmentMgr, SGSubsystemMgr::GENERAL); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_subsystem( "xml-proprules", FGXMLAutopilotGroup::createInstance("property-rule"), SGSubsystemMgr::GENERAL ); + mgr->add(); + mgr->add(); + mgr->add("xml-proprules", FGXMLAutopilotGroup::createInstance("property-rule")); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_subsystem( "io", new FGIO, SGSubsystemMgr::GENERAL ); - globals->add_subsystem("logger", new FGLogger, SGSubsystemMgr::GENERAL); + mgr->add(); + mgr->add(); + mgr->add(); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_subsystem("history", new FGFlightHistory, SGSubsystemMgr::GENERAL); + mgr->add(); + mgr->add(); + mgr->add(); { SGSubsystem * httpd = flightgear::http::FGHttpd::createInstance( fgGetNode(flightgear::http::PROPERTY_ROOT) ); if( NULL != httpd ) - globals->add_subsystem("httpd", httpd, SGSubsystemMgr::GENERAL ); + mgr->add("httpd", httpd); } if (!duringReset) { - globals->add_subsystem("tides", new FGTide, SGSubsystemMgr::GENERAL ); + mgr->add(); } } // SGSubsystemMgr::FDM { - globals->add_subsystem("flight", new FDMShell, SGSubsystemMgr::FDM); + mgr->add(); // Initialize the aircraft systems and instrumentation (before the // autopilot.) - globals->add_subsystem("systems", new FGSystemMgr, SGSubsystemMgr::FDM); - globals->add_subsystem("instrumentation", new FGInstrumentMgr, SGSubsystemMgr::FDM); - globals->add_subsystem( "xml-autopilot", FGXMLAutopilotGroup::createInstance("autopilot"), SGSubsystemMgr::FDM ); + mgr->add(); + mgr->add(); + mgr->add("xml-autopilot", FGXMLAutopilotGroup::createInstance("autopilot")); } // SGSubsystemMgr::POST_FDM { - globals->add_new_subsystem(SGSubsystemMgr::POST_FDM); - globals->add_subsystem("ATC", new FGATCManager, SGSubsystemMgr::POST_FDM); - globals->add_subsystem("ai-model", new FGAIManager, SGSubsystemMgr::POST_FDM); - globals->add_subsystem("mp", new FGMultiplayMgr, SGSubsystemMgr::POST_FDM); + mgr->add(); + mgr->add(); + mgr->add(); + mgr->add(); #ifdef ENABLE_SWIFT - globals->add_subsystem("swift", new SwiftConnection, SGSubsystemMgr::POST_FDM); + mgr->add(); #endif // FGReplay. @@ -1077,16 +1078,16 @@ void fgCreateSubsystems(bool duringReset) { // problem where JSBSim appears to rely on FGReplay creating certain // properties before it is initialised. This caused problems when // FGReplay was changed to be POST_FDM. - globals->add_new_subsystem(SGSubsystemMgr::POST_FDM) - ->init(); // Special case. + mgr->add(); + mgr->get_subsystem("replay")->init(); // Special case. - //globals->add_subsystem("ai-model", new FGAIManager, SGSubsystemMgr::POST_FDM); - globals->add_subsystem("submodel-mgr", new FGSubmodelMgr, SGSubsystemMgr::POST_FDM); + //mgr->add(); + mgr->add(); // It's probably a good idea to initialize the top level traffic manager // After the AI and ATC systems have been initialized properly. // AI Traffic manager - globals->add_subsystem("traffic-manager", new FGTrafficManager, SGSubsystemMgr::POST_FDM); + mgr->add(); fgSetArchivable("/sim/panel/visibility"); fgSetArchivable("/sim/panel/x-offset"); @@ -1096,32 +1097,32 @@ void fgCreateSubsystems(bool duringReset) { // SGSubsystemMgr::DISPLAY { - globals->add_subsystem("hud", new HUD, SGSubsystemMgr::DISPLAY); - globals->add_subsystem("cockpit-displays", new flightgear::CockpitDisplayManager, SGSubsystemMgr::DISPLAY); + mgr->add(); + mgr->add(); simgear::canvas::Canvas::setSystemAdapter( simgear::canvas::SystemAdapterPtr(new canvas::FGCanvasSystemAdapter) ); - globals->add_subsystem("Canvas", new CanvasMgr, SGSubsystemMgr::DISPLAY); + mgr->add(); auto canvasGui = new GUIMgr; - globals->add_subsystem("CanvasGUI", canvasGui, SGSubsystemMgr::DISPLAY); + mgr->add("CanvasGUI", canvasGui); auto guiCamera = flightgear::getGUICamera(flightgear::CameraGroup::getDefault()); canvasGui->setGUIViewAndCamera(globals->get_renderer()->getView(), guiCamera); #ifdef ENABLE_AUDIO_SUPPORT - globals->add_subsystem("voice", new FGVoiceMgr, SGSubsystemMgr::DISPLAY); + mgr->add(); #endif // ordering here is important : Nasal (via events), then models, then views if (!duringReset) { - globals->add_subsystem("lighting", new FGLight, SGSubsystemMgr::DISPLAY); - globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY); + mgr->add(); + mgr->add("events", globals->get_event_mgr()); } - globals->add_new_subsystem(SGSubsystemMgr::DISPLAY); - globals->add_new_subsystem(SGSubsystemMgr::DISPLAY); - globals->add_new_subsystem(SGSubsystemMgr::DISPLAY); + mgr->add(); + mgr->add(); + mgr->add(); } // SGSubsystemMgr::SOUND @@ -1130,7 +1131,7 @@ void fgCreateSubsystems(bool duringReset) { // to be updated in every loop. // 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- - globals->add_new_subsystem(SGSubsystemMgr::SOUND); + mgr->add(); #ifdef ENABLE_IAX // Initialize the FGCom subsystem. @@ -1138,7 +1139,7 @@ void fgCreateSubsystems(bool duringReset) { // depends on OpenAL, which is shutdown when the SOUND group // shutdown. // Sentry: FLIGHTGEAR-66 - globals->add_new_subsystem(SGSubsystemMgr::SOUND); + mgr->add(); #endif } } @@ -1147,16 +1148,19 @@ void fgPostInitSubsystems() { SGTimeStamp st; st.stamp(); - + + // Fetch the subsystem manager. + auto mgr = globals->get_subsystem_mgr(); + //////////////////////////////////////////////////////////////////////// // Initialize the Nasal interpreter. // Do this last, so that the loaded scripts see initialized state //////////////////////////////////////////////////////////////////////// - globals->add_new_subsystem(SGSubsystemMgr::INIT); + mgr->add(); // initialize methods that depend on other subsystems. st.stamp(); - globals->get_subsystem_mgr()->postinit(); + mgr->postinit(); SG_LOG(SG_GENERAL, SG_INFO, "Subsystems postinit took:" << st.elapsedMSec()); //////////////////////////////////////////////////////////////////////// @@ -1189,10 +1193,9 @@ void fgStartReposition() // set this signal so Nasal scripts can take action. fgSetBool("/sim/signals/reinit", true); fgSetBool("/sim/crashed", false); - - FDMShell* fdm = globals->get_subsystem(); - fdm->unbind(); - + + globals->get_subsystem("flight")->unbind(); + // update our position based on current presets // this will mark position as needed finalized which we'll do in the // main-loop @@ -1227,7 +1230,7 @@ void fgStartReposition() } // need to bind FDMshell again - fdm->bind(); + globals->get_subsystem("flight")->bind(); // need to reset aircraft (systems/instruments/autopilot) // so they can adapt to current environment diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 445c76d36..50311c70b 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -602,15 +602,6 @@ FGGlobals::get_subsystem (const char * name) const 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 * FGGlobals::get_event_mgr () const { diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index 5861abd55..e11fbef5c 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -180,19 +180,6 @@ public: } - void add_subsystem (const char * name, - SGSubsystem * subsystem, - SGSubsystemMgr::GroupType type, - double min_time_sec = 0); - - template - 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; inline double get_sim_time_sec () const { return sim_time_sec; } diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 7b8e7850b..60e9fd8c9 100755 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -186,9 +186,8 @@ static void initTerrasync() // hence not downloaded again. 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(); terra_sync->setRoot(globals->get_props()); - globals->add_subsystem("terrasync", terra_sync, SGSubsystemMgr::GENERAL); terra_sync->bind(); terra_sync->init(); @@ -338,7 +337,7 @@ static void fgIdleFunction ( void ) { } else if ( idle_state == 4 ) { idle_state++; - globals->add_new_subsystem(SGSubsystemMgr::INIT); + globals->get_subsystem_mgr()->add(); // Do some quick general initializations if( !fgInitGeneral()) { @@ -375,9 +374,9 @@ static void fgIdleFunction ( void ) { // Initialize the TG scenery subsystem. //////////////////////////////////////////////////////////////////// - globals->add_new_subsystem(SGSubsystemMgr::DISPLAY); - globals->get_scenery()->init(); - globals->get_scenery()->bind(); + auto scenery = globals->get_subsystem_mgr()->add(); + scenery->init(); + scenery->bind(); fgSplashProgress("creating-subsystems"); } else if (( idle_state == 7 ) || (idle_state == 2007)) { @@ -705,7 +704,7 @@ int fgMainInit( int argc, char **argv ) fgInitSecureMode(); fgInitAircraftPaths(false); - auto errorManager = globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + auto errorManager = globals->get_subsystem_mgr()->add(); errorManager->preinit(); 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 addons::AddonManager::instance()->addAddonMenusToFGMenubar(); - auto presets = globals->add_new_subsystem(SGSubsystemMgr::DISPLAY); + auto presets = globals->get_subsystem_mgr()->add(); presets->applyInitialPreset(); // Initialize the Window/Graphics environment. diff --git a/src/Network/HTTPClient.cxx b/src/Network/HTTPClient.cxx index 28aaabcd3..451115df3 100644 --- a/src/Network/HTTPClient.cxx +++ b/src/Network/HTTPClient.cxx @@ -93,7 +93,7 @@ FGHTTPClient* FGHTTPClient::getOrCreate() return ext; } - ext = globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + ext = globals->get_subsystem_mgr()->add(); ext->init(); return ext; } diff --git a/src/Viewer/fgviewer.cxx b/src/Viewer/fgviewer.cxx index 7027f61b2..81ed57611 100644 --- a/src/Viewer/fgviewer.cxx +++ b/src/Viewer/fgviewer.cxx @@ -228,7 +228,7 @@ fgviewerMain(int argc, char** argv) // Now init the renderer, as we've got all the options, globals etc. fgrenderer->init(); - FGScenery* scenery = globals->add_new_subsystem(SGSubsystemMgr::DISPLAY); + auto scenery = globals->get_subsystem_mgr()->add(); scenery->init(); scenery->bind(); diff --git a/test_suite/FGTestApi/TestPilot.cxx b/test_suite/FGTestApi/TestPilot.cxx index 49d591fcd..154aecde7 100644 --- a/test_suite/FGTestApi/TestPilot.cxx +++ b/test_suite/FGTestApi/TestPilot.cxx @@ -49,7 +49,7 @@ TestPilot::TestPilot(SGPropertyNode_ptr props) : _groundspeedKnotsProp = _propRoot->getNode("velocities/groundspeed-kt", true); _verticalFPMProp = _propRoot->getNode("velocities/vertical-fpm", true); - globals->add_subsystem("flight", this, SGSubsystemMgr::FDM); + globals->get_subsystem_mgr()->add("flight", this); } TestPilot::~TestPilot() diff --git a/test_suite/FGTestApi/scene_graph.cxx b/test_suite/FGTestApi/scene_graph.cxx index 6818f8984..c74dddfaf 100644 --- a/test_suite/FGTestApi/scene_graph.cxx +++ b/test_suite/FGTestApi/scene_graph.cxx @@ -48,7 +48,7 @@ void initScenery() render->setView(viewer.get()); // Start up the scenery subsystem. - globals->add_new_subsystem(SGSubsystemMgr::DISPLAY); + globals->get_subsystem_mgr()->add(); globals->get_scenery()->init(); globals->get_scenery()->bind(); } diff --git a/test_suite/FGTestApi/testGlobals.cxx b/test_suite/FGTestApi/testGlobals.cxx index fb1e936ad..a867827e8 100644 --- a/test_suite/FGTestApi/testGlobals.cxx +++ b/test_suite/FGTestApi/testGlobals.cxx @@ -69,7 +69,7 @@ void initTestGlobals(const std::string& testName) fgSetDefaults(); - auto t = globals->add_new_subsystem(SGSubsystemMgr::INIT); + auto t = globals->get_subsystem_mgr()->add(); t->bind(); 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 * 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 globals->get_locale()->selectLanguage({}); @@ -169,10 +169,10 @@ void initStandardNasal(bool withCanvas) nasalNode->setBoolValue("local_weather/enabled", false); // Nasal needs the interpolator running - globals->add_subsystem("prop-interpolator", new FGInterpolator, SGSubsystemMgr::INIT); + globals->get_subsystem_mgr()->add(); // will be inited, since we already did that - globals->add_new_subsystem(SGSubsystemMgr::INIT); + globals->get_subsystem_mgr()->add(); } void populateFPWithoutNasal(flightgear::FlightPlanRef f, diff --git a/test_suite/simgear_tests/canvas/testCanvas.cxx b/test_suite/simgear_tests/canvas/testCanvas.cxx index d4077cc8c..e5d317233 100644 --- a/test_suite/simgear_tests/canvas/testCanvas.cxx +++ b/test_suite/simgear_tests/canvas/testCanvas.cxx @@ -31,7 +31,7 @@ void CanvasTests::setUp() simgear::canvas::SystemAdapterPtr(new canvas::FGCanvasSystemAdapter) ); - globals->add_subsystem("Canvas", new CanvasMgr, SGSubsystemMgr::DISPLAY); + globals->get_subsystem_mgr()->add(); globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->init(); diff --git a/test_suite/system_tests/FDM/testAeroMesh.cxx b/test_suite/system_tests/FDM/testAeroMesh.cxx index e449233a6..252ba8bb5 100644 --- a/test_suite/system_tests/FDM/testAeroMesh.cxx +++ b/test_suite/system_tests/FDM/testAeroMesh.cxx @@ -85,9 +85,10 @@ void AeroMeshTests::testLiftComputation() props->setDoubleValue("geometry/wing/chord-ft", c); props->setDoubleValue("geometry/weight-lbs", weight); - globals->add_new_subsystem(SGSubsystemMgr::POST_FDM); - globals->get_subsystem()->bind(); - globals->get_subsystem()->init(); + auto subsystem_mgr = globals->get_subsystem_mgr(); + subsystem_mgr->add(); + subsystem_mgr->get_subsystem()->bind(); + subsystem_mgr->get_subsystem()->init(); FGAIManager *aiManager = new FGAIManager; FGAIAircraft *ai = new FGAIAircraft; diff --git a/test_suite/system_tests/Instrumentation/testgps.cxx b/test_suite/system_tests/Instrumentation/testgps.cxx index 5ed79bbf4..ab0a7aa9d 100644 --- a/test_suite/system_tests/Instrumentation/testgps.cxx +++ b/test_suite/system_tests/Instrumentation/testgps.cxx @@ -120,10 +120,10 @@ void GPSTests::testGPS() FGRouteMgr* rm = new FGRouteMgr; - globals->add_subsystem( "route-manager", rm ); + globals->get_subsystem_mgr()->add( "route-manager", rm ); // FGEnvironmentMgr* envMgr = new FGEnvironmentMgr; - // globals->add_subsystem("environment", envMgr); + // globals->get_subsystem_mgr()->add("environment", envMgr); // envMgr->init(); fgSetBool("/sim/realism/simple-gps", true); @@ -132,7 +132,7 @@ void GPSTests::testGPS() SGPropertyNode* nd = fgGetNode("/instrumentation/gps", true); GPS* gps = new GPS(nd); - globals->add_subsystem("gps", gps); + globals->get_subsystem_mgr()->add("gps", gps); const FGAirport* egph = fgFindAirportID("EGPH"); testSetPosition(egph->geod()); diff --git a/test_suite/unit_tests/AI/test_AIFlightPlan.cxx b/test_suite/unit_tests/AI/test_AIFlightPlan.cxx index 232332cb4..f9f1380a0 100644 --- a/test_suite/unit_tests/AI/test_AIFlightPlan.cxx +++ b/test_suite/unit_tests/AI/test_AIFlightPlan.cxx @@ -49,7 +49,7 @@ void AIFlightPlanTests::setUp() FGTestApi::setUp::initTestGlobals("AI"); FGTestApi::setUp::initNavDataCache(); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->get_subsystem_mgr()->add(); auto props = globals->get_props(); props->setBoolValue("sim/ai/enabled", true); diff --git a/test_suite/unit_tests/AI/test_AIManager.cxx b/test_suite/unit_tests/AI/test_AIManager.cxx index 65ffde3e4..d1c537bae 100644 --- a/test_suite/unit_tests/AI/test_AIManager.cxx +++ b/test_suite/unit_tests/AI/test_AIManager.cxx @@ -45,7 +45,7 @@ void AIManagerTests::setUp() FGTestApi::setUp::initTestGlobals("AI"); FGTestApi::setUp::initNavDataCache(); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->get_subsystem_mgr()->add(); auto props = globals->get_props(); props->setBoolValue("sim/ai/enabled", true); diff --git a/test_suite/unit_tests/AI/test_TrafficMgr.cxx b/test_suite/unit_tests/AI/test_TrafficMgr.cxx index 3f7893abc..136e9a401 100644 --- a/test_suite/unit_tests/AI/test_TrafficMgr.cxx +++ b/test_suite/unit_tests/AI/test_TrafficMgr.cxx @@ -55,7 +55,7 @@ void TrafficMgrTests::tearDown() } void TrafficMgrTests::testParse() { - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->get_subsystem_mgr()->add(); globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->init(); @@ -107,7 +107,7 @@ void TrafficMgrTests::testTrafficManager() FGTestApi::setPositionAndStabilise(egeo->geod()); - auto tmgr = globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + auto tmgr = globals->get_subsystem_mgr()->add(); tmgr->bind(); tmgr->init(); diff --git a/test_suite/unit_tests/AI/test_groundnet.cxx b/test_suite/unit_tests/AI/test_groundnet.cxx index 9056ee022..5950332d6 100644 --- a/test_suite/unit_tests/AI/test_groundnet.cxx +++ b/test_suite/unit_tests/AI/test_groundnet.cxx @@ -68,10 +68,10 @@ void GroundnetTests::setUp() ybbn->testSuiteInjectGroundnetXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "YBBN.groundnet.xml"); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->get_subsystem_mgr()->add(); + globals->get_subsystem_mgr()->add(); + globals->get_subsystem_mgr()->add(); + globals->get_subsystem_mgr()->add(); globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->init(); diff --git a/test_suite/unit_tests/AI/test_submodels.cxx b/test_suite/unit_tests/AI/test_submodels.cxx index 80f99e2a2..5b350ee5e 100644 --- a/test_suite/unit_tests/AI/test_submodels.cxx +++ b/test_suite/unit_tests/AI/test_submodels.cxx @@ -49,8 +49,8 @@ void SubmodelsTests::setUp() props->setBoolValue("sim/ai/enabled", true); props->setStringValue("sim/submodels/path", "Aircraft/Test/submodels.xml"); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->get_subsystem_mgr()->add(); + globals->get_subsystem_mgr()->add(); globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->init(); diff --git a/test_suite/unit_tests/AI/test_traffic.cxx b/test_suite/unit_tests/AI/test_traffic.cxx index 50a8a18a0..a6e83cdd1 100644 --- a/test_suite/unit_tests/AI/test_traffic.cxx +++ b/test_suite/unit_tests/AI/test_traffic.cxx @@ -89,11 +89,11 @@ void TrafficTests::setUp() FGAirportRef ybbn = FGAirport::getByIdent("YBBN"); ybbn->testSuiteInjectGroundnetXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "YBBN.groundnet.xml"); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->get_subsystem_mgr()->add(); + globals->get_subsystem_mgr()->add(); + globals->get_subsystem_mgr()->add(); + globals->get_subsystem_mgr()->add(); + globals->get_subsystem_mgr()->add(); globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->init(); diff --git a/test_suite/unit_tests/Autopilot/testDigitalFilter.cxx b/test_suite/unit_tests/Autopilot/testDigitalFilter.cxx index 3594d8a1f..73fc52a20 100644 --- a/test_suite/unit_tests/Autopilot/testDigitalFilter.cxx +++ b/test_suite/unit_tests/Autopilot/testDigitalFilter.cxx @@ -56,7 +56,7 @@ void DigitalFilterTests::testNoise() 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->init(); diff --git a/test_suite/unit_tests/Autopilot/testPidController.cxx b/test_suite/unit_tests/Autopilot/testPidController.cxx index 5ff3ae4a6..e804b2717 100644 --- a/test_suite/unit_tests/Autopilot/testPidController.cxx +++ b/test_suite/unit_tests/Autopilot/testPidController.cxx @@ -102,7 +102,7 @@ void PidControllerTests::test(bool startup_current) 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->init(); diff --git a/test_suite/unit_tests/Instrumentation/test_commRadio.cxx b/test_suite/unit_tests/Instrumentation/test_commRadio.cxx index 587c5798d..17cb393e2 100644 --- a/test_suite/unit_tests/Instrumentation/test_commRadio.cxx +++ b/test_suite/unit_tests/Instrumentation/test_commRadio.cxx @@ -51,7 +51,7 @@ SGSubsystemRef CommRadioTests::setupStandardRadio(const std::string& name, int i r->bind(); r->init(); - globals->add_subsystem("comm-radio", r, SGSubsystemMgr::GENERAL); + globals->get_subsystem_mgr()->add("comm-radio", r); return r; } diff --git a/test_suite/unit_tests/Instrumentation/test_gps.cxx b/test_suite/unit_tests/Instrumentation/test_gps.cxx index 83d64ddeb..56ffd9565 100644 --- a/test_suite/unit_tests/Instrumentation/test_gps.cxx +++ b/test_suite/unit_tests/Instrumentation/test_gps.cxx @@ -104,13 +104,13 @@ GPS* GPSTests::setupStandardGPS(SGPropertyNode_ptr config, gps->bind(); gps->init(); - globals->add_subsystem("gps", gps, SGSubsystemMgr::POST_FDM); + globals->get_subsystem_mgr()->add("gps", gps); return gps; } void GPSTests::setupRouteManager() { - auto rm = globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + auto rm = globals->get_subsystem_mgr()->add(); rm->bind(); rm->init(); rm->postinit(); diff --git a/test_suite/unit_tests/Instrumentation/test_hold_controller.cxx b/test_suite/unit_tests/Instrumentation/test_hold_controller.cxx index c9b91ce55..c9d7f64c1 100644 --- a/test_suite/unit_tests/Instrumentation/test_hold_controller.cxx +++ b/test_suite/unit_tests/Instrumentation/test_hold_controller.cxx @@ -111,13 +111,13 @@ GPS* HoldControllerTests::setupStandardGPS(SGPropertyNode_ptr config, gps->bind(); gps->init(); - globals->add_subsystem("gps", gps, SGSubsystemMgr::POST_FDM); + globals->get_subsystem_mgr()->add("gps", gps); return gps; } void HoldControllerTests::setupRouteManager() { - auto rm = globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + auto rm = globals->get_subsystem_mgr()->add(); rm->bind(); rm->init(); rm->postinit(); diff --git a/test_suite/unit_tests/Instrumentation/test_rnav_procedures.cxx b/test_suite/unit_tests/Instrumentation/test_rnav_procedures.cxx index 2519f70a9..befb7361c 100644 --- a/test_suite/unit_tests/Instrumentation/test_rnav_procedures.cxx +++ b/test_suite/unit_tests/Instrumentation/test_rnav_procedures.cxx @@ -170,13 +170,13 @@ GPS* RNAVProcedureTests::setupStandardGPS(SGPropertyNode_ptr config, gps->bind(); gps->init(); - globals->add_subsystem("gps", gps, SGSubsystemMgr::POST_FDM); + globals->get_subsystem_mgr()->add("gps", gps); return gps; } void RNAVProcedureTests::setupRouteManager() { - auto rm = globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + auto rm = globals->get_subsystem_mgr()->add(); rm->bind(); rm->init(); rm->postinit(); diff --git a/test_suite/unit_tests/Instrumentation/test_transponder.cxx b/test_suite/unit_tests/Instrumentation/test_transponder.cxx index 042061260..0bd84bf42 100644 --- a/test_suite/unit_tests/Instrumentation/test_transponder.cxx +++ b/test_suite/unit_tests/Instrumentation/test_transponder.cxx @@ -40,7 +40,7 @@ SGSubsystemRef TransponderTests::setupStandardTransponder(const std::string& nam r->bind(); r->init(); - globals->add_subsystem("transponder", r, SGSubsystemMgr::FDM); + globals->get_subsystem_mgr()->add("transponder", r); return r; } diff --git a/test_suite/unit_tests/Main/test_posinit.cxx b/test_suite/unit_tests/Main/test_posinit.cxx index b82c62a5a..b175a20b8 100644 --- a/test_suite/unit_tests/Main/test_posinit.cxx +++ b/test_suite/unit_tests/Main/test_posinit.cxx @@ -61,10 +61,10 @@ void PosInitTests::setUp() apt->testSuiteInjectGroundnetXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "EDDF.groundnet.xml"); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->get_subsystem_mgr()->add(); + globals->get_subsystem_mgr()->add(); + globals->get_subsystem_mgr()->add(); + globals->get_subsystem_mgr()->add(); } diff --git a/test_suite/unit_tests/Navaids/test_fpNasal.cxx b/test_suite/unit_tests/Navaids/test_fpNasal.cxx index 4caa5ba5a..b52c437fa 100644 --- a/test_suite/unit_tests/Navaids/test_fpNasal.cxx +++ b/test_suite/unit_tests/Navaids/test_fpNasal.cxx @@ -34,7 +34,7 @@ void FPNasalTests::setUp() } // flightplan() acces needs the route manager - globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->get_subsystem_mgr()->add(); globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->init(); diff --git a/test_suite/unit_tests/Navaids/test_routeManager.cxx b/test_suite/unit_tests/Navaids/test_routeManager.cxx index 3a856768c..ce258e28a 100644 --- a/test_suite/unit_tests/Navaids/test_routeManager.cxx +++ b/test_suite/unit_tests/Navaids/test_routeManager.cxx @@ -50,7 +50,7 @@ void RouteManagerTests::setUp() globals->append_fg_scenery(proceduresPath); } - globals->add_new_subsystem(SGSubsystemMgr::FDM); + globals->get_subsystem_mgr()->add(); // setup the default GPS, which is needed for waypoint // sequencing to work @@ -63,7 +63,7 @@ void RouteManagerTests::setUp() SGPropertyNode_ptr node = globals->get_props()->getNode("instrumentation", true)->getChild("gps", 0, true); // node->setBoolValue("serviceable", true); // 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()->init(); diff --git a/test_suite/unit_tests/Network/test_swiftAircraftManager.cxx b/test_suite/unit_tests/Network/test_swiftAircraftManager.cxx index daee225c8..62d782335 100644 --- a/test_suite/unit_tests/Network/test_swiftAircraftManager.cxx +++ b/test_suite/unit_tests/Network/test_swiftAircraftManager.cxx @@ -29,7 +29,7 @@ std::vector> SwiftAircraftManagerTest::getAIList() void SwiftAircraftManagerTest::testAircraftManager() { - globals->add_new_subsystem(SGSubsystemMgr::POST_FDM); + globals->get_subsystem_mgr()->add(); globals->get_subsystem()->bind(); globals->get_subsystem()->init(); diff --git a/test_suite/unit_tests/Scripting/testGC.cxx b/test_suite/unit_tests/Scripting/testGC.cxx index 725f67cc5..49fcd2344 100644 --- a/test_suite/unit_tests/Scripting/testGC.cxx +++ b/test_suite/unit_tests/Scripting/testGC.cxx @@ -38,13 +38,13 @@ void NasalGCTests::setUp() fgInitAllowedPaths(); auto nasalNode = globals->get_props()->getNode("nasal", true); - globals->add_subsystem("prop-interpolator", new FGInterpolator, SGSubsystemMgr::INIT); + globals->get_subsystem_mgr()->add(); globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->init(); global_nasalMinimalInit = true; - globals->add_new_subsystem(SGSubsystemMgr::INIT); + globals->get_subsystem_mgr()->add(); globals->get_subsystem_mgr()->postinit(); } diff --git a/test_suite/unit_tests/Scripting/testNasalSys.cxx b/test_suite/unit_tests/Scripting/testNasalSys.cxx index cf8552197..cabc03038 100644 --- a/test_suite/unit_tests/Scripting/testNasalSys.cxx +++ b/test_suite/unit_tests/Scripting/testNasalSys.cxx @@ -42,12 +42,12 @@ void NasalSysTests::setUp() fgInitAllowedPaths(); globals->get_props()->getNode("nasal", true); - globals->add_subsystem("prop-interpolator", new FGInterpolator, SGSubsystemMgr::INIT); + globals->get_subsystem_mgr()->add(); globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->init(); - globals->add_new_subsystem(SGSubsystemMgr::INIT); + globals->get_subsystem_mgr()->add(); globals->get_subsystem_mgr()->postinit(); } diff --git a/test_suite/unit_tests/general/test_Views.cxx b/test_suite/unit_tests/general/test_Views.cxx index 932620bfd..8aae11eaa 100644 --- a/test_suite/unit_tests/general/test_Views.cxx +++ b/test_suite/unit_tests/general/test_Views.cxx @@ -49,7 +49,7 @@ void ViewsTests::tearDown() void ViewsTests::testBasic() { - auto vm = globals->add_new_subsystem(SGSubsystemMgr::DISPLAY); + auto vm = globals->get_subsystem_mgr()->add(); CPPUNIT_ASSERT_EQUAL(static_cast(nullptr), vm->get_current_view());