Commit 9eea4484 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - first version of working remove method of container

parent 1c586564
......@@ -90,7 +90,6 @@ WModule::WModule():
WModule::~WModule()
{
// cleanup
removeConnectors();
}
void WModule::addConnector( boost::shared_ptr< WModuleInputConnector > con )
......@@ -105,8 +104,6 @@ void WModule::addConnector( boost::shared_ptr< WModuleOutputConnector > con )
void WModule::disconnectAll()
{
// TODO(ebaum): flat or deep removal? What to do with connected modules?
// remove connections and their signals
for( std::set<boost::shared_ptr< WModuleInputConnector > >::iterator listIter = m_inputConnectors.begin();
listIter != m_inputConnectors.end(); ++listIter )
......@@ -125,7 +122,7 @@ void WModule::removeConnectors()
m_initialized( false );
m_isUsable( m_initialized() && m_isAssociated() );
// remove connections and their signals
// remove connections and their signals, this is flat removal. The module container can do deep removal
disconnectAll();
// clean up list
......
......@@ -278,9 +278,9 @@ protected:
void initialize();
/**
* Removes connectors and cleans up.
* Called whenever the module should shutdown.
*/
void cleanup();
virtual void cleanup();
/**
* Adds the specified connector to the list of inputs.
......
......@@ -147,6 +147,8 @@ void WModuleContainer::add( boost::shared_ptr< WModule > module, bool run )
void WModuleContainer::remove( boost::shared_ptr< WModule > module )
{
// simple flat removal.
WLogger::getLogger()->addLogMessage( "Removing module \"" + module->getName() + "\" from container." , "ModuleContainer (" + getName() + ")",
LL_DEBUG );
......@@ -160,6 +162,11 @@ void WModuleContainer::remove( boost::shared_ptr< WModule > module )
LL_DEBUG );
module->wait( true );
// remove progress combiner
m_progress->removeSubProgress( module->getRootProgressCombiner() );
// remove signal subscriptions
// get write lock
m_moduleAccess->beginWrite();
m_moduleAccess->get().erase( module );
......@@ -167,9 +174,6 @@ void WModuleContainer::remove( boost::shared_ptr< WModule > module )
module->setAssociatedContainer( boost::shared_ptr< WModuleContainer >() );
// TODO(ebaum): remove signal subscriptions
// TODO(ebaum): remove progress from combiner
// TODO(ebaum): flat or deep removal? What to do with associated modules?
}
WModuleContainer::DataModuleListType WModuleContainer::getDataModules()
......@@ -222,6 +226,7 @@ void WModuleContainer::stop()
WLogger::getLogger()->addLogMessage( "Waiting for module \"" + ( *listIter )->getName() + "\" to finish." ,
"ModuleContainer (" + getName() + ")", LL_INFO );
( *listIter )->wait( true );
( *listIter )->cleanup();
}
m_moduleAccess->endRead();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment