Commit f841caf2 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[ADD] - module factory now provides prototypes by type. Needed later for our IO modules

parent aebf63cd
......@@ -182,6 +182,26 @@ const boost::shared_ptr< WModule > WModuleFactory::getPrototypeByInstance( boost
return getPrototypeByName( instance->getName() );
}
std::vector< WModule::ConstSPtr > WModuleFactory::getPrototypesByType( MODULE_TYPE type )
{
std::vector< WModule::ConstSPtr > ret;
// for this a read lock is sufficient, gets unlocked if it looses scope
PrototypeSharedContainerType::ReadTicket l = m_prototypes.getReadTicket();
// find first and only prototype (ensured during load())
for( std::set< boost::shared_ptr< WModule > >::const_iterator listIter = l->get().begin(); listIter != l->get().end();
++listIter )
{
if( ( *listIter )->getType() == type )
{
ret.push_back( *listIter );
}
}
return ret;
}
WModuleFactory::PrototypeSharedContainerType::ReadTicket WModuleFactory::getPrototypes() const
{
return m_prototypes.getReadTicket();
......
......@@ -125,6 +125,15 @@ public:
*/
const boost::shared_ptr< WModule > getPrototypeByInstance( boost::shared_ptr< WModule > instance );
/**
* Finds a prototype using an type.
*
* \param type the type of module.
*
* \return the prototypes as list.
*/
std::vector< WModule::ConstSPtr > getPrototypesByType( MODULE_TYPE type );
/**
* This method gives read access to the list of all prototypes.
*
......
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