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

View file

@ -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

View file

@ -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

View file

@ -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()
{

View file

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

View file

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