FGIO uses new SGSubsystem shutdown() logic
This commit is contained in:
parent
86be8fcb51
commit
0cb0c59bc9
3 changed files with 26 additions and 27 deletions
|
@ -29,6 +29,7 @@
|
|||
#include <cstdlib> // atoi()
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/io/iochannel.hxx>
|
||||
|
@ -76,15 +77,13 @@ FGIO::FGIO()
|
|||
{
|
||||
}
|
||||
|
||||
#include <algorithm>
|
||||
using std::for_each;
|
||||
|
||||
static void delete_ptr( FGProtocol* p ) { delete p; }
|
||||
|
||||
|
||||
|
||||
FGIO::~FGIO()
|
||||
{
|
||||
shutdown_all();
|
||||
for_each( io_channels.begin(), io_channels.end(), delete_ptr );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,7 +93,7 @@ FGIO::parse_port_config( const string& config )
|
|||
{
|
||||
SG_LOG( SG_IO, SG_INFO, "Parse I/O channel request: " << config );
|
||||
|
||||
vector<string> tokens = simgear::strutils::split( config, "," );
|
||||
string_list tokens = simgear::strutils::split( config, "," );
|
||||
if (tokens.empty())
|
||||
{
|
||||
SG_LOG( SG_IO, SG_ALERT,
|
||||
|
@ -315,9 +314,8 @@ FGIO::init()
|
|||
|
||||
// parse the configuration strings and store the results in the
|
||||
// appropriate FGIOChannel structures
|
||||
typedef vector<string> container;
|
||||
container::iterator i = globals->get_channel_options_list()->begin();
|
||||
container::iterator end = globals->get_channel_options_list()->end();
|
||||
string_list::iterator i = globals->get_channel_options_list()->begin();
|
||||
string_list::iterator end = globals->get_channel_options_list()->end();
|
||||
for (; i != end; ++i )
|
||||
{
|
||||
p = parse_port_config( *i );
|
||||
|
@ -339,7 +337,6 @@ FGIO::reinit()
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
// process any IO channel work
|
||||
void
|
||||
FGIO::update( double delta_time_sec )
|
||||
|
@ -347,9 +344,8 @@ FGIO::update( double delta_time_sec )
|
|||
// cout << "processing I/O channels" << endl;
|
||||
// cout << " Elapsed time = " << delta_time_sec << endl;
|
||||
|
||||
typedef vector< FGProtocol* > container;
|
||||
container::iterator i = io_channels.begin();
|
||||
container::iterator end = io_channels.end();
|
||||
ProtocolVec::iterator i = io_channels.begin();
|
||||
ProtocolVec::iterator end = io_channels.end();
|
||||
for (; i != end; ++i ) {
|
||||
FGProtocol* p = *i;
|
||||
|
||||
|
@ -369,24 +365,24 @@ FGIO::update( double delta_time_sec )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FGIO::shutdown_all() {
|
||||
FGIO::shutdown()
|
||||
{
|
||||
FGProtocol *p;
|
||||
|
||||
// cout << "shutting down all I/O channels" << endl;
|
||||
|
||||
typedef vector< FGProtocol* > container;
|
||||
container::iterator i = io_channels.begin();
|
||||
container::iterator end = io_channels.end();
|
||||
ProtocolVec::iterator i = io_channels.begin();
|
||||
ProtocolVec::iterator end = io_channels.end();
|
||||
for (; i != end; ++i )
|
||||
{
|
||||
p = *i;
|
||||
|
||||
if ( p->is_enabled() ) {
|
||||
p->close();
|
||||
}
|
||||
|
||||
delete p;
|
||||
}
|
||||
|
||||
io_channels.clear();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
void unbind();
|
||||
void update( double dt );
|
||||
|
||||
void shutdown_all();
|
||||
void shutdown();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -55,7 +55,9 @@ private:
|
|||
|
||||
// define the global I/O channel list
|
||||
//io_container global_io_list;
|
||||
std::vector< FGProtocol* > io_channels;
|
||||
|
||||
typedef std::vector< FGProtocol* > ProtocolVec;
|
||||
ProtocolVec io_channels;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -172,6 +172,7 @@ FGGlobals::~FGGlobals()
|
|||
delete ai;
|
||||
}
|
||||
|
||||
subsystem_mgr->shutdown();
|
||||
subsystem_mgr->unbind();
|
||||
delete subsystem_mgr;
|
||||
|
||||
|
|
Loading…
Reference in a new issue