Commit a2b530c9 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - default modules now defined as list in walnut.cfg

parent 93b1e876
......@@ -2,8 +2,12 @@
# Uncomment the options you are interested in.
[modules]
# standard.ignoreHUD = yes # do not use HUD as default module
# use this to specify the default module to add during load.
# It is a comma seperated list. If this is not specified the default is assumed:
# "Coordinate System Module,HUD,Navigation Slice Module"
default="Coordinate System Module,HUD,Navigation Slice Module"
# MC.isoValue = 110 # set standard isovalue for marching cubes module (isosurface)
[qt4gui]
# hideAxial = yes # hide the axial view widget
# hideCoronal = yes # hide the coronal view widget
......
......@@ -46,6 +46,7 @@
#include "../common/WConditionOneShot.h"
#include "../common/WFlag.h"
#include "../common/WPreferences.h"
#include "../utils/WStringUtils.h"
#include "../graphicsEngine/WGraphicsEngine.h"
......@@ -147,12 +148,24 @@ void WKernel::threadMain()
// default modules
{
bool ignore;
m_moduleContainer->add( m_moduleFactory->create( m_moduleFactory->getPrototypeByName( "Navigation Slice Module" ) ) , true );
m_moduleContainer->add( m_moduleFactory->create( m_moduleFactory->getPrototypeByName( "Coordinate System Module" ) ) , true );
if( !( WPreferences::getPreference( "modules.standard.ignoreHUD", &ignore ) && ignore ) )
std::string stdModules = "Coordinate System Module,HUD,Navigation Slice Module";
WPreferences::getPreference( "modules.default", &stdModules );
std::vector< std::string > defMods = string_utils::tokenize( stdModules, "," );
for ( std::vector< std::string >::iterator iter = defMods.begin(); iter != defMods.end(); ++iter )
{
m_moduleContainer->add( m_moduleFactory->create( m_moduleFactory->getPrototypeByName( "HUD" ) ) , true );
std::string moduleName = string_utils::trim( ( *iter ) );
boost::shared_ptr< WModule> proto = m_moduleFactory->isPrototypeAvailable( moduleName );
// try to find a prototype
if ( proto.get() )
{
// the module exists
m_moduleContainer->add( m_moduleFactory->create( proto ) , true );
}
else
{
WLogger::getLogger()->addLogMessage( "Specified default module \"" + moduleName + "\" does not exist. Ignoring.", "Kernel", LL_WARNING );
}
}
}
......
......@@ -139,7 +139,7 @@ boost::shared_ptr< WModuleFactory > WModuleFactory::getModuleFactory()
}
const boost::shared_ptr< WModule > WModuleFactory::getPrototypeByName( std::string name )
const boost::shared_ptr< WModule > WModuleFactory::isPrototypeAvailable( std::string name )
{
// for this a read lock is sufficient
boost::shared_lock< boost::shared_mutex > slock = boost::shared_lock< boost::shared_mutex >( m_prototypesLock );
......@@ -158,6 +158,13 @@ const boost::shared_ptr< WModule > WModuleFactory::getPrototypeByName( std::stri
slock.unlock();
return ret;
}
const boost::shared_ptr< WModule > WModuleFactory::getPrototypeByName( std::string name )
{
boost::shared_ptr< WModule > ret = isPrototypeAvailable( name );
// if not found -> throw
if ( ret == boost::shared_ptr< WModule >() )
{
......
......@@ -72,6 +72,17 @@ public:
*/
static boost::shared_ptr< WModuleFactory > getModuleFactory();
/**
* Searches a prototype by name. It returns the prototype, or a NULL pointer if it is not found. The difference to
* getPrototypeByName() is, that an unavailable prototype does not throw an exception. This is nice for checking whether a
* prototype exists or not.
*
* \param name name of the prototype to search
*
* \return the prototype if it exists, or NULL if not.
*/
const boost::shared_ptr< WModule > isPrototypeAvailable( std::string name );
/**
* Finds a prototype using the specified name.
*
......
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