Version: 9.15.0
YACS::ENGINE::OutputPyPort Class Reference

#include <PythonPorts.hxx>

Inheritance diagram for YACS::ENGINE::OutputPyPort:
Collaboration diagram for YACS::ENGINE::OutputPyPort:

Public Member Functions

 OutputPyPort (const std::string &name, Node *node, TypeCode *type)
 
 OutputPyPort (const OutputPyPort &other, Node *newHelder)
 
 ~OutputPyPort ()
 
virtual void put (const void *data)
 
void putWithoutForward (PyObject *data)
 
void put (PyObject *data)
 
OutputPortclone (Node *newHelder) const
 
virtual PyObject * get () const
 
virtual PyObjgetPyObj () const
 
virtual std::string getAsString ()
 returns port value as a string that can be used in a GUI for example More...
 
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

PyObject * _data
 
- 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
 

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 105 of file PythonPorts.hxx.

Constructor & Destructor Documentation

◆ OutputPyPort() [1/2]

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

Definition at line 266 of file PythonPorts.cxx.

267  : OutputPort(name, node, type), DataPort(name, node, type), Port(node)
268 {
269  _data = Py_None;
270  Py_INCREF(_data);
271 }
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

References _data.

Referenced by clone().

◆ OutputPyPort() [2/2]

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

Definition at line 282 of file PythonPorts.cxx.

282  :OutputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder),
283  _data(Py_None)
284 {
285  Py_INCREF(_data);
286 }

References _data.

◆ ~OutputPyPort()

OutputPyPort::~OutputPyPort ( )

Definition at line 272 of file PythonPorts.cxx.

273 {
274  PyGILState_STATE gstate = PyGILState_Ensure();
275  DEBTRACE( "_data refcnt: " << _data->ob_refcnt );
276  // Release or not release : all GenericObj are deleted when the output port is deleted
278  Py_XDECREF(_data);
279  PyGILState_Release(gstate);
280 }
void releasePyObj(PyObject *data)
Definition: PythonPorts.cxx:74
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _data, DEBTRACE, and releasePyObj().

Member Function Documentation

◆ clone()

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

Implements YACS::ENGINE::OutputPort.

Definition at line 314 of file PythonPorts.cxx.

315 {
316  return new OutputPyPort(*this,newHelder);
317 }
OutputPyPort(const std::string &name, Node *node, TypeCode *type)

References OutputPyPort().

◆ dump()

std::string OutputPyPort::dump ( )
virtual

Reimplemented from YACS::ENGINE::OutputPort.

Definition at line 340 of file PythonPorts.cxx.

341 {
343  string xmldump = convertPyObjectXml(edGetType(), _data);
344  return xmldump;
345 }
TypeCode * edGetType() const
Definition: DataPort.hxx:53
std::string convertPyObjectXml(const TypeCode *t, PyObject *data)

References _data, YACS::ENGINE::convertPyObjectXml(), YACS::ENGINE::DataPort::edGetType(), and testCppPluginInvokation::l.

◆ get()

PyObject * OutputPyPort::get ( ) const
virtual

Definition at line 319 of file PythonPorts.cxx.

320 {
321  return _data;
322 }

References _data.

◆ getAsString()

std::string OutputPyPort::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 329 of file PythonPorts.cxx.

330 {
331  std::string ret;
332  //protect _data against modification or delete in another thread
333  PyObject* data=_data;
334  Py_INCREF(data);
335  ret = convertPyObjectToString(data);
336  Py_XDECREF(data);
337  return ret;
338 }
std::string convertPyObjectToString(PyObject *ob)

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

◆ getPyObj()

PyObject * OutputPyPort::getPyObj ( ) const
virtual

Definition at line 324 of file PythonPorts.cxx.

325 {
326  return _data;
327 }

References _data.

Referenced by valToStr().

◆ put() [1/2]

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

Reimplemented from YACS::ENGINE::OutputPort.

Definition at line 288 of file PythonPorts.cxx.

289 {
290  put((PyObject *)data);
291 }
virtual void put(const void *data)

◆ put() [2/2]

void OutputPyPort::put ( PyObject *  data)

Definition at line 307 of file PythonPorts.cxx.

308 {
309  putWithoutForward(data);
310  DEBTRACE( "OutputPyPort::put.ob refcnt: " << data->ob_refcnt );
311  OutputPort::put(data);
312 }
virtual void put(const void *data)
Definition: OutputPort.cxx:66
void putWithoutForward(PyObject *data)

References DEBTRACE, YACS::ENGINE::OutputPort::put(), and putWithoutForward().

◆ putWithoutForward()

void OutputPyPort::putWithoutForward ( PyObject *  data)

Definition at line 293 of file PythonPorts.cxx.

294 {
295  DEBTRACE( "OutputPyPort::put.ob refcnt: " << data->ob_refcnt );
296 #ifdef _DEVDEBUG_
297  PyObject_Print(data,stderr,Py_PRINT_RAW);
298  cerr << endl;
299 #endif
301  Py_XDECREF(_data);
302  _data = data;
303  Py_INCREF(_data);
304  //no registerPyObj : we steal the output reference of the node
305 }

References _data, DEBTRACE, and releasePyObj().

Referenced by put(), YACS::ENGINE::PythonNode::squeezeMemory(), and YACS::ENGINE::PythonNode::squeezeMemoryRemote().

◆ typeName()

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

Reimplemented from YACS::ENGINE::OutputPort.

Definition at line 120 of file PythonPorts.hxx.

120 {return "YACS__ENGINE__OutputPyPort";}

◆ valFromStr()

void OutputPyPort::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 355 of file PythonPorts.cxx.

356 {
357 }

◆ valToStr()

std::string OutputPyPort::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 347 of file PythonPorts.cxx.

348 {
349  PyObject *strPyObj = PyObject_Str(getPyObj());
350  string val = PyBytes_AsString(strPyObj);
351  Py_DECREF(strPyObj);
352  return val;
353 }
virtual PyObj * getPyObj() const

References getPyObj().

Member Data Documentation

◆ _data

PyObject* YACS::ENGINE::OutputPyPort::_data
protected

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