Version: 9.15.0
YACS::ENGINE::OutputCorbaPort Class Reference

#include <CORBAPorts.hxx>

Inheritance diagram for YACS::ENGINE::OutputCorbaPort:
Collaboration diagram for YACS::ENGINE::OutputCorbaPort:

Public Member Functions

 OutputCorbaPort (const std::string &name, Node *node, TypeCode *type)
 
 OutputCorbaPort (const OutputCorbaPort &other, Node *newHelder)
 
virtual ~OutputCorbaPort ()
 
virtual void put (const void *data)
 
void put (CORBA::Any *data)
 
OutputPortclone (Node *newHelder) const
 
virtual CORBA::Any * getAny ()
 
virtual CORBA::Any * getAnyOut ()
 
virtual std::string getAsString ()
 returns port value as a string that can be used in a GUI for example More...
 
virtual PyObject * getPyObj ()
 
virtual std::string dump ()
 
virtual std::string typeName ()
 
virtual std::string valToStr ()
 Gives a string representation of the data, for user interfaces. More...
 
virtual void valFromStr (std::string valstr)
 Allows to set data from a string representation used in user interface. More...
 
- Public Member Functions inherited from YACS::ENGINE::OutputPort
virtual ~OutputPort ()
 
std::set< InPort * > edSetInPort () const
 
bool isAlreadyLinkedWith (InPort *withp) const
 
bool isAlreadyInSet (InputPort *inputPort) const
 
bool isConnected () const
 
std::string getNameOfTypeOfCurrentInstance () const
 
int removeInPort (InPort *inPort, bool forward)
 
virtual bool edAddInputPort (InputPort *phyPort)
 
virtual bool edAddInPropertyPort (InPropertyPort *phyPort)
 
virtual int edRemoveInputPort (InputPort *inputPort, bool forward)
 
bool addInPort (InPort *inPort)
 
void edRemoveAllLinksLinkedWithMe ()
 
virtual void exInit ()
 
virtual void checkBasicConsistency () const
 Check validity of output port. Nothing on base class. More...
 
- Public Member Functions inherited from YACS::ENGINE::DataFlowPort
TypeOfChannel getTypeOfChannel () const
 returns type of channel the port will use for data exchange on runtime : DATAFLOW or DATASTREAM. More...
 
virtual ~DataFlowPort ()
 
- Public Member Functions inherited from YACS::ENGINE::DataPort
TypeCodeedGetType () const
 
void edSetType (TypeCode *type)
 
std::string getName () const
 
void setName (std::string theName)
 
bool isDifferentTypeOf (const DataPort *other) const
 
- Public Member Functions inherited from YACS::ENGINE::Port
virtual ~Port ()
 
NodegetNode () const
 
int getNumId () const
 
void modified ()
 
- Public Member Functions inherited from YACS::ENGINE::OutPort
virtual void checkConsistency (LinkInfo &info) const
 
virtual int edGetNumberOfOutLinks () const
 
virtual void getAllRepresented (std::set< OutPort * > &represented) const
 
virtual ~OutPort ()
 
std::vector< DataPort * > calculateHistoryOfLinkWith (InPort *end)
 

Protected Attributes

CORBA::Any _data
 
CORBA::ORB_ptr _orb
 
- Protected Attributes inherited from YACS::ENGINE::OutputPort
std::set< InputPort * > _setOfInputPort
 
- Protected Attributes inherited from YACS::ENGINE::DataPort
TypeCode_type
 
std::string _name
 
- Protected Attributes inherited from YACS::ENGINE::Port
Node_node
 
int _id
 

Private Attributes

YACS::BASES::Mutex _mutex
 

Friends

std::ostream & operator<< (std::ostream &os, const OutputCorbaPort &p)
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::ENGINE::DataPort
static DataPortisCrossingType (const std::vector< DataPort * > &historyOfLink)
 
- Static Public Attributes inherited from YACS::ENGINE::OutputPort
static const char NAME [] ="OutputPort"
 
- Static Public Attributes inherited from YACS::ENGINE::DataFlowPort
static const char NAME [] ="DataFlowPort"
 
- Static Public Attributes inherited from YACS::ENGINE::DataPort
static const char NAME [] ="DataPort"
 
- Protected Member Functions inherited from YACS::ENGINE::OutputPort
 OutputPort (const OutputPort &other, Node *newHelder)
 
 OutputPort (const std::string &name, Node *node, TypeCode *type)
 
const std::set< InputPort * > & getSetOfPhyLinks () const
 Returns physical links linked to this. Contrary to edSetInPort that returns semantic links. More...
 
- Protected Member Functions inherited from YACS::ENGINE::DataFlowPort
 DataFlowPort (const DataFlowPort &other, Node *newHelder)
 
 DataFlowPort (const std::string &name, Node *node, TypeCode *type)
 
- Protected Member Functions inherited from YACS::ENGINE::DataPort
virtual ~DataPort ()
 
 DataPort (const DataPort &other, Node *newHelder)
 
 DataPort (const std::string &name, Node *node, TypeCode *type)
 
- Protected Member Functions inherited from YACS::ENGINE::Port
 Port (Node *node)
 
 Port (const Port &other, Node *newHelder)
 
- Protected Member Functions inherited from YACS::ENGINE::OutPort
 OutPort (const OutPort &other, Node *newHelder)
 
 OutPort (const std::string &name, Node *node, TypeCode *type)
 
- Static Protected Attributes inherited from YACS::ENGINE::Port
static int _total = 0
 
static const char NAME [] ="Port"
 

Detailed Description

Definition at line 80 of file CORBAPorts.hxx.

Constructor & Destructor Documentation

◆ OutputCorbaPort() [1/2]

OutputCorbaPort::OutputCorbaPort ( const std::string &  name,
Node node,
TypeCode type 
)

Definition at line 292 of file CORBAPorts.cxx.

295  : OutputPort(name, node, type), DataPort(name, node, type), Port(node)
296 {
298 }
DataPort(const DataPort &other, Node *newHelder)
Definition: DataPort.cxx:41
OutputPort(const OutputPort &other, Node *newHelder)
Definition: OutputPort.cxx:38
Port(Node *node)
Definition: Port.cxx:34
CORBA::ORB_ptr getOrb() const
YACSRUNTIMESALOME_EXPORT RuntimeSALOME * getSALOMERuntime()

References _orb, YACS::ENGINE::RuntimeSALOME::getOrb(), and YACS::ENGINE::getSALOMERuntime().

Referenced by clone().

◆ OutputCorbaPort() [2/2]

OutputCorbaPort::OutputCorbaPort ( const OutputCorbaPort other,
Node newHelder 
)

Definition at line 300 of file CORBAPorts.cxx.

300  :OutputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder)
301 {
303 }

References _orb, YACS::ENGINE::RuntimeSALOME::getOrb(), and YACS::ENGINE::getSALOMERuntime().

◆ ~OutputCorbaPort()

OutputCorbaPort::~OutputCorbaPort ( )
virtual

Definition at line 305 of file CORBAPorts.cxx.

306 {
307  DEBTRACE(getName());
308  // Release or not release : all GenericObj are deleted when the output port is deleted
309  releaseObj(_data);
310 #ifdef REFCNT
311  DEBTRACE("refcount CORBA : " << ((omni::TypeCode_base*)_data.pd_tc.in())->pd_ref_count);
312  DEBTRACE("refcount CORBA tc_double: " << ((omni::TypeCode_base*)CORBA::_tc_double)->pd_ref_count);
313 #endif
314 }
void releaseObj(CORBA::Any &data)
Definition: CORBAPorts.cxx:48
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
std::string getName() const
Definition: DataPort.hxx:55

References _data, DEBTRACE, YACS::ENGINE::DataPort::getName(), and releaseObj().

Member Function Documentation

◆ clone()

OutputPort * OutputCorbaPort::clone ( Node newHelder) const
virtual

Implements YACS::ENGINE::OutputPort.

Definition at line 353 of file CORBAPorts.cxx.

354 {
355  return new OutputCorbaPort(*this,newHelder);
356 }
OutputCorbaPort(const std::string &name, Node *node, TypeCode *type)
Definition: CORBAPorts.cxx:292

References OutputCorbaPort().

◆ dump()

std::string OutputCorbaPort::dump ( )
virtual

Reimplemented from YACS::ENGINE::OutputPort.

Definition at line 450 of file CORBAPorts.cxx.

451 {
452  CORBA::TypeCode_var tc=_data.type();
453  if (tc->equivalent(CORBA::_tc_null))
454  return "<value>nil</value>";
455  string xmldump = convertCorbaXml(edGetType(), &_data);
456  return xmldump;
457 }
TypeCode * edGetType() const
Definition: DataPort.hxx:53
std::string convertCorbaXml(const TypeCode *t, CORBA::Any *data)

References _data, YACS::ENGINE::convertCorbaXml(), and YACS::ENGINE::DataPort::edGetType().

◆ getAny()

CORBA::Any * OutputCorbaPort::getAny ( )
virtual

Definition at line 358 of file CORBAPorts.cxx.

359 {
360  // return a pointer to the internal any
361  return &_data;
362 }

References _data.

Referenced by getPyObj().

◆ getAnyOut()

CORBA::Any * OutputCorbaPort::getAnyOut ( )
virtual

Definition at line 364 of file CORBAPorts.cxx.

365 {
366  CORBA::Any* a=new CORBA::Any;
367  DynType kind=edGetType()->kind();
368  CORBA::TypeCode_var t;
369 
370  if(kind == Int)
371  {
372  a->replace(CORBA::_tc_long, (void*) 0);
373  }
374  else if(kind == String)
375  {
376  a->replace(CORBA::_tc_string, (void*) 0);
377  }
378  else if(kind == Double)
379  {
380  a->replace(CORBA::_tc_double, (void*) 0);
381  }
382  else if(kind == Objref)
383  {
384  t = getCorbaTC(edGetType());
385  a->replace(t, (void*) 0);
386  }
387  else if(kind == Sequence)
388  {
389  t = getCorbaTC(edGetType());
390  a->replace(t, (void*) 0);
391  }
392  else if(kind == Struct)
393  {
394  t = getCorbaTC(edGetType());
395 #ifdef REFCNT
396  DEBTRACE("refcount CORBA : " << ((omni::TypeCode_base*)t.in())->pd_ref_count);
397 #endif
398  a->replace(t, (void*) 0);
399 #ifdef REFCNT
400  DEBTRACE("refcount CORBA : " << ((omni::TypeCode_base*)t.in())->pd_ref_count);
401 #endif
402  }
403  else if(kind == Bool)
404  {
405  a->replace(CORBA::_tc_boolean, (void*) 0);
406  }
407  else if(kind == NONE)
408  {
409  stringstream msg;
410  msg << "Cannot set Any Out for None" << __FILE__ << ":" << __LINE__;
411  throw Exception(msg.str());
412  }
413  else
414  {
415  stringstream msg;
416  msg << "Cannot set Any Out for unknown type" << __FILE__
417  << ":" << __LINE__;
418  throw Exception(msg.str());
419  }
420 
421  DEBTRACE( "getAnyOut:a: " << a );
422 #ifdef REFCNT
423  DEBTRACE("refcount CORBA : " << ((omni::TypeCode_base*)a->pd_tc.in())->pd_ref_count);
424 #endif
425  return a;
426 }
DynType kind() const
Definition: TypeCode.cxx:47
CORBA::TypeCode_ptr getCorbaTC(const TypeCode *t)

References gui.CONNECTOR::a, YACS::ENGINE::Bool, DEBTRACE, YACS::ENGINE::Double, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::getCorbaTC(), YACS::ENGINE::Int, YACS::ENGINE::TypeCode::kind(), YACS::ENGINE::NONE, YACS::ENGINE::Objref, YACS::ENGINE::Sequence, YACS::ENGINE::String, YACS::ENGINE::Struct, and gui.Appli::t.

◆ getAsString()

std::string OutputCorbaPort::getAsString ( )
virtual

returns port value as a string that can be used in a GUI for example

Do nothing here. To subclass

Reimplemented from YACS::ENGINE::DataPort.

Definition at line 441 of file CORBAPorts.cxx.

442 {
444  PyObject* ob=getPyObj();
445  std::string s=convertPyObjectToString(ob);
446  Py_DECREF(ob);
447  return s;
448 }
virtual PyObject * getPyObj()
Definition: CORBAPorts.cxx:428
std::string convertPyObjectToString(PyObject *ob)

References YACS::ENGINE::convertPyObjectToString(), and getPyObj().

◆ getPyObj()

PyObject * OutputCorbaPort::getPyObj ( )
virtual

Definition at line 428 of file CORBAPorts.cxx.

429 {
431  CORBA::TypeCode_var tc=getAny()->type();
432  if (!tc->equivalent(CORBA::_tc_null))
434  else
435  {
436  Py_INCREF(Py_None);
437  return Py_None;
438  }
439 }
YACS::BASES::Mutex _mutex
Definition: CORBAPorts.hxx:103
virtual CORBA::Any * getAny()
Definition: CORBAPorts.cxx:358
PyObject * convertCorbaPyObject(const TypeCode *t, CORBA::Any *data)

References _mutex, YACS::ENGINE::convertCorbaPyObject(), YACS::ENGINE::DataPort::edGetType(), and getAny().

Referenced by getAsString(), and valToStr().

◆ put() [1/2]

void OutputCorbaPort::put ( const void *  data)
virtual

Reimplemented from YACS::ENGINE::OutputPort.

Definition at line 316 of file CORBAPorts.cxx.

317 {
318  put((CORBA::Any *)data);
319 }
virtual void put(const void *data)
Definition: CORBAPorts.cxx:316

◆ put() [2/2]

void OutputCorbaPort::put ( CORBA::Any *  data)

Definition at line 321 of file CORBAPorts.cxx.

322 {
323  InputPort *p;
324 
325  {
327 #ifdef REFCNT
328  DEBTRACE("refcount CORBA : " << ((omni::TypeCode_base*)data->pd_tc.in())->pd_ref_count);
329 #endif
330 #ifdef REFCNT
331  DEBTRACE("refcount CORBA : " << ((omni::TypeCode_base*)_data.pd_tc.in())->pd_ref_count);
332 #endif
333 
334  releaseObj(_data);
335 
336  _data=*data;
337 
338  //no registerObj : we steal the output reference of the node
339  }
340 
341 #ifdef REFCNT
342  DEBTRACE("refcount CORBA : " << ((omni::TypeCode_base*)_data.pd_tc.in())->pd_ref_count);
343 #endif
344  OutputPort::put(data);
345 #ifdef REFCNT
346  DEBTRACE("refcount CORBA : " << ((omni::TypeCode_base*)data->pd_tc.in())->pd_ref_count);
347 #endif
348 #ifdef REFCNT
349  DEBTRACE("refcount CORBA : " << ((omni::TypeCode_base*)_data.pd_tc.in())->pd_ref_count);
350 #endif
351 }
Base class for Input Ports.
Definition: InputPort.hxx:44
virtual void put(const void *data)
Definition: OutputPort.cxx:66
Proc * p
Definition: driver.cxx:216

References _data, _mutex, DEBTRACE, p, YACS::ENGINE::OutputPort::put(), and releaseObj().

◆ typeName()

virtual std::string YACS::ENGINE::OutputCorbaPort::typeName ( )
inlinevirtual

Reimplemented from YACS::ENGINE::OutputPort.

Definition at line 96 of file CORBAPorts.hxx.

96 {return "YACS__ENGINE__OutputCorbaPort";}

◆ valFromStr()

void OutputCorbaPort::valFromStr ( std::string  valstr)
virtual

Allows to set data from a string representation used in user interface.

Implemented in derived classes, depending on runtime, to set the data from its user interface representation. Typical use, a Python string representation that can be used in edition or restitution.

Reimplemented from YACS::ENGINE::DataFlowPort.

Definition at line 478 of file CORBAPorts.cxx.

479 {
480 }

◆ valToStr()

std::string OutputCorbaPort::valToStr ( )
virtual

Gives a string representation of the data, for user interfaces.

Implemented in derived classes, depending on runtime, to provide the data representation for user interfaces. Typical use, a Python string representation that can be used in edition or restitution.

Reimplemented from YACS::ENGINE::DataFlowPort.

Definition at line 470 of file CORBAPorts.cxx.

471 {
472  PyObject *strPyObj = PyObject_Str(getPyObj());
473  string val = PyBytes_AsString(strPyObj);
474  Py_DECREF(strPyObj);
475  return val;
476 }

References getPyObj().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const OutputCorbaPort p 
)
friend

Member Data Documentation

◆ _data

CORBA::Any YACS::ENGINE::OutputCorbaPort::_data
protected

Definition at line 100 of file CORBAPorts.hxx.

Referenced by dump(), getAny(), put(), and ~OutputCorbaPort().

◆ _mutex

YACS::BASES::Mutex YACS::ENGINE::OutputCorbaPort::_mutex
private

Definition at line 103 of file CORBAPorts.hxx.

Referenced by getPyObj(), and put().

◆ _orb

CORBA::ORB_ptr YACS::ENGINE::OutputCorbaPort::_orb
protected

Definition at line 101 of file CORBAPorts.hxx.

Referenced by OutputCorbaPort().


The documentation for this class was generated from the following files: