1
0
Fork 0

Reset: change FDM ownership

- make the FDM owned via a SGSharedPtr
- drop some property references explicitly.
This commit is contained in:
James Turner 2013-12-01 21:34:30 +00:00
parent 8bcf597086
commit 8aba04c3a2
2 changed files with 24 additions and 10 deletions

View file

@ -63,14 +63,13 @@ using std::string;
FDMShell::FDMShell() :
_tankProperties( fgGetNode("/consumables/fuel", true) ),
_impl(NULL),
_dataLogging(false)
{
}
FDMShell::~FDMShell()
{
delete _impl;
SG_LOG(SG_GENERAL, SG_INFO, "destorying FDM shell");
}
void FDMShell::init()
@ -91,15 +90,29 @@ void FDMShell::init()
createImplementation();
}
void FDMShell::shutdown()
{
if (_impl) {
fgSetBool("/sim/fdm-initialized", false);
_impl->unbind();
_impl.clear();
}
_props.clear();
_wind_north.clear();
_wind_east.clear();
_wind_down.clear();
_control_fdm_atmo.clear();
_temp_degc.clear();
_pressure_inhg.clear();
_density_slugft .clear();
_data_logging.clear();
_replay_master.clear();
}
void FDMShell::reinit()
{
if (_impl) {
fgSetBool("/sim/fdm-initialized", false);
_impl->unbind();
delete _impl;
_impl = NULL;
}
shutdown();
init();
}

View file

@ -44,6 +44,7 @@ public:
virtual ~FDMShell();
virtual void init();
virtual void shutdown();
virtual void reinit();
virtual void bind();
@ -57,7 +58,7 @@ private:
void createImplementation();
TankPropertiesList _tankProperties;
FGInterface* _impl;
SGSharedPtr<FGInterface> _impl;
SGPropertyNode_ptr _props; // root property tree for this FDM instance
bool _dataLogging;