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

[ADD] - added convenience method to create and add a module to a container in one call

parent ddddb579
......@@ -181,6 +181,19 @@ void WModuleContainer::add( boost::shared_ptr< WModule > module, bool run )
}
}
WModule::SPtr WModuleContainer::createAndAdd( std::string name )
{
WModule::SPtr module = WModuleFactory::getModuleFactory()->create(
WModuleFactory::getModuleFactory()->getPrototypeByName( name )
);
// add to the container
add( module );
module->isReady().wait();
return module;
}
void WModuleContainer::remove( boost::shared_ptr< WModule > module )
{
// simple flat removal.
......
......@@ -111,6 +111,15 @@ public:
*/
virtual void add( boost::shared_ptr< WModule > module, bool run = true );
/**
* Convenience method to create a module instance with a given name and automatically add it to the container.
*
* \param name the prototype name to create
*
* \return the created and added module
*/
virtual WModule::SPtr createAndAdd( std::string name );
/**
* Remove the given module from this container if it is associated with it. It only provides flat removal. It does not remove depending
* modules. Please be aware that this method does NOT stop the module. It just removes it from the container. If you release the shared
......
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