void IFrameLayoutManager::initialize( ConfigurationType configuration) { OSLM_ASSERT("Bad configuration name "<<configuration->getName()<< ", must be frame", configuration->getName() == "frame"); std::vector < ConfigurationType > name = configuration->find("name"); std::vector < ConfigurationType > icon = configuration->find("icon"); std::vector < ConfigurationType > minSize = configuration->find("minSize"); std::vector < ConfigurationType > styles = configuration->find("style"); if(!name.empty()) { m_frameInfo.m_name = name.at(0)->getValue(); } if(!icon.empty()) { m_frameInfo.m_iconPath = ::boost::filesystem::path( icon.at(0)->getValue() ) ; OSLM_ASSERT("Sorry, icon "<< m_frameInfo.m_iconPath << " doesn't exist", ::boost::filesystem::exists(m_frameInfo.m_iconPath)); } if(!minSize.empty()) { if(minSize.at(0)->hasAttribute("width")) { m_frameInfo.m_minSize.first = ::boost::lexical_cast<int >(minSize.at(0)->getExistingAttributeValue("width")) ; } if(minSize.at(0)->hasAttribute("height")) { m_frameInfo.m_minSize.second = ::boost::lexical_cast<int >(minSize.at(0)->getExistingAttributeValue("height")) ; } } if(!styles.empty()) { ::fwRuntime::ConfigurationElement::sptr stylesCfgElt = styles.at(0); SLM_FATAL_IF("<style> node must contain mode attribute", !stylesCfgElt->hasAttribute("mode") ); const std::string style = stylesCfgElt->getExistingAttributeValue("mode"); if (style == "DEFAULT") { m_frameInfo.m_style = DEFAULT; } else if (style == "STAY_ON_TOP") { m_frameInfo.m_style = STAY_ON_TOP; } else if (style == "MODAL") { m_frameInfo.m_style = MODAL; } else { OSLM_FATAL("Sorry, style "<<style<< " is unknown."); } } this->readConfig(); }
void MultiFiles::cachedDeepCopy(const Object::csptr &source, DeepCopyCacheType &cache) { MultiFiles::csptr other = MultiFiles::dynamicConstCast(source); FW_RAISE_EXCEPTION_IF( ::fwData::Exception( "Unable to copy" + (source ? source->getClassname() : std::string("<NULL>")) + " to " + this->getClassname()), !bool(other) ); this->fieldDeepCopy( source, cache ); OSLM_FATAL("Not implemented." ); }
void XMLSubstitute::substitute( xmlNodePtr original, xmlNodePtr substitutionRules, std::map< std::string, std::string> &dictionary) { std::list< ::fwRuntime::io::Substitute > substitutions = getSubstitutions( substitutionRules ); for ( std::list< ::fwRuntime::io::Substitute >::iterator iter = substitutions.begin(); iter != substitutions.end(); ++iter ) { std::string xpath = iter->xpath; std::string dictEntry = iter->dictEntry; std::string status = iter->status; bool entryInDictionary = dictionary.find(dictEntry) != dictionary.end(); if ( status=="required" && !entryInDictionary ) { OSLM_FATAL("XML substitution required dictEntry [" << dictEntry << "] missing for xpath " << xpath ); } // optional and not in dictionary if ( status=="optional" && !entryInDictionary ) { OSLM_INFO("XML substitution optional dictEntry [" << dictEntry << "] not modified for xpath " << xpath ); continue; } OSLM_INFO("XML substitution dictEntry [" << dictEntry << "] modified with xpath " << xpath << " with the value : " << dictionary[dictEntry] ); // create the context for xpath xmlXPathContextPtr xpathCtx; xpathCtx = xmlXPathNewContext(original->doc); SLM_ASSERT("xpathCtx not instanced", xpathCtx); // search xmlChar *xpathExpr= BAD_CAST xpath.c_str(); xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx); SLM_ASSERT("xpathObj not instanced", xpathObj); int NbNodesFound = xpathObj->nodesetval->nodeNr; for (int i=NbNodesFound-1; i >= 0; --i ) { xmlNodePtr node = xpathObj->nodesetval->nodeTab[i]; // substitution if (node->type == XML_ATTRIBUTE_NODE ) { xmlSetProp( node->parent, node->name, BAD_CAST dictionary[dictEntry].c_str() ); } if (node->type == XML_ELEMENT_NODE ) { xmlNodeSetName( node , BAD_CAST dictionary[dictEntry].c_str() ); } if (node->type == XML_TEXT_NODE ) { xmlNodeSetContent( node , BAD_CAST dictionary[dictEntry].c_str() ); } } xmlXPathFreeObject(xpathObj ); } }
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()); } }
void SliceListEditor::onChangeSliceMode( bool checked ) { if(::fwTools::fwID::exist(m_adaptorUID)) { ::fwServices::IService::sptr service = ::fwServices::get(m_adaptorUID); ::fwData::Image::sptr image = service->getObject< ::fwData::Image >(); SLM_ASSERT("SliceListEditor adaptorUID " << m_adaptorUID <<" isn't an Adaptor on an Image?" , image); ::fwData::Integer::sptr dataInfo = ::fwData::Integer::New(); if(m_oneSliceItem->isChecked()) { dataInfo->value() = 1; m_nbSlice = 1; } else if(m_threeSlicesItem->isChecked()) { dataInfo->value() = 3; m_nbSlice = 3; } else if(m_obliqueSliceItem->isChecked()) { dataInfo->value() = -1; m_nbSlice = -1; } else { OSLM_FATAL("Unknown slice mode"); } dataInfo->setField(::fwComEd::Dictionary::m_relatedServiceId , ::fwData::String::New( m_adaptorUID ) ); ::fwComEd::ImageMsg::sptr imageMsg = ::fwComEd::ImageMsg::New(); imageMsg->addEvent( "SLICE_MODE", dataInfo ); ::fwServices::IEditionService::notify(this->getSptr(), image, imageMsg); } else { OSLM_TRACE("Service "<< m_adaptorUID << " is not yet present."); } }