Commit 18dffaa4 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - modules get inserted into dataset browser when they are inserted...

[CHANGE] - modules get inserted into dataset browser when they are inserted into the root container and not when they signal ready
parent 5858b03c
......@@ -90,8 +90,22 @@ void WProgressCombiner::finish()
{
// combiner just propagate the finish request down to all children
boost::unique_lock<boost::shared_mutex> lock = boost::unique_lock<boost::shared_mutex>( m_updateLock );
// add the progress to the children list
// as the children define this progress' state -> iterate children
for ( std::set< boost::shared_ptr< WProgress > >::iterator i = m_children.begin(); i != m_children.end(); ++i )
{
// enforce child to update
( *i )->finish();
( *i )->update();
}
// remove the children
m_children.clear();
// set the defaults
WProgress::finish();
m_progress = 0.0;
lock.unlock();
}
......
......@@ -133,8 +133,8 @@ int WQt4Gui::run()
m_mainWindow->getModuleButtonSignal()->connect( boost::bind( &WKernel::applyModule, m_kernel, _1, _2 ) );
// bind the GUI's slot with the ready signal
t_ModuleGenericSignalHandlerType f = boost::bind( &WQt4Gui::slotAddDatasetOrModuleToBrowser, this, _1 );
m_kernel->getRootContainer()->addDefaultNotifier( WM_READY, f );
t_ModuleGenericSignalHandlerType assocSignal = boost::bind( &WQt4Gui::slotAddDatasetOrModuleToBrowser, this, _1 );
m_kernel->getRootContainer()->addDefaultNotifier( WM_ASSOCIATED, assocSignal );
// now we are initialized
m_isInitialized( true );
......
......@@ -117,14 +117,18 @@ WQtDatasetTreeItem* WQtDatasetBrowser::addDataset( boost::shared_ptr< WModule >
subject->setExpanded( true );
emit dataSetBrowserEvent( QString( "textureChanged" ), true );
emit dataSetBrowserEvent( QString( "dataSetAdded" ), true );
return subject->addDatasetItem( module );
WQtDatasetTreeItem* item = subject->addDatasetItem( module );
item->setDisabled( true );
return item;
}
WQtModuleTreeItem* WQtDatasetBrowser::addModule( boost::shared_ptr< WModule > module )
{
WQtModuleHeaderTreeItem* tiModules = ( WQtModuleHeaderTreeItem* )m_treeWidget->topLevelItem( 0 );
tiModules->setExpanded( true );
return tiModules->addModuleItem( module );
WQtModuleTreeItem* item = tiModules->addModuleItem( module );
item->setDisabled( true );
return item;
}
boost::shared_ptr< WModule > WQtDatasetBrowser::getSelectedModule()
......
......@@ -44,7 +44,10 @@ WQtDatasetTreeItem* WQtSubjectTreeItem::addDatasetItem( boost::shared_ptr< WModu
std::string name = module->getProperties()->getValueString( "name" );
// remove the path up to the file name
name = string_utils::tokenize( name, "/" ).back();
if ( name != "" )
{
name = string_utils::tokenize( name, "/" ).back();
}
ds->setText( 0, QString( name.c_str() ) );
......
......@@ -56,6 +56,7 @@ WModule::WModule():
m_isAssociated( new WCondition(), false ),
m_isUsable( new WCondition(), false ),
m_isReady( new WConditionOneShot(), false ),
m_readyProgress( boost::shared_ptr< WProgress >( new WProgress( "Initializing Module" ) ) ),
m_moduleState()
{
// initialize members
......@@ -63,6 +64,9 @@ WModule::WModule():
m_container = boost::shared_ptr< WModuleContainer >();
m_progress = boost::shared_ptr< WProgressCombiner >( new WProgressCombiner() );
// add a progress indicator which finishes on "ready()"
m_progress->addSubProgress( m_readyProgress );
// our internal state consist out of two conditions: data changed and the exit flag from WThreadedRunner.
m_moduleState.add( m_shutdownFlag.getCondition() );
}
......
......@@ -46,6 +46,7 @@
#include "../common/WLogger.h"
#include "../common/WProperties.h"
#include "../common/WProgressCombiner.h"
#include "../common/WProgress.h"
#include "../common/WThreadedRunner.h"
#include "../common/WPrototyped.h"
#include "../common/WConditionSet.h"
......@@ -360,6 +361,11 @@ protected:
*/
WBoolFlag m_isReady;
/**
* Progress indicator for the "ready" state.
*/
boost::shared_ptr< WProgress > m_readyProgress;
/**
* The internal state of the module. This is, by default, simply the exit flag from WThreadedRunner.
*/
......
......@@ -89,17 +89,22 @@ void WModuleContainer::add( boost::shared_ptr< WModule > module, bool run )
// -> so run it
// connect default ready/error notifiers
boost::shared_lock<boost::shared_mutex> slock = boost::shared_lock<boost::shared_mutex>( m_readyNotifiersLock );
for ( std::list< t_ModuleGenericSignalHandlerType >::iterator iter = m_readyNotifiers.begin(); iter != m_readyNotifiers.end(); ++iter)
{
module->subscribeSignal( WM_READY, ( *iter ) );
}
slock.unlock();
slock = boost::shared_lock<boost::shared_mutex>( m_errorNotifiersLock );
boost::shared_lock<boost::shared_mutex> slock = boost::shared_lock<boost::shared_mutex>( m_errorNotifiersLock );
for ( std::list< t_ModuleErrorSignalHandlerType >::iterator iter = m_errorNotifiers.begin(); iter != m_errorNotifiers.end(); ++iter)
{
module->subscribeSignal( WM_ERROR, ( *iter ) );
}
slock = boost::shared_lock<boost::shared_mutex>( m_associatedNotifiersLock );
for ( std::list< t_ModuleGenericSignalHandlerType >::iterator iter = m_associatedNotifiers.begin(); iter != m_associatedNotifiers.end(); ++iter)
{
// call associated notifier
( *iter )( module );
}
slock = boost::shared_lock<boost::shared_mutex>( m_readyNotifiersLock );
for ( std::list< t_ModuleGenericSignalHandlerType >::iterator iter = m_readyNotifiers.begin(); iter != m_readyNotifiers.end(); ++iter)
{
module->subscribeSignal( WM_READY, ( *iter ) );
}
slock.unlock();
// run it
......@@ -170,6 +175,11 @@ void WModuleContainer::addDefaultNotifier( MODULE_SIGNAL signal, t_ModuleGeneric
boost::unique_lock<boost::shared_mutex> lock;
switch (signal)
{
case WM_ASSOCIATED:
lock = boost::unique_lock<boost::shared_mutex>( m_associatedNotifiersLock );
m_associatedNotifiers.push_back( notifier );
lock.unlock();
break;
case WM_READY:
lock = boost::unique_lock<boost::shared_mutex>( m_readyNotifiersLock );
m_readyNotifiers.push_back( notifier );
......
......@@ -170,6 +170,16 @@ protected:
*/
std::list< t_ModuleGenericSignalHandlerType > m_readyNotifiers;
/**
* Lock for associated notifiers set.
*/
boost::shared_mutex m_associatedNotifiersLock;
/**
* The notifiers connected to added modules by default and fired whenever the module got associated.
*/
std::list< t_ModuleGenericSignalHandlerType > m_associatedNotifiers;
private:
};
......
......@@ -36,6 +36,7 @@ class WException;
*/
typedef enum
{
WM_ASSOCIATED, // module got associated to a container
WM_READY, // module ready
WM_ERROR // error during execution
}
......
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