28 #include "SALOMEDS_Attributes.hh"
29 #include "SALOME_KernelServices.hxx"
62 Port(other,newHelder),_storeData(other._storeData)
86 DEBTRACE(
"OutputStudyPort::putIOR " << ior);
87 if(ior.substr(0,7) ==
"<value>")
98 value=
"<value><double>"+ior+
"</double></value>";
101 value=
"<value><int>"+ior+
"</int></value>";
104 value=
"<value><string>"+ior+
"</string></value>";
107 value=
"<value><boolean>"+ior+
"</boolean></value>";
110 value=
"<value><objref>"+ior+
"</objref></value>";
144 SALOMEDS::SObject_var aSO = KERNEL::getStudyServant()->FindObjectID(data.c_str());
145 if(CORBA::is_nil(aSO))
148 aSO=KERNEL::getStudyServant()->FindObjectByPath(data.c_str());
149 if(CORBA::is_nil(aSO))
151 std::stringstream msg;
152 msg <<
"Execution problem: no id or path: " << data <<
" in study";
157 CORBA::String_var path=KERNEL::getStudyServant()->GetObjectPath(aSO);
159 CORBA::String_var
id=aSO->GetID();
163 SALOMEDS::GenericAttribute_var aGAttr;
164 CORBA::String_var value;
168 if ( aSO->FindAttribute( aGAttr,
"AttributeIOR" ) )
170 SALOMEDS::AttributeIOR_var anAttr = SALOMEDS::AttributeIOR::_narrow( aGAttr );
171 value=anAttr->Value();
172 putIOR((
const char*)value);
177 std::string error=
"Execution problem: no AttributeIOR in study object: ";
184 if ( aSO->FindAttribute( aGAttr,
"AttributeReal" ) )
186 SALOMEDS::AttributeReal_var anAttr = SALOMEDS::AttributeReal::_narrow( aGAttr );
188 std::stringstream msg;
189 msg <<
"<value><double>" << std::setprecision(16) << d <<
"</double></value>";
190 put(msg.str().c_str());
194 std::string error=
"Execution problem: no AttributeReal in study object: ";
200 if ( aSO->FindAttribute( aGAttr,
"AttributeInteger" ) )
202 SALOMEDS::AttributeInteger_var anAttr = SALOMEDS::AttributeInteger::_narrow( aGAttr );
203 CORBA::Long
l=anAttr->Value();
204 std::stringstream msg;
205 msg <<
"<value><int>" <<
l <<
"</int></value>";
206 put(msg.str().c_str());
210 std::string error=
"Execution problem: no AttributeInteger in study object: ";
216 if ( aSO->FindAttribute( aGAttr,
"AttributeComment" ) )
218 SALOMEDS::AttributeComment_var anAttr = SALOMEDS::AttributeComment::_narrow( aGAttr );
219 value=anAttr->Value();
221 putIOR((
const char*)value);
225 std::string error=
"Execution problem: no AttributeComment in study object: ";
235 SALOMEDS::SObject_ptr sobj,
const std::string& name)
237 SALOMEDS::ChildIterator_var anIterator= KERNEL::getStudyServant()->NewChildIterator(sobj);
238 SALOMEDS::GenericAttribute_var anAttr;
239 SALOMEDS::AttributeName_var namAttr ;
240 SALOMEDS::SObject_var result=SALOMEDS::SObject::_nil();
242 for (; anIterator->More(); anIterator->Next())
244 SALOMEDS::SObject_var anObj=anIterator->Value();
245 if(anObj->FindAttribute(anAttr,
"AttributeName"))
247 namAttr = SALOMEDS::AttributeName::_narrow( anAttr );
248 CORBA::String_var value=namAttr->Value();
249 if(name == (
const char*)value)
256 if(CORBA::is_nil(result))
259 result = builder->NewObject( sobj );
260 anAttr=builder->FindOrCreateAttribute(result,
"AttributeName");
261 namAttr = SALOMEDS::AttributeName::_narrow( anAttr );
262 namAttr->SetValue(name.c_str());
264 return result._retn();
285 Port(other,newHelder),_storeData(other._storeData)
321 std::string::size_type begin = s.find_first_of(
"<");
322 begin = s.find_first_of(
">",begin);
323 begin = s.find_first_of(
"<",begin);
324 begin = s.find_first_of(
">",begin);
325 begin = s.find_first_not_of(
"> ",begin);
326 std::string::size_type last = s.find_first_of(
"<",begin);
327 return s.substr(begin,last-begin);
348 SALOMEDS::GenericAttribute_var aGAttr;
349 SALOMEDS::SObject_var aSO ;
350 SALOMEDS::AttributeName_var anAttr ;
351 SALOMEDS::AttributeIOR_var iorAttr ;
352 SALOMEDS::SComponent_var aFather;
357 aSO = KERNEL::getStudyServant()->FindObjectID(data.c_str());
358 if(CORBA::is_nil(aSO))
361 aSO=KERNEL::getStudyServant()->CreateObjectID(data.c_str());
362 if(!CORBA::is_nil(aSO))
364 aGAttr=aBuilder->FindOrCreateAttribute(aSO,
"AttributeName");
365 anAttr = SALOMEDS::AttributeName::_narrow( aGAttr );
366 anAttr->SetValue(
getName().c_str());
370 if(CORBA::is_nil(aSO))
375 std::string::size_type begin = data.find_first_not_of(
"/");
376 std::string::size_type pos=data.find_first_of(
"/", begin);
377 if (pos != std::string::npos)
379 name=data.substr(begin,pos-begin);
380 objname=data.substr(pos+1);
384 name=data.substr(begin);
387 std::string pname=
"/"+name;
399 CORBA::Object_var compovar= scompo->getCompoPtr();
400 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(compovar);
401 if ( !CORBA::is_nil( aDriver ) )
405 CORBA::Object_var anObject;
409 anObject=
orb->string_to_object(
getIOR().c_str());
413 std::cerr <<
"Execution problem: can not get the object to publish" << std::endl;
416 if ( aDriver->CanPublishInStudy( anObject ) )
419 SALOMEDS::SObject_var aTmpSO;
422 aTmpSO = aDriver->PublishInStudy(aTmpSO, anObject,objname.c_str() );
427 std::cerr <<
"Execution problem: error in PublishInStudy" << std::endl;
436 aSO=KERNEL::getStudyServant()->FindObjectByPath(pname.c_str());
437 if(CORBA::is_nil(aSO))
440 aFather=aBuilder->NewComponent(name.c_str());
441 if(CORBA::is_nil(aFather))
443 std::cerr <<
"Execution problem: can not create component: " + name << std::endl;
446 aGAttr=aBuilder->FindOrCreateAttribute(aFather,
"AttributeName");
447 anAttr = SALOMEDS::AttributeName::_narrow( aGAttr );
448 anAttr->SetValue(name.c_str());
449 aSO=KERNEL::getStudyServant()->FindObjectByPath(pname.c_str());
452 begin=data.find_first_not_of(
"/",pos);
453 while (begin != std::string::npos)
455 pos = data.find_first_of(
"/", begin);
456 if (pos != std::string::npos)
457 name=data.substr(begin,pos-begin);
459 name=data.substr(begin);
461 begin=data.find_first_not_of(
"/",pos);
465 if(CORBA::is_nil(aSO))
467 std::cerr <<
"Execution problem: can not create id or path: " + data +
" in study" << std::endl;
472 SALOMEDS::AttributeComment_var commentAttr ;
473 SALOMEDS::AttributeReal_var realAttr ;
474 SALOMEDS::AttributeInteger_var intAttr ;
475 SALOMEDS::AttributeString_var stringAttr ;
483 aGAttr=aBuilder->FindOrCreateAttribute(aSO,
"AttributeIOR");
484 iorAttr = SALOMEDS::AttributeIOR::_narrow( aGAttr );
485 iorAttr->SetValue(value.c_str());
490 aGAttr=aBuilder->FindOrCreateAttribute(aSO,
"AttributeReal");
491 realAttr = SALOMEDS::AttributeReal::_narrow( aGAttr );
492 d=atof(value.c_str());
493 realAttr->SetValue(d);
498 aGAttr=aBuilder->FindOrCreateAttribute(aSO,
"AttributeInteger");
499 intAttr = SALOMEDS::AttributeInteger::_narrow( aGAttr );
500 v=atol(value.c_str());
501 intAttr->SetValue(v);
507 aGAttr=aBuilder->FindOrCreateAttribute(aSO,
"AttributeComment");
508 commentAttr = SALOMEDS::AttributeComment::_narrow( aGAttr );
509 commentAttr->SetValue(value.c_str());
514 aGAttr=aBuilder->FindOrCreateAttribute(aSO,
"AttributeComment");
515 commentAttr = SALOMEDS::AttributeComment::_narrow( aGAttr );
516 commentAttr->SetValue(value.c_str());
Base class for all component instances.
TypeCode * edGetType() const
std::string getName() const
Base class for all nodes.
Class for Study output Ports.
OutputStudyPort(const std::string &name, Node *node, TypeCode *type)
void setData(const std::string &data)
virtual std::string getPyObj()
virtual std::string getAsString()
returns port value as a string that can be used in a GUI for example
OutputPort * clone(Node *newHelder) const
virtual void getDataFromStudy()
virtual void putIOR(const std::string &ior)
virtual std::string dump()
Class for XML Output Ports.
virtual void put(const void *data)
Base class for all ports.
Base class for all schema objects.
std::map< std::string, ComponentInstance * > componentInstanceMap
CORBA::ORB_ptr getOrb() const
Class for Salome component instance.
Base class for all type objects.
SALOMEDS::SObject_ptr findOrCreateSoWithName(SALOMEDS::StudyBuilder_ptr builder, SALOMEDS::SObject_ptr sobj, const std::string &name)
YACSRUNTIMESALOME_EXPORT RuntimeSALOME * getSALOMERuntime()