28 #include "SALOMEDS_Attributes.hh"
61 Port(other,newHelder),_storeData(other._storeData)
85 DEBTRACE(
"OutputStudyPort::putIOR " << ior);
86 if(ior.substr(0,7) ==
"<value>")
97 value=
"<value><double>"+ior+
"</double></value>";
100 value=
"<value><int>"+ior+
"</int></value>";
103 value=
"<value><string>"+ior+
"</string></value>";
106 value=
"<value><boolean>"+ior+
"</boolean></value>";
109 value=
"<value><objref>"+ior+
"</objref></value>";
143 SALOMEDS::SObject_var aSO = myStudy->FindObjectID(data.c_str());
144 if(CORBA::is_nil(aSO))
147 aSO=myStudy->FindObjectByPath(data.c_str());
148 if(CORBA::is_nil(aSO))
150 std::stringstream msg;
151 msg <<
"Execution problem: no id or path: " << data <<
" in study " << myStudy->StudyId();
156 CORBA::String_var path=myStudy->GetObjectPath(aSO);
158 CORBA::String_var
id=aSO->GetID();
162 SALOMEDS::GenericAttribute_var aGAttr;
163 CORBA::String_var value;
167 if ( aSO->FindAttribute( aGAttr,
"AttributeIOR" ) )
169 SALOMEDS::AttributeIOR_var anAttr = SALOMEDS::AttributeIOR::_narrow( aGAttr );
170 value=anAttr->Value();
171 putIOR((
const char*)value);
176 std::string error=
"Execution problem: no AttributeIOR in study object: ";
183 if ( aSO->FindAttribute( aGAttr,
"AttributeReal" ) )
185 SALOMEDS::AttributeReal_var anAttr = SALOMEDS::AttributeReal::_narrow( aGAttr );
187 std::stringstream msg;
188 msg <<
"<value><double>" << std::setprecision(16) << d <<
"</double></value>";
189 put(msg.str().c_str());
193 std::string error=
"Execution problem: no AttributeReal in study object: ";
199 if ( aSO->FindAttribute( aGAttr,
"AttributeInteger" ) )
201 SALOMEDS::AttributeInteger_var anAttr = SALOMEDS::AttributeInteger::_narrow( aGAttr );
202 CORBA::Long l=anAttr->Value();
203 std::stringstream msg;
204 msg <<
"<value><int>" << l <<
"</int></value>";
205 put(msg.str().c_str());
209 std::string error=
"Execution problem: no AttributeInteger in study object: ";
215 if ( aSO->FindAttribute( aGAttr,
"AttributeComment" ) )
217 SALOMEDS::AttributeComment_var anAttr = SALOMEDS::AttributeComment::_narrow( aGAttr );
218 value=anAttr->Value();
220 putIOR((
const char*)value);
224 std::string error=
"Execution problem: no AttributeComment in study object: ";
234 SALOMEDS::SObject_ptr sobj,
const std::string& name)
236 SALOMEDS::ChildIterator_var anIterator= study->NewChildIterator(sobj);
237 SALOMEDS::GenericAttribute_var anAttr;
238 SALOMEDS::AttributeName_var namAttr ;
239 SALOMEDS::SObject_var result=SALOMEDS::SObject::_nil();
241 for (; anIterator->More(); anIterator->Next())
243 SALOMEDS::SObject_var anObj=anIterator->Value();
244 if(anObj->FindAttribute(anAttr,
"AttributeName"))
246 namAttr = SALOMEDS::AttributeName::_narrow( anAttr );
247 CORBA::String_var value=namAttr->Value();
248 if(name == (
const char*)value)
255 if(CORBA::is_nil(result))
258 result = builder->NewObject( sobj );
259 anAttr=builder->FindOrCreateAttribute(result,
"AttributeName");
260 namAttr = SALOMEDS::AttributeName::_narrow( anAttr );
261 namAttr->SetValue(name.c_str());
263 return result._retn();
284 Port(other,newHelder),_storeData(other._storeData)
320 std::string::size_type begin = s.find_first_of(
"<");
321 begin = s.find_first_of(
">",begin);
322 begin = s.find_first_of(
"<",begin);
323 begin = s.find_first_of(
">",begin);
324 begin = s.find_first_not_of(
"> ",begin);
325 std::string::size_type last = s.find_first_of(
"<",begin);
326 return s.substr(begin,last-begin);
347 SALOMEDS::GenericAttribute_var aGAttr;
348 SALOMEDS::SObject_var aSO ;
349 SALOMEDS::AttributeName_var anAttr ;
350 SALOMEDS::AttributeIOR_var iorAttr ;
351 SALOMEDS::SComponent_var aFather;
356 aSO = myStudy->FindObjectID(data.c_str());
357 if(CORBA::is_nil(aSO))
360 aSO=myStudy->CreateObjectID(data.c_str());
361 if(!CORBA::is_nil(aSO))
363 aGAttr=aBuilder->FindOrCreateAttribute(aSO,
"AttributeName");
364 anAttr = SALOMEDS::AttributeName::_narrow( aGAttr );
365 anAttr->SetValue(
getName().c_str());
369 if(CORBA::is_nil(aSO))
374 std::string::size_type begin = data.find_first_not_of(
"/");
375 std::string::size_type pos=data.find_first_of(
"/", begin);
376 if (pos != std::string::npos)
378 name=data.substr(begin,pos-begin);
379 objname=data.substr(pos+1);
383 name=data.substr(begin);
386 std::string pname=
"/"+name;
398 CORBA::Object_var compovar= scompo->getCompoPtr();
399 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(compovar);
400 if ( !CORBA::is_nil( aDriver ) )
404 CORBA::Object_var anObject;
408 anObject=orb->string_to_object(
getIOR().c_str());
412 std::cerr <<
"Execution problem: can not get the object to publish" << std::endl;
415 if ( aDriver->CanPublishInStudy( anObject ) )
418 SALOMEDS::SObject_var aTmpSO;
421 aTmpSO = aDriver->PublishInStudy(myStudy, aTmpSO, anObject,objname.c_str() );
426 std::cerr <<
"Execution problem: error in PublishInStudy" << std::endl;
435 aSO=myStudy->FindObjectByPath(pname.c_str());
436 if(CORBA::is_nil(aSO))
439 aFather=aBuilder->NewComponent(name.c_str());
440 if(CORBA::is_nil(aFather))
442 std::cerr <<
"Execution problem: can not create component: " + name << std::endl;
445 aGAttr=aBuilder->FindOrCreateAttribute(aFather,
"AttributeName");
446 anAttr = SALOMEDS::AttributeName::_narrow( aGAttr );
447 anAttr->SetValue(name.c_str());
448 aSO=myStudy->FindObjectByPath(pname.c_str());
451 begin=data.find_first_not_of(
"/",pos);
452 while (begin != std::string::npos)
454 pos = data.find_first_of(
"/", begin);
455 if (pos != std::string::npos)
456 name=data.substr(begin,pos-begin);
458 name=data.substr(begin);
460 begin=data.find_first_not_of(
"/",pos);
464 if(CORBA::is_nil(aSO))
466 std::cerr <<
"Execution problem: can not create id or path: " + data +
" in study" << std::endl;
471 SALOMEDS::AttributeComment_var commentAttr ;
472 SALOMEDS::AttributeReal_var realAttr ;
473 SALOMEDS::AttributeInteger_var intAttr ;
474 SALOMEDS::AttributeString_var stringAttr ;
482 aGAttr=aBuilder->FindOrCreateAttribute(aSO,
"AttributeIOR");
483 iorAttr = SALOMEDS::AttributeIOR::_narrow( aGAttr );
484 iorAttr->SetValue(value.c_str());
489 aGAttr=aBuilder->FindOrCreateAttribute(aSO,
"AttributeReal");
490 realAttr = SALOMEDS::AttributeReal::_narrow( aGAttr );
491 d=atof(value.c_str());
492 realAttr->SetValue(d);
497 aGAttr=aBuilder->FindOrCreateAttribute(aSO,
"AttributeInteger");
498 intAttr = SALOMEDS::AttributeInteger::_narrow( aGAttr );
499 v=atol(value.c_str());
500 intAttr->SetValue(v);
506 aGAttr=aBuilder->FindOrCreateAttribute(aSO,
"AttributeComment");
507 commentAttr = SALOMEDS::AttributeComment::_narrow( aGAttr );
508 commentAttr->SetValue(value.c_str());
513 aGAttr=aBuilder->FindOrCreateAttribute(aSO,
"AttributeComment");
514 commentAttr = SALOMEDS::AttributeComment::_narrow( aGAttr );
515 commentAttr->SetValue(value.c_str());