Version: 8.3.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) throw (ConversionException)
 
void put (PyObject *data) throw (ConversionException)
 
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) throw (Exception)
 
virtual bool edAddInputPort (InputPort *phyPort) throw (Exception)
 
virtual bool edAddInPropertyPort (InPropertyPort *phyPort) throw (Exception)
 
virtual int edRemoveInputPort (InputPort *inputPort, bool forward) throw (Exception)
 
bool addInPort (InPort *inPort) throw (Exception)
 
void edRemoveAllLinksLinkedWithMe () throw (Exception)
 
virtual void exInit ()
 
virtual void checkBasicConsistency () const throw (Exception)
 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
 

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"
 
- 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...
 
- Static Protected Attributes inherited from YACS::ENGINE::Port
static int _total = 0
 
static const char NAME [] ="Port"
 

Detailed Description

Definition at line 102 of file PythonPorts.hxx.

Constructor & Destructor Documentation

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

Definition at line 282 of file PythonPorts.cxx.

References _data.

Referenced by clone().

283  : OutputPort(name, node, type), DataPort(name, node, type), Port(node)
284 {
285  _data = Py_None;
286  Py_INCREF(_data);
287 }
OutputPyPort::OutputPyPort ( const OutputPyPort other,
Node newHelder 
)

Definition at line 298 of file PythonPorts.cxx.

References _data.

298  :OutputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder),
299  _data(Py_None)
300 {
301  Py_INCREF(_data);
302 }
OutputPyPort::~OutputPyPort ( )

Definition at line 288 of file PythonPorts.cxx.

References _data, DEBTRACE, and releasePyObj().

289 {
290  PyGILState_STATE gstate = PyGILState_Ensure();
291  DEBTRACE( "_data refcnt: " << _data->ob_refcnt );
292  // Release or not release : all GenericObj are deleted when the output port is deleted
294  Py_XDECREF(_data);
295  PyGILState_Release(gstate);
296 }

Member Function Documentation

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

Implements YACS::ENGINE::OutputPort.

Definition at line 326 of file PythonPorts.cxx.

References OutputPyPort().

327 {
328  return new OutputPyPort(*this,newHelder);
329 }
std::string OutputPyPort::dump ( )
virtual

Reimplemented from YACS::ENGINE::OutputPort.

Definition at line 352 of file PythonPorts.cxx.

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

353 {
354  if( _data == Py_None)
355  return "<value>None</value>";
357  string xmldump = convertPyObjectXml(edGetType(), _data);
358  return xmldump;
359 }
PyObject * OutputPyPort::get ( ) const
virtual

Definition at line 331 of file PythonPorts.cxx.

References _data.

332 {
333  return _data;
334 }
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 341 of file PythonPorts.cxx.

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

342 {
343  std::string ret;
344  //protect _data against modification or delete in another thread
345  PyObject* data=_data;
346  Py_INCREF(data);
347  ret = convertPyObjectToString(data);
348  Py_XDECREF(data);
349  return ret;
350 }
PyObject * OutputPyPort::getPyObj ( ) const
virtual

Definition at line 336 of file PythonPorts.cxx.

References _data.

Referenced by valToStr().

337 {
338  return _data;
339 }
void OutputPyPort::put ( PyObject *  data) throw (ConversionException)

Definition at line 309 of file PythonPorts.cxx.

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

310 {
311  InputPort *p;
312  DEBTRACE( "OutputPyPort::put.ob refcnt: " << data->ob_refcnt );
313 #ifdef _DEVDEBUG_
314  PyObject_Print(data,stderr,Py_PRINT_RAW);
315  cerr << endl;
316 #endif
318  Py_XDECREF(_data);
319  _data = data;
320  Py_INCREF(_data);
321  //no registerPyObj : we steal the output reference of the node
322  DEBTRACE( "OutputPyPort::put.ob refcnt: " << data->ob_refcnt );
323  OutputPort::put(data);
324 }
virtual std::string YACS::ENGINE::OutputPyPort::typeName ( )
inlinevirtual

Reimplemented from YACS::ENGINE::OutputPort.

Definition at line 116 of file PythonPorts.hxx.

116 {return "YACS__ENGINE__OutputPyPort";}
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 369 of file PythonPorts.cxx.

370 {
371 }
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 361 of file PythonPorts.cxx.

References getPyObj().

362 {
363  PyObject *strPyObj = PyObject_Str(getPyObj());
364  string val = PyString_AsString(strPyObj);
365  Py_DECREF(strPyObj);
366  return val;
367 }

Member Data Documentation

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

Definition at line 120 of file PythonPorts.hxx.

Referenced by dump(), get(), getAsString(), getPyObj(), OutputPyPort(), and ~OutputPyPort().


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