Version: 9.15.0
YACS::ENGINE::OutputStudyPort Class Reference

Class for Study output Ports. More...

#include <StudyPorts.hxx>

Inheritance diagram for YACS::ENGINE::OutputStudyPort:
Collaboration diagram for YACS::ENGINE::OutputStudyPort:

Public Member Functions

 OutputStudyPort (const std::string &name, Node *node, TypeCode *type)
 
 OutputStudyPort (const OutputStudyPort &other, Node *newHelder)
 
OutputPortclone (Node *newHelder) const
 
void setData (const std::string &data)
 
std::string getData ()
 
virtual void putIOR (const std::string &ior)
 
virtual std::string dump ()
 
virtual std::string getPyObj ()
 
virtual std::string getAsString ()
 returns port value as a string that can be used in a GUI for example More...
 
virtual std::string typeName ()
 
virtual void getDataFromStudy ()
 
- Public Member Functions inherited from YACS::ENGINE::OutputXmlPort
 OutputXmlPort (const std::string &name, Node *node, TypeCode *type)
 
 OutputXmlPort (const OutputXmlPort &other, Node *newHelder)
 
virtual void put (const void *data)
 
void put (const char *data)
 
virtual const char * get () const
 
OutputPortclone (Node *newHelder) const
 
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

std::string _storeData
 
- Protected Attributes inherited from YACS::ENGINE::OutputXmlPort
std::string _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

Class for Study output Ports.

See also
StudyInNode

Definition at line 32 of file StudyPorts.hxx.

Constructor & Destructor Documentation

◆ OutputStudyPort() [1/2]

YACS::ENGINE::OutputStudyPort::OutputStudyPort ( const std::string &  name,
Node node,
TypeCode type 
)

Definition at line 52 of file StudyPorts.cxx.

53  : OutputXmlPort(name, node, type),
54  DataPort(name, node, type),
55  Port(node)
56 {
57 }
DataPort(const DataPort &other, Node *newHelder)
Definition: DataPort.cxx:41
OutputXmlPort(const std::string &name, Node *node, TypeCode *type)
Definition: XMLPorts.cxx:122
Port(Node *node)
Definition: Port.cxx:34

Referenced by clone().

◆ OutputStudyPort() [2/2]

YACS::ENGINE::OutputStudyPort::OutputStudyPort ( const OutputStudyPort other,
Node newHelder 
)

Definition at line 59 of file StudyPorts.cxx.

60  : OutputXmlPort(other,newHelder),
61  DataPort(other,newHelder),
62  Port(other,newHelder),_storeData(other._storeData)
63 {
64 }

Member Function Documentation

◆ clone()

OutputPort * YACS::ENGINE::OutputStudyPort::clone ( Node newHelder) const
virtual

Implements YACS::ENGINE::OutputPort.

Definition at line 66 of file StudyPorts.cxx.

67 {
68  return new OutputStudyPort(*this,newHelder);
69 }
OutputStudyPort(const std::string &name, Node *node, TypeCode *type)
Definition: StudyPorts.cxx:52

References OutputStudyPort().

◆ dump()

std::string YACS::ENGINE::OutputStudyPort::dump ( )
virtual

Reimplemented from YACS::ENGINE::OutputXmlPort.

Definition at line 122 of file StudyPorts.cxx.

123 {
124  DEBTRACE( "OutputStudyPort::dump " << _storeData );
125  DEBTRACE( "OutputStudyPort::dump " << _data );
126  //return "<value><string>"+_storeData+"</string></value>";
127  return _data;
128 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References YACS::ENGINE::OutputXmlPort::_data, _storeData, and DEBTRACE.

◆ getAsString()

std::string YACS::ENGINE::OutputStudyPort::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 134 of file StudyPorts.cxx.

135 {
136  return getData();
137 }

References getData().

Referenced by YACS::HMI::CommandSetOutPortValue::localExecute(), and YACS::HMI::CommandSetOutPortValue::localReverse().

◆ getData()

std::string YACS::ENGINE::OutputStudyPort::getData ( )

◆ getDataFromStudy()

void YACS::ENGINE::OutputStudyPort::getDataFromStudy ( )
virtual

Definition at line 139 of file StudyPorts.cxx.

140 {
141  std::string data = getData();
142  DEBTRACE("data: " << data );
143  //try an id
144  SALOMEDS::SObject_var aSO = KERNEL::getStudyServant()->FindObjectID(data.c_str());
145  if(CORBA::is_nil(aSO))
146  {
147  //try a path
148  aSO=KERNEL::getStudyServant()->FindObjectByPath(data.c_str());
149  if(CORBA::is_nil(aSO))
150  {
151  std::stringstream msg;
152  msg << "Execution problem: no id or path: " << data << " in study";
153  throw Exception(msg.str());
154  }
155  }
156 
157  CORBA::String_var path=KERNEL::getStudyServant()->GetObjectPath(aSO);
158  DEBTRACE(path);
159  CORBA::String_var id=aSO->GetID();
160  DEBTRACE(id);
161  //CORBA::Object_var sobj=aSO->GetObject();
162 
163  SALOMEDS::GenericAttribute_var aGAttr;
164  CORBA::String_var value;
165 
166  if(edGetType()->kind()==Objref)
167  {
168  if ( aSO->FindAttribute( aGAttr, "AttributeIOR" ) )
169  {
170  SALOMEDS::AttributeIOR_var anAttr = SALOMEDS::AttributeIOR::_narrow( aGAttr );
171  value=anAttr->Value();
172  putIOR((const char*)value);
173  }
174  else
175  {
176  //Problem !!!
177  std::string error="Execution problem: no AttributeIOR in study object: ";
178  error=error+data;
179  throw Exception(error);
180  }
181  }
182  else if(edGetType()->kind()==Double )
183  {
184  if ( aSO->FindAttribute( aGAttr, "AttributeReal" ) )
185  {
186  SALOMEDS::AttributeReal_var anAttr = SALOMEDS::AttributeReal::_narrow( aGAttr );
187  CORBA::Double d=anAttr->Value();
188  std::stringstream msg;
189  msg << "<value><double>" << std::setprecision(16) << d << "</double></value>";
190  put(msg.str().c_str());
191  }
192  else
193  {
194  std::string error="Execution problem: no AttributeReal in study object: ";
195  throw Exception(error+data);
196  }
197  }
198  else if(edGetType()->kind()== Int)
199  {
200  if ( aSO->FindAttribute( aGAttr, "AttributeInteger" ) )
201  {
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());
207  }
208  else
209  {
210  std::string error="Execution problem: no AttributeInteger in study object: ";
211  throw Exception(error+data);
212  }
213  }
214  else
215  {
216  if ( aSO->FindAttribute( aGAttr, "AttributeComment" ) )
217  {
218  SALOMEDS::AttributeComment_var anAttr = SALOMEDS::AttributeComment::_narrow( aGAttr );
219  value=anAttr->Value();
220  DEBTRACE(value);
221  putIOR((const char*)value);
222  }
223  else
224  {
225  std::string error="Execution problem: no AttributeComment in study object: ";
226  throw Exception(error+data);
227  }
228  }
229 }
TypeCode * edGetType() const
Definition: DataPort.hxx:53
virtual void putIOR(const std::string &ior)
Definition: StudyPorts.cxx:84
virtual void put(const void *data)
Definition: XMLPorts.cxx:137

References DEBTRACE, YACS::ENGINE::Double, YACS::ENGINE::DataPort::edGetType(), getData(), YACS::ENGINE::Int, testCppPluginInvokation::l, YACS::ENGINE::Objref, YACS::ENGINE::OutputXmlPort::put(), and putIOR().

Referenced by YACS::ENGINE::StudyInNode::execute().

◆ getPyObj()

std::string YACS::ENGINE::OutputStudyPort::getPyObj ( )
virtual

Definition at line 130 of file StudyPorts.cxx.

131 {
132  return getData();
133 }

References getData().

◆ putIOR()

void YACS::ENGINE::OutputStudyPort::putIOR ( const std::string &  ior)
virtual

Definition at line 84 of file StudyPorts.cxx.

85 {
86  DEBTRACE("OutputStudyPort::putIOR " << ior);
87  if(ior.substr(0,7) == "<value>")
88  {
89  put(ior.c_str());
90  }
91  else
92  {
93  int tk=edGetType()->kind();
94  std::string value;
95  switch(tk)
96  {
97  case Double:
98  value="<value><double>"+ior+"</double></value>";
99  break;
100  case Int:
101  value="<value><int>"+ior+"</int></value>";
102  break;
103  case String:
104  value="<value><string>"+ior+"</string></value>";
105  break;
106  case Bool:
107  value="<value><boolean>"+ior+"</boolean></value>";
108  break;
109  case Objref:
110  value="<value><objref>"+ior+"</objref></value>";
111  break;
112  case Sequence:
113  case Array:
114  case Struct:
115  default:
116  break;
117  }
118  put(value.c_str());
119  }
120 }
DynType kind() const
Definition: TypeCode.cxx:47

References YACS::ENGINE::Array, YACS::ENGINE::Bool, DEBTRACE, YACS::ENGINE::Double, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::Int, YACS::ENGINE::TypeCode::kind(), YACS::ENGINE::Objref, YACS::ENGINE::OutputXmlPort::put(), YACS::ENGINE::Sequence, YACS::ENGINE::String, and YACS::ENGINE::Struct.

Referenced by getDataFromStudy().

◆ setData()

void YACS::ENGINE::OutputStudyPort::setData ( const std::string &  data)

Definition at line 71 of file StudyPorts.cxx.

72 {
73  _storeData = data;
74  DEBTRACE( "OutputStudyPort::setData " << _storeData );
75  modified();
76 }
void modified()
Definition: Port.cxx:53

References _storeData, DEBTRACE, and YACS::ENGINE::Port::modified().

Referenced by YACS::ENGINE::StudyInNode::setData().

◆ typeName()

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

Reimplemented from YACS::ENGINE::OutputPort.

Definition at line 44 of file StudyPorts.hxx.

44 {return "YACS__ENGINE__OutputStudyPort";}

Member Data Documentation

◆ _storeData

std::string YACS::ENGINE::OutputStudyPort::_storeData
protected

Definition at line 47 of file StudyPorts.hxx.

Referenced by dump(), getData(), and setData().


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