Commit cc93da89 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - compatible modules are now sorted alphabetically.

parent 89f6b6f5
......@@ -454,9 +454,9 @@ void WQtDatasetBrowser::buildPropTab( boost::shared_ptr< WProperties > props )
void WQtDatasetBrowser::createCompatibleButtons( boost::shared_ptr< WModule >module )
{
// every module may have compatibles: create ribbon menu entry
std::set< boost::shared_ptr< WApplyPrototypeCombiner > > comps = WModuleFactory::getModuleFactory()->getCompatiblePrototypes( module );
std::vector< boost::shared_ptr< WApplyPrototypeCombiner > > comps = WModuleFactory::getModuleFactory()->getCompatiblePrototypes( module );
for ( std::set< boost::shared_ptr< WApplyPrototypeCombiner > >::iterator iter = comps.begin(); iter != comps.end(); ++iter )
for ( std::vector< boost::shared_ptr< WApplyPrototypeCombiner > >::const_iterator iter = comps.begin(); iter != comps.end(); ++iter )
{
if( !m_moduleWhiteList.empty() )
{
......
......@@ -212,9 +212,22 @@ const boost::shared_ptr< WModule > WModuleFactory::getPrototypeByInstance( boost
return getPrototypeByName( instance->getName() );
}
std::set< boost::shared_ptr< WApplyPrototypeCombiner > > WModuleFactory::getCompatiblePrototypes( boost::shared_ptr< WModule > module )
/**
* Sorting function for sorting the compatibles list. It uses the alphabetical order of the names.
*
* \param lhs the first combiner
* \param rhs the second combiner
*
* \return true if lhs < rhs
*/
bool compatiblesSort( boost::shared_ptr< WApplyPrototypeCombiner > lhs, boost::shared_ptr< WApplyPrototypeCombiner > rhs )
{
std::set< boost::shared_ptr < WApplyPrototypeCombiner > > compatibles;
return ( lhs->getTargetPrototype()->getName() < rhs->getTargetPrototype()->getName() );
}
std::vector< boost::shared_ptr< WApplyPrototypeCombiner > > WModuleFactory::getCompatiblePrototypes( boost::shared_ptr< WModule > module )
{
std::vector< boost::shared_ptr < WApplyPrototypeCombiner > > compatibles;
// for this a read lock is sufficient
boost::shared_lock< boost::shared_mutex > slock = boost::shared_lock< boost::shared_mutex >( m_prototypesLock );
......@@ -229,7 +242,7 @@ std::set< boost::shared_ptr< WApplyPrototypeCombiner > > WModuleFactory::getComp
std::set<boost::shared_ptr<WModuleInputConnector> > pcons = ( *listIter )->getInputConnectors();
if( pcons.size() == 0 )
{
compatibles.insert( boost::shared_ptr< WApplyPrototypeCombiner >( new WApplyPrototypeCombiner( module, "", *listIter, "" ) ) );
compatibles.push_back( boost::shared_ptr< WApplyPrototypeCombiner >( new WApplyPrototypeCombiner( module, "", *listIter, "" ) ) );
}
}
......@@ -269,7 +282,7 @@ std::set< boost::shared_ptr< WApplyPrototypeCombiner > > WModuleFactory::getComp
if( ( *cons.begin() )->connectable( *pcons.begin() ) && ( *pcons.begin() )->connectable( *cons.begin() ) )
{
// it is compatible -> add to list
compatibles.insert( boost::shared_ptr< WApplyPrototypeCombiner >(
compatibles.push_back( boost::shared_ptr< WApplyPrototypeCombiner >(
new WApplyPrototypeCombiner( module, ( *cons.begin() )->getName(), *listIter, ( *pcons.begin() )->getName() ) )
);
}
......@@ -277,6 +290,9 @@ std::set< boost::shared_ptr< WApplyPrototypeCombiner > > WModuleFactory::getComp
slock.unlock();
// sort the compatibles
std::sort( compatibles.begin(), compatibles.end(), compatiblesSort );
return compatibles;
}
......@@ -121,7 +121,7 @@ public:
*
* \return set of compatible combiners.
*/
std::set< boost::shared_ptr< WApplyPrototypeCombiner > > getCompatiblePrototypes( boost::shared_ptr< WModule > module );
std::vector< boost::shared_ptr< WApplyPrototypeCombiner > > getCompatiblePrototypes( boost::shared_ptr< WModule > module );
/**
* This method uses a newly created instance of WModule and initializes it properly. After using this method, the module is
......
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