32 #include "../common/WLogger.h"
33 #include "combiner/WApplyCombiner.h"
34 #include "exceptions/WPrototypeNotUnique.h"
35 #include "exceptions/WPrototypeUnknown.h"
37 #include "WModuleCombiner.h"
38 #include "WModuleFactory.h"
72 std::set< std::string > names;
74 while( listIter != l->get().end() )
79 if( names.count( ( *listIter )->getName() ) )
82 "\" is not unique. Modules have to have a unique name. Ignoring this module." ),
83 "ModuleFactory", LL_ERROR );
85 l->get().erase( listIter++ );
90 names.insert( ( *listIter )->getName() );
107 return ( ticket->get().count( module ) != 0 );
112 wlog::debug(
"ModuleFactory" ) <<
"Creating new instance of prototype \"" << prototype->getName() <<
"\".";
120 throw WPrototypeUnknown( std::string(
"Could not clone module \"" + prototype->getName() +
"\" since it is no prototype." ) );
127 boost::shared_ptr< WModule > clone = boost::shared_ptr< WModule >( prototype->factory() );
129 clone->setUUID( uuid );
133 clone->setLocalPath( prototype->getLocalPath() );
141 module->initialize();
161 boost::shared_ptr< WModule > ret = boost::shared_ptr< WModule >();
162 for( std::set< boost::shared_ptr< WModule > >::const_iterator listIter = l->get().begin(); listIter != l->get().end();
165 if( ( *listIter )->getName() == name )
180 if( ret == boost::shared_ptr< WModule >() )
182 throw WPrototypeUnknown( std::string(
"Could not find prototype \"" + name +
"\"." ) );
195 std::vector< WModule::ConstSPtr > ret;
201 for( std::set< boost::shared_ptr< WModule > >::const_iterator listIter = l->get().begin(); listIter != l->get().end();
204 if( ( *listIter )->getType() == type )
206 ret.push_back( *listIter );
220 WCombinerTypes::WCompatiblesList compatibles;
226 bool addModulesWithoutInput = !module;
228 if( addModulesWithoutInput )
236 if( pcons.size() == 0 )
239 WCombinerTypes::WOneToOneCombiners lComp;
242 lComp.push_back( boost::shared_ptr< WApplyCombiner >(
new WApplyCombiner( module,
"", *listIter,
"" ) ) );
245 compatibles.push_back( WCombinerTypes::WCompatiblesGroup( ( *listIter ), lComp ) );
257 WCombinerTypes::WOneToOneCombiners lComp = WApplyCombiner::createCombinerList< WApplyCombiner >( module, ( *listIter ) );
260 if( lComp.size() != 0 )
262 compatibles.push_back( WCombinerTypes::WCompatiblesGroup( ( *listIter ), lComp ) );
271 std::sort( compatibles.begin(), compatibles.end(), WCombinerTypes::compatiblesSort );
278 WCombinerTypes::WCompatiblesList compatibles;
288 WCombinerTypes::WOneToOneCombiners lComp;
291 lComp.push_back( boost::shared_ptr< WApplyCombiner >(
new WApplyCombiner( *listIter ) ) );
294 compatibles.push_back( WCombinerTypes::WCompatiblesGroup( ( *listIter ), lComp ) );
301 std::sort( compatibles.begin(), compatibles.end(), WCombinerTypes::compatiblesSort );
313 UuidModuleMap::const_iterator it = r->get().find( uuid );
314 if( it != r->get().end() )
317 boost::weak_ptr< WModule > m = ( *it ).second;