1
0
Fork 0

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.
This commit is contained in:
James Turner 2012-09-19 11:37:19 +01:00
parent 09ac319e87
commit 48c26079e1
6 changed files with 40 additions and 17 deletions

View file

@ -49,6 +49,7 @@ public:
virtual void addAutopilot( const std::string & name, SGPropertyNode_ptr apNode, SGPropertyNode_ptr config ); virtual void addAutopilot( const std::string & name, SGPropertyNode_ptr apNode, SGPropertyNode_ptr config );
virtual void removeAutopilot( const std::string & name ); virtual void removeAutopilot( const std::string & name );
void init(); void init();
InitStatus incrementalInit();
void reinit(); void reinit();
void update( double dt ); void update( double dt );
private: private:
@ -101,6 +102,12 @@ void FGXMLAutopilotGroupImplementation::reinit()
init(); init();
} }
SGSubsystem::InitStatus FGXMLAutopilotGroupImplementation::incrementalInit()
{
init();
return INIT_DONE;
}
void FGXMLAutopilotGroupImplementation::init() void FGXMLAutopilotGroupImplementation::init()
{ {
initFrom( fgGetNode( "/sim/systems" ), _nodeName.c_str() ); initFrom( fgGetNode( "/sim/systems" ), _nodeName.c_str() );

View file

@ -132,23 +132,26 @@ FGEnvironmentMgr::~FGEnvironmentMgr ()
delete _3dCloudsEnableListener; delete _3dCloudsEnableListener;
} }
void SGSubsystem::InitStatus FGEnvironmentMgr::incrementalInit()
FGEnvironmentMgr::init ()
{ {
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, InitStatus r = SGSubsystemGroup::incrementalInit();
&FGEnvironmentMgr::updateClosestAirport, 30 ); 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 void

View file

@ -54,7 +54,7 @@ public:
FGEnvironmentMgr (); FGEnvironmentMgr ();
virtual ~FGEnvironmentMgr (); virtual ~FGEnvironmentMgr ();
virtual void init (); virtual InitStatus incrementalInit ();
virtual void reinit (); virtual void reinit ();
virtual void shutdown (); virtual void shutdown ();
virtual void bind (); virtual void bind ();
@ -103,7 +103,6 @@ private:
simgear::TiedPropertyList _tiedProperties; simgear::TiedPropertyList _tiedProperties;
SGPropertyChangeListener * _3dCloudsEnableListener; SGPropertyChangeListener * _3dCloudsEnableListener;
SGSky* _sky; SGSky* _sky;
}; };
#endif // _ENVIRONMENT_MGR_HXX #endif // _ENVIRONMENT_MGR_HXX

View file

@ -321,6 +321,7 @@ public:
virtual ~TerrainSamplerImplementation (); virtual ~TerrainSamplerImplementation ();
virtual void init (); virtual void init ();
virtual InitStatus incrementalInit ();
virtual void postinit(); virtual void postinit();
virtual void reinit (); virtual void reinit ();
virtual void bind(); virtual void bind();
@ -347,6 +348,12 @@ TerrainSamplerImplementation::TerrainSamplerImplementation( SGPropertyNode_ptr r
TerrainSamplerImplementation::~TerrainSamplerImplementation() TerrainSamplerImplementation::~TerrainSamplerImplementation()
{ {
} }
SGSubsystem::InitStatus TerrainSamplerImplementation::incrementalInit()
{
init();
return INIT_DONE;
}
void TerrainSamplerImplementation::init() void TerrainSamplerImplementation::init()
{ {

View file

@ -63,6 +63,12 @@ FGInstrumentMgr::~FGInstrumentMgr ()
{ {
} }
SGSubsystem::InitStatus FGInstrumentMgr::incrementalInit()
{
init();
return INIT_DONE;
}
void FGInstrumentMgr::init() void FGInstrumentMgr::init()
{ {
SGPropertyNode_ptr config_props = new SGPropertyNode; SGPropertyNode_ptr config_props = new SGPropertyNode;

View file

@ -33,6 +33,7 @@ public:
virtual ~FGInstrumentMgr (); virtual ~FGInstrumentMgr ();
virtual void init(); virtual void init();
virtual InitStatus incrementalInit();
virtual void reinit(); virtual void reinit();
private: private:
bool build (SGPropertyNode* config_props); bool build (SGPropertyNode* config_props);