Version: 9.16.0
YACS::ENGINE::InputCorbaPort Class Reference

Class for CORBA Input Ports. More...

#include <CORBAPorts.hxx>

Inheritance diagram for YACS::ENGINE::InputCorbaPort:
Collaboration diagram for YACS::ENGINE::InputCorbaPort:

Public Member Functions

 InputCorbaPort (const std::string &name, Node *node, TypeCode *type)
 
 InputCorbaPort (const InputCorbaPort &other, Node *newHelder)
 
virtual ~InputCorbaPort ()
 
bool edIsManuallyInitialized () const
 Specifies if this port has been manually set by the call of InputPort::edInit. More...
 
void edRemoveManInit ()
 Removes eventually previous manual initialisation. More...
 
virtual void put (const void *data)
 
void put (CORBA::Any *data)
 
void releaseData () override
 
InputPortclone (Node *newHelder) const
 
void * get () const
 
virtual bool isEmpty ()
 
virtual CORBA::Any * getAny ()
 
virtual std::string getAsString ()
 returns port value as a string that can be used in a GUI for example More...
 
virtual PyObject * getPyObj ()
 
virtual void exSaveInit ()
 Save the current data value for further reinitialization of the port. More...
 
virtual void exRestoreInit ()
 Restore the saved data value to current data value. 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::InputPort
virtual ~InputPort ()
 
std::string getNameOfTypeOfCurrentInstance () const
 
virtual InputPortgetPublicRepresentant ()
 returns the final physical port behind 'this'. More...
 
virtual bool isIntermediate () const
 
virtual bool edIsManuallyInitialized () const
 Specifies if this port has been manually set by the call of InputPort::edInit. More...
 
bool edIsInitialized () const
 soon deprecated More...
 
template<class T >
void edInit (T value)
 
void edInit (Any *value)
 
void edInit (const std::string &impl, const void *value)
 Initialize the port with an object (value) coming from a world with implementation impl. More...
 
virtual void edRemoveManInit ()
 Removes eventually previous manual initialisation. More...
 
virtual void checkBasicConsistency () const
 Check basically that this port has one chance to be specified on time. It's a necessary condition not sufficient at all. More...
 
virtual void exInit (bool start)
 
virtual void exSaveInit ()=0
 
virtual void exRestoreInit ()=0
 
virtual InputPortclone (Node *newHelder) const =0
 
virtual bool isEmpty ()
 
virtual void * get () const =0
 
virtual void releaseData ()=0
 
virtual void put (const void *data)=0
 
virtual std::string dump ()
 
virtual std::string getHumanRepr ()
 
virtual void setStringRef (std::string strRef)
 
virtual std::string typeName ()
 
bool canBeNull () const
 
- Public Member Functions inherited from YACS::ENGINE::DataFlowPort
std::string getNameOfTypeOfCurrentInstance () const
 
TypeOfChannel getTypeOfChannel () const
 returns type of channel the port will use for data exchange on runtime : DATAFLOW or DATASTREAM. More...
 
virtual ~DataFlowPort ()
 
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::DataPort
TypeCodeedGetType () const
 
void edSetType (TypeCode *type)
 
std::string getName () const
 
void setName (std::string theName)
 
std::string getNameOfTypeOfCurrentInstance () const
 
virtual TypeOfChannel getTypeOfChannel () const =0
 returns type of channel the port will use for data exchange on runtime : DATAFLOW or DATASTREAM. More...
 
bool isDifferentTypeOf (const DataPort *other) const
 
virtual void edRemoveAllLinksLinkedWithMe ()=0
 
virtual std::string typeName ()
 
virtual std::string getAsString ()
 returns port value as a string that can be used in a GUI for example More...
 
- Public Member Functions inherited from YACS::ENGINE::Port
virtual ~Port ()
 
NodegetNode () const
 
virtual std::string getNameOfTypeOfCurrentInstance () const
 
int getNumId () const
 
virtual std::string typeName ()
 
void modified ()
 
- Public Member Functions inherited from YACS::ENGINE::InPort
virtual InPortgetPublicRepresentant ()
 
virtual int edGetNumberOfLinks () const
 Returns number of physical backlinks NOT number of user backlinks. More...
 
virtual std::set< OutPort * > edSetOutPort () const
 Returns physical backlinks NOT user backlinks. More...
 
bool canSafelySqueezeMemory () const
 
bool isBackLinked () const
 
virtual ~InPort ()
 
virtual std::string typeName ()
 

Protected Attributes

CORBA::Any _data
 
CORBA::Any * _initData
 
CORBA::ORB_ptr _orb
 
- Protected Attributes inherited from YACS::ENGINE::InputPort
Any_initValue
 
std::string _stringRef
 
bool _canBeNull
 
- Protected Attributes inherited from YACS::ENGINE::DataPort
TypeCode_type
 
std::string _name
 
- Protected Attributes inherited from YACS::ENGINE::Port
Node_node
 
int _id
 
- Protected Attributes inherited from YACS::ENGINE::InPort
std::set< std::pair< OutPort *, bool > > _backLinks
 

Private Attributes

YACS::BASES::Mutex _mutex
 

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::InputPort
static const char NAME [] ="InputPort"
 
- 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::InputPort
 InputPort (const InputPort &other, Node *newHelder)
 
 InputPort (const std::string &name, Node *node, TypeCode *type, bool canBeNull=false)
 
void releaseDataUnsafe ()
 
- 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::InPort
 InPort (const InPort &other, Node *newHelder)
 
 InPort (const std::string &name, Node *node, TypeCode *type)
 
void edRemoveAllLinksLinkedWithMe ()
 
virtual void edNotifyReferencedBy (OutPort *fromPort, bool isLoopProof=true)
 
virtual void edNotifyDereferencedBy (OutPort *fromPort)
 
virtual void getAllRepresentants (std::set< InPort * > &repr) const
 
- Static Protected Attributes inherited from YACS::ENGINE::Port
static int _total = 0
 
static const char NAME [] ="Port"
 

Detailed Description

Class for CORBA Input Ports.

See also
CORBANode

Definition at line 44 of file CORBAPorts.hxx.

Constructor & Destructor Documentation

◆ InputCorbaPort() [1/2]

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

Definition at line 100 of file CORBAPorts.cxx.

103 : InputPort(name, node, type), DataPort(name, node, type), Port(node), _initData(0)
104{
106}
DataPort(const DataPort &other, Node *newHelder)
Definition: DataPort.cxx:41
InputPort(const InputPort &other, Node *newHelder)
Definition: InputPort.cxx:36
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().

◆ InputCorbaPort() [2/2]

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

Definition at line 108 of file CORBAPorts.cxx.

108 :InputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder),
109 _initData(0)
110{
112 if(other._initData)
113 {
114 _initData=new CORBA::Any;
115 *_initData=*(other._initData);
116 }
117 _data=other._data;
118}

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

◆ ~InputCorbaPort()

InputCorbaPort::~InputCorbaPort ( )
virtual

Definition at line 120 of file CORBAPorts.cxx.

121{
122 delete _initData;
123 // Release or not release : all GenericObj are deleted when the input port is deleted
125}
void releaseObj(CORBA::Any &data)
Definition: CORBAPorts.cxx:48

References _data, _initData, and releaseObj().

Member Function Documentation

◆ clone()

InputPort * InputCorbaPort::clone ( Node newHelder) const
virtual

Implements YACS::ENGINE::InputPort.

Definition at line 191 of file CORBAPorts.cxx.

192{
193 return new InputCorbaPort(*this,newHelder);
194}
InputCorbaPort(const std::string &name, Node *node, TypeCode *type)
Definition: CORBAPorts.cxx:100

References InputCorbaPort().

◆ dump()

std::string InputCorbaPort::dump ( )
virtual

Reimplemented from YACS::ENGINE::InputPort.

Definition at line 258 of file CORBAPorts.cxx.

259{
260 CORBA::TypeCode_var tc=_data.type();
261 if (tc->equivalent(CORBA::_tc_null))
262 return "<value>nil</value>";
263 if (edGetType()->kind() != YACS::ENGINE::Objref)
264 return convertCorbaXml(edGetType(), &_data);
265 if (! _stringRef.empty())
266 return _stringRef;
267 else
268 return convertCorbaXml(edGetType(), &_data);
269// {
270// stringstream msg;
271// msg << "Cannot retreive init string reference string for port " << _name
272// << " on node " << _node->getName();
273// throw Exception(msg.str());
274// }
275}
TypeCode * edGetType() const
Definition: DataPort.hxx:53
std::string _stringRef
Definition: InputPort.hxx:90
std::string convertCorbaXml(const TypeCode *t, CORBA::Any *data)

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

◆ edIsManuallyInitialized()

bool InputCorbaPort::edIsManuallyInitialized ( ) const
virtual

Specifies if this port has been manually set by the call of InputPort::edInit.

Reimplemented from YACS::ENGINE::InputPort.

Definition at line 127 of file CORBAPorts.cxx.

128{
129 return _initData!=0;
130}

References _initData.

◆ edRemoveManInit()

void InputCorbaPort::edRemoveManInit ( )
virtual

Removes eventually previous manual initialisation.

Reimplemented from YACS::ENGINE::InputPort.

Definition at line 132 of file CORBAPorts.cxx.

133{
134 delete _initData;
135 _initData=0;
137}
virtual void edRemoveManInit()
Removes eventually previous manual initialisation.
Definition: InputPort.cxx:140

References _initData, and YACS::ENGINE::InputPort::edRemoveManInit().

◆ exRestoreInit()

void InputCorbaPort::exRestoreInit ( )
virtual

Restore the saved data value to current data value.

If no data has been saved (_initData == 0) don't restore

Implements YACS::ENGINE::InputPort.

Definition at line 252 of file CORBAPorts.cxx.

253{
254 if(!_initData)return;
255 put(_initData);
256}
virtual void put(const void *data)
Definition: CORBAPorts.cxx:139

References _initData, and put().

◆ exSaveInit()

void InputCorbaPort::exSaveInit ( )
virtual

Save the current data value for further reinitialization of the port.

Implements YACS::ENGINE::InputPort.

Definition at line 240 of file CORBAPorts.cxx.

241{
242 if(_initData)
243 delete _initData;
244 _initData=new CORBA::Any;
246}

References _data, and _initData.

◆ get()

void * InputCorbaPort::get ( ) const
virtual

Implements YACS::ENGINE::InputPort.

Definition at line 196 of file CORBAPorts.cxx.

197{
198 return (void *)&_data;
199}

References _data.

◆ getAny()

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

Definition at line 207 of file CORBAPorts.cxx.

208{
209 // --- return a pointer to internal any
210 return &_data;
211}

References _data.

Referenced by getPyObj().

◆ getAsString()

std::string InputCorbaPort::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 226 of file CORBAPorts.cxx.

227{
229 PyObject* ob=getPyObj();
230 std::string s=convertPyObjectToString(ob);
231 Py_DECREF(ob);
232 return s;
233}
virtual PyObject * getPyObj()
Definition: CORBAPorts.cxx:213
std::string convertPyObjectToString(PyObject *ob)

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

◆ getPyObj()

PyObject * InputCorbaPort::getPyObj ( )
virtual

Definition at line 213 of file CORBAPorts.cxx.

214{
216 CORBA::TypeCode_var tc=getAny()->type();
217 if (!tc->equivalent(CORBA::_tc_null))
219 else
220 {
221 Py_INCREF(Py_None);
222 return Py_None;
223 }
224}
virtual CORBA::Any * getAny()
Definition: CORBAPorts.cxx:207
YACS::BASES::Mutex _mutex
Definition: CORBAPorts.hxx:72
PyObject * convertCorbaPyObject(const TypeCode *t, CORBA::Any *data)

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

Referenced by getAsString(), and valToStr().

◆ isEmpty()

bool InputCorbaPort::isEmpty ( )
virtual

Reimplemented from YACS::ENGINE::InputPort.

Definition at line 201 of file CORBAPorts.cxx.

202{
203 CORBA::TypeCode_var tc=_data.type();
204 return tc->equivalent(CORBA::_tc_null);
205}

References _data.

◆ put() [1/2]

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

Implements YACS::ENGINE::InputPort.

Definition at line 139 of file CORBAPorts.cxx.

140{
141 put((CORBA::Any *)data);
142}

References put().

Referenced by exRestoreInit(), and put().

◆ put() [2/2]

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

Definition at line 168 of file CORBAPorts.cxx.

169{
170#ifdef REFCNT
171 DEBTRACE("refcount CORBA : " << ((omni::TypeCode_base*)data->pd_tc.in())->pd_ref_count);
172#endif
174#ifdef _DEVDEBUG_
175 display(data);
176#endif
177
179
180 // make a copy of the any (protect against deletion of any source)
181 _data=*data;
182 _stringRef="";
183
185
186#ifdef REFCNT
187 DEBTRACE("refcount CORBA : " << ((omni::TypeCode_base*)_data.pd_tc.in())->pd_ref_count);
188#endif
189}
void display(CORBA::Any *data)
Definition: CORBAPorts.cxx:144
void registerObj(CORBA::Any &data)
Definition: CORBAPorts.cxx:74
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _data, _mutex, YACS::ENGINE::InputPort::_stringRef, DEBTRACE, display(), registerObj(), and releaseObj().

◆ releaseData()

void InputCorbaPort::releaseData ( )
overridevirtual

Implements YACS::ENGINE::InputPort.

Definition at line 164 of file CORBAPorts.cxx.

165{//do nothing - to be implemented
166}

◆ typeName()

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

Reimplemented from YACS::ENGINE::InputPort.

Definition at line 64 of file CORBAPorts.hxx.

64{return "YACS__ENGINE__InputCorbaPort";}

◆ valFromStr()

void InputCorbaPort::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 288 of file CORBAPorts.cxx.

289{
290}

◆ valToStr()

std::string InputCorbaPort::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 277 of file CORBAPorts.cxx.

278{
279 int isString = PyBytes_Check(getPyObj());
280 PyObject *strPyObj = PyObject_Str(getPyObj());
281 string val = PyBytes_AsString(strPyObj);
282 if (isString)
283 val = "\"" + val + "\"";
284 Py_DECREF(strPyObj);
285 return val;
286}

References getPyObj().

Member Data Documentation

◆ _data

CORBA::Any YACS::ENGINE::InputCorbaPort::_data
protected

Definition at line 68 of file CORBAPorts.hxx.

Referenced by dump(), exSaveInit(), get(), getAny(), InputCorbaPort(), isEmpty(), put(), and ~InputCorbaPort().

◆ _initData

CORBA::Any* YACS::ENGINE::InputCorbaPort::_initData
protected

◆ _mutex

YACS::BASES::Mutex YACS::ENGINE::InputCorbaPort::_mutex
private

Definition at line 72 of file CORBAPorts.hxx.

Referenced by getPyObj(), and put().

◆ _orb

CORBA::ORB_ptr YACS::ENGINE::InputCorbaPort::_orb
protected

Definition at line 70 of file CORBAPorts.hxx.

Referenced by InputCorbaPort().


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