From 48c26079e19fe7c4c2a5e60e3e670e430bff3c62 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 19 Sep 2012 11:37:19 +0100 Subject: [PATCH] Fix classes derived from SubsystemGroup. Various classes derive from SubsystemGroup, but extend the init behaviour. Fix those for the incremental init scheme, generally by forcing their init to be atomic. Can convert them to be truly incremental in the future if it's needed, but probably not. --- src/Autopilot/autopilotgroup.cxx | 7 ++++++ src/Environment/environment_mgr.cxx | 33 ++++++++++++++------------ src/Environment/environment_mgr.hxx | 3 +-- src/Environment/terrainsampler.cxx | 7 ++++++ src/Instrumentation/instrument_mgr.cxx | 6 +++++ src/Instrumentation/instrument_mgr.hxx | 1 + 6 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/Autopilot/autopilotgroup.cxx b/src/Autopilot/autopilotgroup.cxx index c9df860d2..c60ea3010 100644 --- a/src/Autopilot/autopilotgroup.cxx +++ b/src/Autopilot/autopilotgroup.cxx @@ -49,6 +49,7 @@ public: virtual void addAutopilot( const std::string & name, SGPropertyNode_ptr apNode, SGPropertyNode_ptr config ); virtual void removeAutopilot( const std::string & name ); void init(); + InitStatus incrementalInit(); void reinit(); void update( double dt ); private: @@ -101,6 +102,12 @@ void FGXMLAutopilotGroupImplementation::reinit() init(); } +SGSubsystem::InitStatus FGXMLAutopilotGroupImplementation::incrementalInit() +{ + init(); + return INIT_DONE; +} + void FGXMLAutopilotGroupImplementation::init() { initFrom( fgGetNode( "/sim/systems" ), _nodeName.c_str() ); diff --git a/src/Environment/environment_mgr.cxx b/src/Environment/environment_mgr.cxx index a1e22555d..e7688d793 100644 --- a/src/Environment/environment_mgr.cxx +++ b/src/Environment/environment_mgr.cxx @@ -132,23 +132,26 @@ FGEnvironmentMgr::~FGEnvironmentMgr () delete _3dCloudsEnableListener; } -void -FGEnvironmentMgr::init () +SGSubsystem::InitStatus FGEnvironmentMgr::incrementalInit() { - SG_LOG( SG_ENVIRONMENT, SG_INFO, "Initializing environment subsystem"); - SGSubsystemGroup::init(); - fgClouds->Init(); - - // FIXME: is this really part of the environment_mgr? - // Initialize the longitude, latitude and altitude to the initial position - // of the aircraft so that the atmospheric properties (pressure, temperature - // and density) can be initialized accordingly. - _altitude_n->setDoubleValue(fgGetDouble("/sim/presets/altitude-ft")); - _longitude_n->setDoubleValue(fgGetDouble("/sim/presets/longitude-deg")); - _latitude_n->setDoubleValue(fgGetDouble("/sim/presets/latitude-deg")); - globals->get_event_mgr()->addTask("updateClosestAirport", this, - &FGEnvironmentMgr::updateClosestAirport, 30 ); + InitStatus r = SGSubsystemGroup::incrementalInit(); + if (r == INIT_DONE) { + fgClouds->Init(); + + // FIXME: is this really part of the environment_mgr? + // Initialize the longitude, latitude and altitude to the initial position + // of the aircraft so that the atmospheric properties (pressure, temperature + // and density) can be initialized accordingly. + _altitude_n->setDoubleValue(fgGetDouble("/sim/presets/altitude-ft")); + _longitude_n->setDoubleValue(fgGetDouble("/sim/presets/longitude-deg")); + _latitude_n->setDoubleValue(fgGetDouble("/sim/presets/latitude-deg")); + + globals->get_event_mgr()->addTask("updateClosestAirport", this, + &FGEnvironmentMgr::updateClosestAirport, 30 ); + } + + return r; } void diff --git a/src/Environment/environment_mgr.hxx b/src/Environment/environment_mgr.hxx index 64e4d9f8f..93213ecb5 100644 --- a/src/Environment/environment_mgr.hxx +++ b/src/Environment/environment_mgr.hxx @@ -54,7 +54,7 @@ public: FGEnvironmentMgr (); virtual ~FGEnvironmentMgr (); - virtual void init (); + virtual InitStatus incrementalInit (); virtual void reinit (); virtual void shutdown (); virtual void bind (); @@ -103,7 +103,6 @@ private: simgear::TiedPropertyList _tiedProperties; SGPropertyChangeListener * _3dCloudsEnableListener; SGSky* _sky; - }; #endif // _ENVIRONMENT_MGR_HXX diff --git a/src/Environment/terrainsampler.cxx b/src/Environment/terrainsampler.cxx index b4a7beabf..744b3ef97 100644 --- a/src/Environment/terrainsampler.cxx +++ b/src/Environment/terrainsampler.cxx @@ -321,6 +321,7 @@ public: virtual ~TerrainSamplerImplementation (); virtual void init (); + virtual InitStatus incrementalInit (); virtual void postinit(); virtual void reinit (); virtual void bind(); @@ -347,6 +348,12 @@ TerrainSamplerImplementation::TerrainSamplerImplementation( SGPropertyNode_ptr r TerrainSamplerImplementation::~TerrainSamplerImplementation() { } + +SGSubsystem::InitStatus TerrainSamplerImplementation::incrementalInit() +{ + init(); + return INIT_DONE; +} void TerrainSamplerImplementation::init() { diff --git a/src/Instrumentation/instrument_mgr.cxx b/src/Instrumentation/instrument_mgr.cxx index 121df9bd8..d47917468 100644 --- a/src/Instrumentation/instrument_mgr.cxx +++ b/src/Instrumentation/instrument_mgr.cxx @@ -63,6 +63,12 @@ FGInstrumentMgr::~FGInstrumentMgr () { } +SGSubsystem::InitStatus FGInstrumentMgr::incrementalInit() +{ + init(); + return INIT_DONE; +} + void FGInstrumentMgr::init() { SGPropertyNode_ptr config_props = new SGPropertyNode; diff --git a/src/Instrumentation/instrument_mgr.hxx b/src/Instrumentation/instrument_mgr.hxx index d7c9b2a07..cda6550e5 100644 --- a/src/Instrumentation/instrument_mgr.hxx +++ b/src/Instrumentation/instrument_mgr.hxx @@ -33,6 +33,7 @@ public: virtual ~FGInstrumentMgr (); virtual void init(); + virtual InitStatus incrementalInit(); virtual void reinit(); private: bool build (SGPropertyNode* config_props);