Ejemplo n.º 1
0
void RootManager::initializeRootObject()
{
    SLM_ASSERT("Sorry, the OSR is already initialized.", ! getDefault()->m_isRootInitialized );
    SLM_ASSERT("Sorry, configuration name parameter is not initialized.", getDefault()->m_rootObjectConfigurationName.first );
    SLM_ASSERT("Sorry, configuration file parameter is not initialized.", getDefault()->m_rootObjectConfigurationFile.first );

    // ToDo Correct this hack
    // Load another "pseudo" bundle
    ::boost::filesystem::path filePath ( getDefault()->m_rootObjectConfigurationFile.second );
    SPTR(::fwRuntime::Bundle) configBundle = ::fwRuntime::io::BundleDescriptorReader::createBundleFromXmlPlugin( filePath );
    ::fwRuntime::Runtime::getDefault()->addBundle( configBundle );
    configBundle->setEnable( true );

    // Validate bundle
    ::fwRuntime::Bundle::ExtensionConstIterator iter = configBundle->extensionsBegin();
    while( iter != configBundle->extensionsEnd() )
    {
        ::fwRuntime::Extension::Validity isValid = (*iter)->validate();
        OSLM_FATAL_IF("Sorry, extension " << (*iter)->getIdentifier() << " is not valid.", isValid == ::fwRuntime::Extension::Invalid );
        iter++;
    }

    // Register service config
    getDefault()->m_ctm = AppConfigManager::New();
    ::fwRuntime::ConfigurationElement::csptr config = ::fwServices::registry::AppConfig::getDefault()->getStandardConfig( getDefault()->m_rootObjectConfigurationName.second );
    getDefault()->m_ctm->setConfig( ::fwRuntime::ConfigurationElement::constCast( config ) );
    getDefault()->m_ctm->launch();
    getDefault()->m_isRootInitialized = true;
}
Ejemplo n.º 2
0
void Uninitializer::apply()
{
    ::boost::shared_ptr< Bundle >  bundle = Runtime::getDefault()->findBundle(m_identifier);
    OSLM_FATAL_IF("Unable to uninitialize bundle " << m_identifier << ". Not found.", bundle == 0);
    try
    {
        bundle->uninitialize();
    }
    catch( const std::exception & e )
    {
        OSLM_FATAL("Unable to uninitialize bundle " << m_identifier << ". " << e.what());
    }
}
Ejemplo n.º 3
0
void Stopper::apply()
{
    SLM_TRACE_FUNC();
    ::boost::shared_ptr< Bundle >  bundle = Runtime::getDefault()->findBundle(m_identifier);
    OSLM_FATAL_IF("Unable to stop bundle " << m_identifier << ". Not found.", bundle == 0);
    try
    {
        OSLM_INFO("Stopping bundle : " << m_identifier);
        bundle->stop();
    }
    catch( const std::exception & e )
    {
        OSLM_ERROR("Unable to stop bundle " << m_identifier << ". " << e.what());
    }
}
Ejemplo n.º 4
0
void Activater::apply()
{
    ::boost::shared_ptr< Bundle >  bundle = Runtime::getDefault()->findBundle(m_identifier, m_version);
    OSLM_FATAL_IF("Unable to activate Bundle " << m_identifier << "_" << m_version << ". Not found.", bundle==0);

    bundle->setEnable( true );

    // Managment of parameter configuration
    for( ParameterContainer::const_iterator i = m_parameters.begin();
            i != m_parameters.end();
            ++i )
    {
        bundle->addParameter( i->first, i->second );
    }

    // Disable extension point for this bundle
    for( DisableExtensionPointContainer::const_iterator id = m_disableExtensionPoints.begin();
            id != m_disableExtensionPoints.end();
            ++id )
    {
        if( bundle->hasExtensionPoint(*id) )
        {
            bundle->setEnableExtensionPoint( *id, false );
        }
        else
        {
            OSLM_ERROR("Unable to disable Extension Point " << *id << " defined in the Bundle " << m_identifier << ". Not found.");
        }
    }

    // Disable extension for this bundle
    for( DisableExtensionContainer::const_iterator id = m_disableExtensions.begin();
            id != m_disableExtensions.end();
            ++id )
    {
        if( bundle->hasExtension(*id) )
        {
            bundle->setEnableExtension( *id, false );
        }
        else
        {
            OSLM_ERROR("Unable to disable Extension " << *id << " defined in the Bundle " << m_identifier << ". Not found.");
        }
    }
}