Version: 8.3.0
YACS::ENGINE::ElementaryNode Class Reference

Base class for all calculation nodes. More...

#include <ElementaryNode.hxx>

Inheritance diagram for YACS::ENGINE::ElementaryNode:
Collaboration diagram for YACS::ENGINE::ElementaryNode:

Public Member Functions

virtual ~ElementaryNode ()
 
void exUpdateState ()
 Update the node state. More...
 
void init (bool start=true)
 
bool isDeployable () const
 
ComponentInstancegetComponent ()
 
const ComponentInstancegetComponent () const
 
ContainergetContainer ()
 
YACS::StatesForNode getState () const
 
void getReadyTasks (std::vector< Task * > &tasks)
 
void edRemovePort (Port *port) throw (Exception)
 
std::list< ElementaryNode * > getRecursiveConstituents () const
 
std::list< ProgressWeightgetProgressWeight () const
 Get the progress weight for all elementary nodes. More...
 
NodegetChildByName (const std::string &name) const throw (Exception)
 
virtual void checkBasicConsistency () const throw (Exception)
 
ComposedNodegetDynClonerIfExists (const ComposedNode *levelToStop) const
 
int getNumberOfInputPorts () const
 
int getNumberOfOutputPorts () const
 
std::string getInPortName (const InPort *) const throw (Exception)
 
std::string getOutPortName (const OutPort *) const throw (Exception)
 
InputPortgetInputPort (const std::string &name) const throw (Exception)
 
OutputPortgetOutputPort (const std::string &name) const throw (Exception)
 
std::list< InputPort * > getSetOfInputPort () const
 
std::list< OutputPort * > getSetOfOutputPort () const
 
std::list< InputPort * > getLocalInputPorts () const
 
std::list< OutputPort * > getLocalOutputPorts () const
 
std::set< OutPort * > getAllOutPortsLeavingCurrentScope () const
 
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope () const
 
virtual std::vector< std::pair
< OutPort *, InPort * > > 
getSetOfLinksLeavingCurrentScope () const
 
virtual std::vector< std::pair
< InPort *, OutPort * > > 
getSetOfLinksComingInCurrentScope () const
 
std::list< InputDataStreamPort * > getSetOfInputDataStreamPort () const
 
std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort () const
 
InputDataStreamPortgetInputDataStreamPort (const std::string &name) const throw (Exception)
 
OutputDataStreamPortgetOutputDataStreamPort (const std::string &name) const throw (Exception)
 
virtual InputPortcreateInputPort (const std::string &inputPortName, TypeCode *type)
 
virtual OutputPortcreateOutputPort (const std::string &outputPortName, TypeCode *type)
 
virtual InputDataStreamPortcreateInputDataStreamPort (const std::string &inputPortDSName, TypeCode *type)
 
virtual OutputDataStreamPortcreateOutputDataStreamPort (const std::string &outputPortDSName, TypeCode *type)
 
virtual InputPortedAddInputPort (const std::string &inputPortName, TypeCode *type) throw (Exception)
 
virtual OutputPortedAddOutputPort (const std::string &outputPortName, TypeCode *type) throw (Exception)
 
virtual InputDataStreamPortedAddInputDataStreamPort (const std::string &inputPortDSName, TypeCode *type) throw (Exception)
 
virtual OutputDataStreamPortedAddOutputDataStreamPort (const std::string &outputPortDSName, TypeCode *type) throw (Exception)
 
virtual void edOrderInputPorts (const std::list< InputPort * > &ports)
 
virtual void edOrderOutputPorts (const std::list< OutputPort * > &ports)
 
virtual std::string typeName ()
 
virtual void edUpdateState ()
 update the status of the node More...
 
virtual void ensureLoading ()
 Put this node into TOLOAD state when possible. More...
 
int getMaxLevelOfParallelism () const
 
void begin ()
 
bool isReady ()
 
void finished ()
 
void aborted ()
 
void loaded ()
 Notify this node that it is loaded. More...
 
void connected ()
 Notify this node that it is connected. More...
 
virtual std::string getErrorDetails ()
 Give a description of error when node status is ERROR. More...
 
virtual void initService ()
 
virtual void connectService ()
 
virtual void disconnectService ()
 
virtual void load ()
 
virtual void getCoupledTasks (std::set< Task * > &coupledSet)
 Calls getCoupledNodes for Task interface. More...
 
virtual void getCoupledNodes (std::set< Task * > &coupledSet)
 Put all nodes that are coupled to this node in coupledSet. More...
 
void accept (Visitor *visitor)
 
virtual void addDatastreamPortToInitMultiService (const std::string &port_name, int number)
 
template<class PORT >
void edRemovePortTypedFromSet (PORT *port, std::list< PORT * > &setOfPorts) throw (Exception)
 
template<class PORT >
bool isPortNameAlreadyExist (const std::string &portName, const std::list< PORT * > &setOfPorts)
 
- Public Member Functions inherited from YACS::ENGINE::Node
virtual ~Node ()
 
virtual void shutdown (int level)
 Stop all pending activities of the node. More...
 
virtual void resetState (int level)
 Reset the node state depending on the parameter level. More...
 
Nodeclone (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
NodecloneWithoutCompAndContDeepCpy (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
void setState (YACS::StatesForNode theState)
 Sets the given state for node. More...
 
virtual YACS::StatesForNode getEffectiveState () const
 Return the node state in the context of its father. More...
 
virtual YACS::StatesForNode getEffectiveState (const Node *) const
 Return the effective state of a node in the context of this one (its father) More...
 
std::string getColorState (YACS::StatesForNode state) const
 Return the color associated to a state. More...
 
InGategetInGate ()
 
OutGategetOutGate ()
 
const std::string & getName () const
 
void setName (const std::string &name)
 Change the name of the node. More...
 
ComposedNodegetFather () const
 
const std::string getId () const
 
bool exIsControlReady () const
 
std::list< Node * > getOutNodes () const
 
virtual void writeDot (std::ostream &os) const
 Dump to the input stream a dot representation of the node. More...
 
virtual void exFailedState ()
 Notify this node that its execution has failed. More...
 
virtual void exDisabledState ()
 Notify this node that it has been disabled. More...
 
std::list< InPort * > getSetOfInPort () const
 
std::list< OutPort * > getSetOfOutPort () const
 
virtual std::set< InputPort * > edGetSetOfUnitializedInputPort () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
virtual bool edAreAllInputPortInitialized () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
InPortgetInPort (const std::string &name) const throw (Exception)
 
InPropertyPortgetInPropertyPort () const throw (Exception)
 
virtual OutPortgetOutPort (const std::string &name) const throw (Exception)
 
std::list< ComposedNode * > getAllAscendanceOf (ComposedNode *levelToStop=0) const
 
bool operator> (const Node &other) const
 
bool operator< (const Node &other) const
 
std::string getImplementation () const
 
virtual ComposedNodegetRootNode () const throw (Exception)
 
virtual void setProperty (const std::string &name, const std::string &value)
 
virtual std::string getProperty (const std::string &name)
 
std::map< std::string,
std::string > 
getProperties ()
 
std::map< std::string,
std::string > 
getPropertyMap ()
 
virtual void setProperties (std::map< std::string, std::string > properties)
 
virtual ProcgetProc ()
 
virtual const ProcgetProc () const
 
std::string getQualifiedName () const
 same as Node::getName() in most cases, but differs for children of switch More...
 
int getNumId ()
 return node instance identifiant, unique for each node instance More...
 
std::vector< std::pair
< std::string, int > > 
getDPLScopeInfo (ComposedNode *gfn)
 
virtual void applyDPLScope (ComposedNode *gfn)
 
virtual void sendEvent (const std::string &event)
 emit notification to all observers registered with the dispatcher More...
 
virtual void sendEvent2 (const std::string &event, void *something)
 emit notification to all observers registered with the dispatcher More...
 
virtual std::string getErrorDetails () const
 
virtual void setErrorDetails (const std::string &error)
 
virtual void modified ()
 Sets Node in modified state and its father if it exists. More...
 
virtual int isModified ()
 
virtual int isValid ()
 indicates if the node is valid (returns 1) or not (returns 0) More...
 
virtual std::string getErrorReport ()
 returns a string that contains an error report if the node is in error More...
 
virtual std::string getContainerLog ()
 returns a string that contains the name of the container log file if it exists More...
 
virtual void cleanNodes ()
 Clean the node in case of not clean exit. More...
 
- Public Member Functions inherited from YACS::ENGINE::Task
virtual void execute ()=0
 
virtual ~Task ()
 

Protected Member Functions

 ElementaryNode (const std::string &name)
 
 ElementaryNode (const ElementaryNode &other, ComposedNode *father)
 
void performDuplicationOfPlacement (const Node &other)
 performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute. More...
 
void performShallowDuplicationOfPlacement (const Node &other)
 performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning. More...
 
void initCommonPartWithoutStateManagement (bool start)
 
virtual void createMultiDatastreamPorts ()
 
void edDisconnectAllLinksWithMe ()
 
bool areAllInputPortsValid () const
 
template<class PORT >
PORT * getPort (const std::string &name, const std::list< PORT * > &setOfPorts) const throw (Exception)
 
template<class PORT , class ENUMTYPE >
PORT * edAddPort (const std::string &portName, std::list< PORT * > &setOfPorts, ENUMTYPE type) throw (Exception)
 
template<class PORT , class ENUMTYPE >
bool edCheckAddPort (const std::string &portName, std::list< PORT * > &setOfPorts, ENUMTYPE type) throw (Exception)
 
- Protected Member Functions inherited from YACS::ENGINE::Node
 Node (const std::string &name)
 
 Node (const Node &other, ComposedNode *father)
 
virtual NodesimpleClone (ComposedNode *father, bool editionOnly=true) const =0
 
virtual void exForwardFailed ()
 
virtual void exForwardFinished ()
 

Static Protected Member Functions

template<class PORT >
static void edRemovePortTypedFromSet (PORT *port, std::list< PORT * > &setOfPorts) throw (Exception)
 
template<class PORT >
static bool isPortNameAlreadyExist (const std::string &portName, const std::list< PORT * > &setOfPorts)
 
- Static Protected Member Functions inherited from YACS::ENGINE::Node
static void checkValidityOfPortName (const std::string &name) throw (Exception)
 
static ComposedNodecheckHavingCommonFather (Node *node1, Node *node2) throw (Exception)
 

Protected Attributes

std::list< InputPort * > _setOfInputPort
 
std::list< OutputPort * > _setOfOutputPort
 
std::list< InputDataStreamPort * > _setOfInputDataStreamPort
 
std::list< OutputDataStreamPort * > _setOfOutputDataStreamPort
 
bool _createDatastreamPorts
 
bool _multi_port_node
 
- Protected Attributes inherited from YACS::ENGINE::Node
InGate _inGate
 
OutGate _outGate
 
InPropertyPort_inPropertyPort
 
std::string _name
 
ComposedNode_father
 
YACS::StatesForNode _state
 
int _modified
 
std::string _errorDetails
 
int _numId
 
std::string _implementation
 
std::map< std::string,
std::string > 
_propertyMap
 

Friends

class ComposedNode
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::ENGINE::Node
static std::string getStateName (YACS::StatesForNode state)
 Return the name of a state. More...
 
- Public Attributes inherited from YACS::ENGINE::Node
YACS::Colour _colour
 
- Static Public Attributes inherited from YACS::ENGINE::Node
static std::map< int, Node * > idMap
 
- Static Protected Attributes inherited from YACS::ENGINE::Node
static const char SEP_CHAR_IN_PORT [] ="."
 
static int _total = 0
 

Detailed Description

Base class for all calculation nodes.

This is an abstract class that must be specialized.

Definition at line 43 of file ElementaryNode.hxx.

Constructor & Destructor Documentation

ElementaryNode::ElementaryNode ( const std::string &  name)
protected

Definition at line 47 of file ElementaryNode.cxx.

48  :
49  Node(name),
51  _multi_port_node(false)
52 {
}
ElementaryNode::ElementaryNode ( const ElementaryNode other,
ComposedNode father 
)
protected

Definition at line 54 of file ElementaryNode.cxx.

References _createDatastreamPorts, _multi_port_node, _setOfInputDataStreamPort, _setOfInputPort, _setOfOutputDataStreamPort, and _setOfOutputPort.

54  :Node(other,father)
55 {
58  for(list<InputPort *>::const_iterator iter1=other._setOfInputPort.begin();iter1!=other._setOfInputPort.end();iter1++)
59  _setOfInputPort.push_back((InputPort *)(*iter1)->clone(this));
60  for(list<OutputPort *>::const_iterator iter2=other._setOfOutputPort.begin();iter2!=other._setOfOutputPort.end();iter2++)
61  _setOfOutputPort.push_back((OutputPort *)(*iter2)->clone(this));
62  for(list<InputDataStreamPort *>::const_iterator iter3=other._setOfInputDataStreamPort.begin();iter3!=other._setOfInputDataStreamPort.end();iter3++)
63  _setOfInputDataStreamPort.push_back((InputDataStreamPort *)(*iter3)->clone(this));
64  for(list<OutputDataStreamPort *>::const_iterator iter4=other._setOfOutputDataStreamPort.begin();iter4!=other._setOfOutputDataStreamPort.end();iter4++)
65  _setOfOutputDataStreamPort.push_back((OutputDataStreamPort *)(*iter4)->clone(this));
66 }
ElementaryNode::~ElementaryNode ( )
virtual

Definition at line 76 of file ElementaryNode.cxx.

References _setOfInputDataStreamPort, _setOfInputPort, _setOfOutputDataStreamPort, and _setOfOutputPort.

77 {
78  for(list<InputPort *>::iterator iter1=_setOfInputPort.begin();iter1!=_setOfInputPort.end();iter1++)
79  delete *iter1;
80  for(list<OutputPort *>::iterator iter2=_setOfOutputPort.begin();iter2!=_setOfOutputPort.end();iter2++)
81  delete *iter2;
82  for(list<InputDataStreamPort *>::iterator iter3=_setOfInputDataStreamPort.begin();iter3!=_setOfInputDataStreamPort.end();iter3++)
83  delete *iter3;
84  for(list<OutputDataStreamPort *>::iterator iter4=_setOfOutputDataStreamPort.begin();iter4!=_setOfOutputDataStreamPort.end();iter4++)
85  delete *iter4;
86 }

Member Function Documentation

void ElementaryNode::aborted ( )
virtual
void ElementaryNode::accept ( Visitor visitor)
virtual
virtual void YACS::ENGINE::ElementaryNode::addDatastreamPortToInitMultiService ( const std::string &  port_name,
int  number 
)
inlinevirtual

Definition at line 129 of file ElementaryNode.hxx.

Referenced by createMultiDatastreamPorts().

130  {}
bool ElementaryNode::areAllInputPortsValid ( ) const
protected

checks if all input ports contains a valid data. Used at execution to change the state of the node for activation.

Definition at line 272 of file ElementaryNode.cxx.

References _setOfInputPort, and PMMLBasicsTestLauncher::ret.

Referenced by connected(), and exUpdateState().

273 {
274  bool ret=true;
275  for(list<InputPort *>::const_iterator iter=_setOfInputPort.begin();iter!=_setOfInputPort.end();iter++)
276  {
277  ret=!(*iter)->isEmpty();
278  if (!ret) break;
279  }
280  return ret;
281 }
void ElementaryNode::begin ( )
virtual

Implements YACS::ENGINE::Task.

Definition at line 747 of file ElementaryNode.cxx.

References YACS::ACTIVATED, and YACS::ENGINE::Node::setState().

Referenced by YACS::HMI::SubjectNode::registerUndoDestroy().

748 {
750 }
void ElementaryNode::checkBasicConsistency ( ) const throw (Exception)
virtual

Reimplemented in YACS::ENGINE::PyFuncNode, YACS::ENGINE::InlineFuncNode, YACS::ENGINE::PythonNode, YACS::ENGINE::StudyOutNode, YACS::ENGINE::PresetNode, YACS::ENGINE::StudyInNode, and YACS::ENGINE::OutNode.

Definition at line 575 of file ElementaryNode.cxx.

References _setOfInputPort, and DEBTRACE.

Referenced by YACS::ENGINE::PythonNode::checkBasicConsistency(), YACS::ENGINE::InlineFuncNode::checkBasicConsistency(), and edUpdateState().

576 {
577  DEBTRACE("ElementaryNode::checkBasicConsistency");
578  list<InputPort *>::const_iterator iter;
579  for(iter=_setOfInputPort.begin();iter!=_setOfInputPort.end();iter++)
580  (*iter)->checkBasicConsistency();
581 }
void ElementaryNode::connected ( )
virtual

Notify this node that it is connected.

When an elementary node has been connected it goes to TOACTIVATE state It is then ready to be executed

Implements YACS::ENGINE::Task.

Definition at line 782 of file ElementaryNode.cxx.

References YACS::ENGINE::Node::_inGate, areAllInputPortsValid(), YACS::ENGINE::InGate::exIsReady(), YACS::LOADED, YACS::ENGINE::Node::setState(), and YACS::TOACTIVATE.

783 {
784  if(_inGate.exIsReady())
786  {
788  return;
789  }
790  setState(LOADED);
791 }
virtual void YACS::ENGINE::ElementaryNode::connectService ( )
inlinevirtual

Implements YACS::ENGINE::Task.

Definition at line 120 of file ElementaryNode.hxx.

120 { }
InputDataStreamPort * ElementaryNode::createInputDataStreamPort ( const std::string &  inputPortDSName,
TypeCode type 
)
virtual

Definition at line 687 of file ElementaryNode.cxx.

References YACS::ENGINE::Runtime::createInputDataStreamPort(), and YACS::ENGINE::getRuntime().

688 {
689  return getRuntime()->createInputDataStreamPort(inputPortDSName, this, type);
690 }
InputPort * ElementaryNode::createInputPort ( const std::string &  inputPortName,
TypeCode type 
)
virtual
void ElementaryNode::createMultiDatastreamPorts ( )
protectedvirtual

Definition at line 288 of file ElementaryNode.cxx.

References _createDatastreamPorts, _multi_port_node, YACS::ENGINE::Node::_propertyMap, _setOfInputDataStreamPort, _setOfOutputDataStreamPort, addDatastreamPortToInitMultiService(), YACS::ENGINE::InputDataStreamPort::clone(), YACS::ENGINE::OutputDataStreamPort::clone(), YACS::ENGINE::DataPort::getName(), CORBAEngineTest::i, and YACS::ENGINE::DataPort::setName().

Referenced by getReadyTasks().

289 {
291  {
292  _createDatastreamPorts = true;
293  for(list<InputDataStreamPort *>::const_iterator iter3 = _setOfInputDataStreamPort.begin(); iter3!=_setOfInputDataStreamPort.end();iter3++)
294  {
295  InputDataStreamPort * port = *iter3;
296  std::string port_name = port->getName();
297  std::map<std::string,std::string>::iterator it=_propertyMap.find(port_name);
298  int multi = 1;
299  if(it != _propertyMap.end())
300  {
301  std::string multi_str = it->second;
302  std::istringstream iss(multi_str);
303  if (!(iss >> multi))
304  throw Exception("Property multi port should be set with a stringified int not an: " + multi_str);
305  }
306 
307  if (multi > 1)
308  {
309  addDatastreamPortToInitMultiService(port_name, multi);
310  // Change name of first port
311  port->setName(port_name + "_0");
312  for (int i = 2; i <= multi; i++)
313  {
314  InputDataStreamPort * new_port = port->clone(this);
315  std::ostringstream number;
316  number << i-1;
317  new_port->setName(port_name + "_" + number.str());
318  _setOfInputDataStreamPort.push_back(new_port);
319  _multi_port_node = true;
320  }
321  }
322  }
323  for(list<OutputDataStreamPort *>::const_iterator iter4 = _setOfOutputDataStreamPort.begin(); iter4!=_setOfOutputDataStreamPort.end();iter4++)
324  {
325  OutputDataStreamPort * port = *iter4;
326  std::string port_name = port->getName();
327  std::map<std::string,std::string>::iterator it=_propertyMap.find(port_name);
328  int multi = 1;
329  if(it != _propertyMap.end())
330  {
331  std::string multi_str = it->second;
332  std::istringstream iss(multi_str);
333  if (!(iss >> multi))
334  throw Exception("Property multi port should be set with a stringified int not an: " + multi_str);
335  }
336 
337  if (multi > 1)
338  {
339  addDatastreamPortToInitMultiService(port_name, multi);
340  // Change name of first port
341  port->setName(port_name + "_0");
342  for (int i = 2; i <= multi; i++)
343  {
344  OutputDataStreamPort * new_port = port->clone(this);
345  std::ostringstream number;
346  number << i-1;
347  new_port->setName(port_name + "_" + number.str());
348  _setOfOutputDataStreamPort.push_back(new_port);
349  _multi_port_node = true;
350  }
351  }
352  }
353  }
354 }
OutputDataStreamPort * ElementaryNode::createOutputDataStreamPort ( const std::string &  outputPortDSName,
TypeCode type 
)
virtual

Definition at line 704 of file ElementaryNode.cxx.

References YACS::ENGINE::Runtime::createOutputDataStreamPort(), and YACS::ENGINE::getRuntime().

705 {
706  return getRuntime()->createOutputDataStreamPort(outputPortDSName, this, type);
707 }
OutputPort * ElementaryNode::createOutputPort ( const std::string &  outputPortName,
TypeCode type 
)
virtual
virtual void YACS::ENGINE::ElementaryNode::disconnectService ( )
inlinevirtual

Implements YACS::ENGINE::Task.

Definition at line 121 of file ElementaryNode.hxx.

121 { }
InputDataStreamPort * ElementaryNode::edAddInputDataStreamPort ( const std::string &  inputPortDSName,
TypeCode type 
) throw (Exception)
virtual

Definition at line 692 of file ElementaryNode.cxx.

References PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::SessionCataLoader::importComponent(), and YACS::HMI::CommandAddIDSPortFromCatalog::localExecute().

693 {
695  if (edCheckAddPort<InputDataStreamPort, TypeCode*>(inputPortDSName,_setOfInputDataStreamPort,type))
696  {
697  ret = createInputDataStreamPort(inputPortDSName, type);
698  _setOfInputDataStreamPort.push_back(ret);
699  modified();
700  }
701  return ret;
702 }
InputPort * ElementaryNode::edAddInputPort ( const std::string &  inputPortName,
TypeCode type 
) throw (Exception)
virtual

the input port is also published recursively in ancestors because it may be visible from everywhere. WARNING: CHECK CASE OF BLOC: ONLY INPUT PORTS NOT INTERNALLY CONNECTED MUST BE VISIBLE.

Definition at line 601 of file ElementaryNode.cxx.

References PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::SalomePythonNode::cloneNode(), YACS::ENGINE::CppNode::cloneNode(), YACS::ENGINE::PythonNode::cloneNode(), YACS::ENGINE::PyFuncNode::cloneNode(), YACS::ENGINE::SessionCataLoader::importComponent(), and YACS::HMI::CommandAddInputPortFromCatalog::localExecute().

602 {
603 
604  // Cannot create an InputPort defined with InPropertyPort name.
605  if (inputPortName == "__InPropertyPort__Node__YACS_")
606  {
607  string what("ElementaryNode::edAddInputPort: it is forbidden to add an InputPort with the name __InPropertyPort__Node__YACS_\"");
608  throw Exception(what);
609  }
610 
611  InputPort *ret = 0;
612  if (edCheckAddPort<InputPort, TypeCode*>(inputPortName,_setOfInputPort,type))
613  {
614  ret = createInputPort(inputPortName, type);
615  _setOfInputPort.push_back(ret);
616  modified();
617  /*
618  ComposedNode *iter=_father;
619  while(iter)
620  iter=iter->_father;
621  */
622  }
623  return ret;
624 }
OutputDataStreamPort * ElementaryNode::edAddOutputDataStreamPort ( const std::string &  outputPortDSName,
TypeCode type 
) throw (Exception)
virtual

Definition at line 709 of file ElementaryNode.cxx.

References PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::SessionCataLoader::importComponent(), and YACS::HMI::CommandAddODSPortFromCatalog::localExecute().

710 {
712  if (edCheckAddPort<OutputDataStreamPort, TypeCode*>(outputPortDSName,_setOfOutputDataStreamPort,type))
713  {
714  ret = createOutputDataStreamPort(outputPortDSName, type);
715  _setOfOutputDataStreamPort.push_back(ret);
716  modified();
717  }
718  return ret;
719 }
OutputPort * ElementaryNode::edAddOutputPort ( const std::string &  outputPortName,
TypeCode type 
) throw (Exception)
virtual

TO SOLVE : The output port is not published in father. Father must create an output port. for now, publication is done the same way as input ports

Definition at line 670 of file ElementaryNode.cxx.

References PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::SalomePythonNode::cloneNode(), YACS::ENGINE::CppNode::cloneNode(), YACS::ENGINE::PythonNode::cloneNode(), YACS::ENGINE::PyFuncNode::cloneNode(), YACS::ENGINE::SessionCataLoader::importComponent(), and YACS::HMI::CommandAddOutputPortFromCatalog::localExecute().

671 {
672  OutputPort *ret =0;
673  if (edCheckAddPort<OutputPort, TypeCode*>(outputPortName,_setOfOutputPort,type))
674  {
675  ret = createOutputPort(outputPortName, type);
676  _setOfOutputPort.push_back(ret);
677  modified();
678  /*
679  ComposedNode *iter=_father;
680  while(iter)
681  iter=iter->_father;
682  */
683  }
684  return ret;
685 }
template<class PORT , class ENUMTYPE >
PORT * YACS::ENGINE::ElementaryNode::edAddPort ( const std::string &  portName,
std::list< PORT * > &  setOfPorts,
ENUMTYPE  type 
) throw (Exception)
protected

protected: add a port given it's name and type, in a given list of ports WHY TEMPLATE PARAMETER ENUMTYPE?

Definition at line 174 of file ElementaryNode.hxx.

References PMMLBasicsTestLauncher::ret.

175  {
176  checkValidityOfPortName(portName);
177  if(isPortNameAlreadyExist<PORT>(portName, setOfPorts))
178  {
179  std::string what="Port of type "; what+=PORT::NAME; what += " with name : "; what+=portName; what+=" already exists";
180  throw Exception(what);
181  }
182  PORT *ret=new PORT(portName,this,type);
183  setOfPorts.push_back(ret);
184  return ret;
185  }
template<class PORT , class ENUMTYPE >
bool YACS::ENGINE::ElementaryNode::edCheckAddPort ( const std::string &  portName,
std::list< PORT * > &  setOfPorts,
ENUMTYPE  type 
) throw (Exception)
protected

Definition at line 188 of file ElementaryNode.hxx.

189  {
190  checkValidityOfPortName(portName);
191  if(isPortNameAlreadyExist<PORT>(portName, setOfPorts))
192  {
193  std::string what="Port of type "; what+=PORT::NAME; what += " with name : "; what+=portName; what+=" already exists";
194  throw Exception(what);
195  }
196  return true;
197  }
void ElementaryNode::edDisconnectAllLinksWithMe ( )
protectedvirtual

Called typically by ComposedNode to correctly update DF/CF/DS links

Reimplemented from YACS::ENGINE::Node.

Definition at line 247 of file ElementaryNode.cxx.

References _setOfInputDataStreamPort, _setOfInputPort, _setOfOutputDataStreamPort, _setOfOutputPort, and YACS::ENGINE::Node::edDisconnectAllLinksWithMe().

Referenced by YACS::ENGINE::DFToDSForLoop::~DFToDSForLoop(), and YACS::ENGINE::DSToDFForLoop::~DSToDFForLoop().

248 {
249  //CF
251  //Leaving part
252  // - DF
253  for(list<InputPort *>::iterator iter=_setOfInputPort.begin();iter!=_setOfInputPort.end();iter++)
254  (*iter)->edRemoveAllLinksLinkedWithMe();
255  // - DS
256  for(list<InputDataStreamPort *>::iterator iter2=_setOfInputDataStreamPort.begin();iter2!=_setOfInputDataStreamPort.end();iter2++)
257  (*iter2)->edRemoveAllLinksLinkedWithMe();
258  //Arriving part
259  // - DF
260  for(list<OutputPort *>::iterator iter=_setOfOutputPort.begin();iter!=_setOfOutputPort.end();iter++)
261  (*iter)->edRemoveAllLinksLinkedWithMe();
262  // - DS
263  for(list<OutputDataStreamPort *>::iterator iter2=_setOfOutputDataStreamPort.begin();iter2!=_setOfOutputDataStreamPort.end();iter2++)
264  (*iter2)->edRemoveAllLinksLinkedWithMe();
265 }
void ElementaryNode::edOrderInputPorts ( const std::list< InputPort * > &  ports)
virtual

Definition at line 626 of file ElementaryNode.cxx.

References _setOfInputPort.

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

627 {
628  std::set<InputPort *> s1;
629  std::set<InputPort *> s2;
630  for(list<InputPort *>::const_iterator it=_setOfInputPort.begin();it != _setOfInputPort.end();it++)
631  s1.insert(*it);
632  for(list<InputPort *>::const_iterator it=ports.begin();it != ports.end();it++)
633  s2.insert(*it);
634 
635  if(s1 != s2)
636  throw Exception("ElementaryNode::edOrderInputPorts : port list must contain same ports as existing ones");
637 
638  _setOfInputPort.clear();
639  for(list<InputPort *>::const_iterator it=ports.begin();it != ports.end();it++)
640  _setOfInputPort.push_back(*it);
641 }
void ElementaryNode::edOrderOutputPorts ( const std::list< OutputPort * > &  ports)
virtual

Definition at line 643 of file ElementaryNode.cxx.

References _setOfOutputPort.

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

644 {
645  std::set<OutputPort *> s1;
646  std::set<OutputPort *> s2;
647  for(list<OutputPort *>::const_iterator it=_setOfOutputPort.begin();it != _setOfOutputPort.end();it++)
648  s1.insert(*it);
649  for(list<OutputPort *>::const_iterator it=ports.begin();it != ports.end();it++)
650  s2.insert(*it);
651 
652  if(s1 != s2)
653  throw Exception("ElementaryNode::edOrderOutputPorts : port list must contain same ports as existing ones");
654 
655  _setOfOutputPort.clear();
656  for(list<OutputPort *>::const_iterator it=ports.begin();it != ports.end();it++)
657  _setOfOutputPort.push_back(*it);
658 }
void ElementaryNode::edRemovePort ( Port port) throw (Exception)

remove port from node at edition. Ports are typed.

Definition at line 521 of file ElementaryNode.cxx.

References DEBTRACE, and p.

Referenced by YACS::HMI::SubjectDataPort::~SubjectDataPort().

522 {
523  DEBTRACE("ElementaryNode::edRemovePort ");
524  if(port->getNode()!=this)
525  throw Exception("ElementaryNode::edRemovePort : Port is not held by this node");
526  if(InputPort *p=dynamic_cast<InputPort *>(port))
527  edRemovePortTypedFromSet<InputPort>(p,_setOfInputPort);
528  else if(OutputPort *p=dynamic_cast<OutputPort *>(port))
529  edRemovePortTypedFromSet<OutputPort>(p,_setOfOutputPort);
530  else if(InputDataStreamPort *p=dynamic_cast<InputDataStreamPort *>(port))
531  edRemovePortTypedFromSet<InputDataStreamPort>(p,_setOfInputDataStreamPort);
532  else if(OutputDataStreamPort *p=dynamic_cast<OutputDataStreamPort *>(port))
533  edRemovePortTypedFromSet<OutputDataStreamPort>(p,_setOfOutputDataStreamPort);
534  else
535  throw Exception("ElementaryNode::edRemovePort : unknown port type");
536  delete port;
537  modified();
538 }
template<class PORT >
static void YACS::ENGINE::ElementaryNode::edRemovePortTypedFromSet ( PORT *  port,
std::list< PORT * > &  setOfPorts 
) throw (Exception)
staticprotected
template<class PORT >
void YACS::ENGINE::ElementaryNode::edRemovePortTypedFromSet ( PORT *  port,
std::list< PORT * > &  setOfPorts 
) throw (Exception)

protected: remove a port from a given list

Definition at line 204 of file ElementaryNode.hxx.

205  {
206  if(!isPortNameAlreadyExist<PORT>(port->getName(), setOfPorts))
207  throw Exception("Port is not part of the list : unable to remove it");
208  typename std::list<PORT *>::iterator iter=std::find(setOfPorts.begin(),setOfPorts.end(),port);
209  if(iter!=setOfPorts.end())
210  {
211  (*iter)->edRemoveAllLinksLinkedWithMe();
212  setOfPorts.erase(iter);
213  }
214  }
void ElementaryNode::edUpdateState ( )
virtual

update the status of the node

Only useful when editing a schema Do nothing in base Node : to implement in derived classes

Reimplemented from YACS::ENGINE::Node.

Definition at line 807 of file ElementaryNode.cxx.

References YACS::ENGINE::Node::_errorDetails, YACS::ENGINE::Node::_modified, YACS::ENGINE::Node::_state, checkBasicConsistency(), DEBTRACE, YACS::ENGINE::Node::getName(), YACS::INVALID, YACS::READY, YACS::ENGINE::Node::setState(), CORBAEngineTest::state, and YACS::Exception::what().

808 {
809  DEBTRACE("ElementaryNode::edUpdateState: " << getName());
811  try
812  {
814  _errorDetails="";
815  }
816  catch(Exception& e)
817  {
818  state=YACS::INVALID;
819  _errorDetails=e.what();
820  }
821  DEBTRACE("ElementaryNode::edUpdateState: " << _errorDetails);
822  if(state != _state)
823  setState(state);
824  _modified=0;
825 }
void ElementaryNode::ensureLoading ( )
virtual

Put this node into TOLOAD state when possible.

Can be called by another ElementaryNode that is connected to this one by a datastream link These 2 nodes must be loaded at the same time as they are coupled It's the other node which requests this node loading

Reimplemented from YACS::ENGINE::Node.

Definition at line 833 of file ElementaryNode.cxx.

References _setOfInputDataStreamPort, _setOfOutputDataStreamPort, YACS::ENGINE::Node::_state, DEBTRACE, YACS::ENGINE::OutputDataStreamPort::edSetInPort(), YACS::ENGINE::InPort::edSetOutPort(), YACS::ENGINE::Node::ensureLoading(), YACS::ENGINE::Node::getName(), YACS::READY, YACS::ENGINE::Node::setState(), and YACS::TOLOAD.

Referenced by exUpdateState().

834 {
835  DEBTRACE("ElementaryNode::ensureLoading: " << getName());
836  if(_state != YACS::READY)
837  return;
839 
840  // request loading for all nodes connected to this one by datastream link
841  // Be careful that nodes can be connected in a loop. Put first this node in TOLOAD state to break the loop
842  std::list<OutputDataStreamPort *>::iterator iterout;
843  for(iterout = _setOfOutputDataStreamPort.begin(); iterout != _setOfOutputDataStreamPort.end(); iterout++)
844  {
845  OutputDataStreamPort *port=(OutputDataStreamPort *)*iterout;
846  std::set<InPort *> ports=port->edSetInPort();
847  std::set<InPort *>::iterator iter;
848  for(iter=ports.begin();iter != ports.end(); iter++)
849  {
850  Node* node= (*iter)->getNode();
851  node->ensureLoading();
852  }
853  }
854  std::list<InputDataStreamPort *>::iterator iterin;
855  for(iterin = _setOfInputDataStreamPort.begin(); iterin != _setOfInputDataStreamPort.end(); iterin++)
856  {
857  InputDataStreamPort *port=(InputDataStreamPort *)*iterin;
858  std::set<OutPort *> ports=port->edSetOutPort();
859  std::set<OutPort *>::iterator iter;
860  for(iter=ports.begin();iter != ports.end(); iter++)
861  {
862  Node* node= (*iter)->getNode();
863  node->ensureLoading();
864  }
865  }
866 }
void ElementaryNode::exUpdateState ( )
virtual

Update the node state.

Note
: Update the '_state' attribute. Typically called by 'this->_inGate' when 'this->_inGate' is ready.

Called by InGate::exNotifyFromPrecursor

Reimplemented from YACS::ENGINE::Node.

Definition at line 134 of file ElementaryNode.cxx.

References YACS::ENGINE::Node::_errorDetails, YACS::ENGINE::Node::_inGate, YACS::ENGINE::Node::_name, YACS::ENGINE::Node::_state, areAllInputPortsValid(), DEBTRACE, YACS::DISABLED, ensureLoading(), YACS::ENGINE::InGate::exIsReady(), YACS::ENGINE::Node::getName(), YACS::INTERNALERR, YACS::LOADED, YACS::READY, YACS::ENGINE::Node::setState(), and YACS::TOACTIVATE.

Referenced by getReadyTasks().

135 {
136  DEBTRACE("ElementaryNode::exUpdateState: " << getName() << " " << _state );
137  if(_state==YACS::DISABLED)return;
138  if(_inGate.exIsReady())
140  {
141  if(_state == YACS::READY)
142  ensureLoading();
143  else if(_state == YACS::LOADED)
145  }
146  else
147  {
148  string what("ElementaryNode::exUpdateState : Invalid graph given : Node with name \"");
149  what+=_name; what+="\" ready to run whereas some inputports are not set correctly\nCheck coherence DF/CF";
151  _errorDetails=what;
152  throw Exception(what);
153  }
154 }
void ElementaryNode::finished ( )
virtual
std::set< InPort * > ElementaryNode::getAllInPortsComingFromOutsideOfCurrentScope ( ) const
virtual

Implements YACS::ENGINE::Node.

Definition at line 193 of file ElementaryNode.cxx.

References YACS::ENGINE::Node::getSetOfInPort(), and PMMLBasicsTestLauncher::ret.

Referenced by getSetOfLinksComingInCurrentScope().

194 {
195  set<InPort *> ret;
196  list<InPort *> temp=getSetOfInPort();
197  for(list<InPort *>::iterator iter2=temp.begin();iter2!=temp.end();iter2++)
198  {
199  set<OutPort *> temp2=(*iter2)->edSetOutPort();
200  if(temp2.size()!=0)
201  ret.insert(*iter2);
202  }
203  return ret;
204 }
std::set< OutPort * > ElementaryNode::getAllOutPortsLeavingCurrentScope ( ) const
virtual

Implements YACS::ENGINE::Node.

Definition at line 180 of file ElementaryNode.cxx.

References YACS::ENGINE::Node::getSetOfOutPort(), and PMMLBasicsTestLauncher::ret.

Referenced by getSetOfLinksLeavingCurrentScope().

181 {
182  set<OutPort *> ret;
183  list<OutPort *> temp=getSetOfOutPort();
184  for(list<OutPort *>::iterator iter2=temp.begin();iter2!=temp.end();iter2++)
185  {
186  set<InPort *> temp2=(*iter2)->edSetInPort();
187  if(temp2.size()!=0)
188  ret.insert(*iter2);
189  }
190  return ret;
191 }
Node * ElementaryNode::getChildByName ( const std::string &  name) const throw (Exception)
virtual

Implements YACS::ENGINE::Node.

Definition at line 569 of file ElementaryNode.cxx.

570 {
571  string what("ElementaryNode does not agregate any nodes particullary node with name "); what+=name;
572  throw Exception(what);
573 }
ComponentInstance * ElementaryNode::getComponent ( )
virtual

Implements YACS::ENGINE::Task.

Reimplemented in YACS::ENGINE::ServiceNode.

Definition at line 114 of file ElementaryNode.cxx.

115 {
116  return 0;
117 }
const ComponentInstance * ElementaryNode::getComponent ( ) const
virtual

Implements YACS::ENGINE::Task.

Reimplemented in YACS::ENGINE::ServiceNode.

Definition at line 119 of file ElementaryNode.cxx.

120 {
121  return 0;
122 }
Container * ElementaryNode::getContainer ( )
virtual

Implements YACS::ENGINE::Task.

Reimplemented in YACS::ENGINE::InlineNode, and YACS::ENGINE::ServiceNode.

Definition at line 124 of file ElementaryNode.cxx.

Referenced by getReadyTasks().

125 {
126  return 0;
127 }
void ElementaryNode::getCoupledNodes ( std::set< Task * > &  coupledSet)
virtual

Put all nodes that are coupled to this node in coupledSet.

Reimplemented from YACS::ENGINE::Node.

Definition at line 875 of file ElementaryNode.cxx.

References _setOfOutputDataStreamPort, YACS::ENGINE::OutputDataStreamPort::edSetInPort(), and YACS::ENGINE::Node::getCoupledNodes().

Referenced by getCoupledTasks().

876 {
877  if(coupledSet.find(this) != coupledSet.end())return;
878 
879  coupledSet.insert(this);
880 
881  std::list<OutputDataStreamPort *>::iterator iterout;
882  for(iterout = _setOfOutputDataStreamPort.begin(); iterout != _setOfOutputDataStreamPort.end(); iterout++)
883  {
884  OutputDataStreamPort *port=(OutputDataStreamPort *)*iterout;
885  std::set<InPort *> ports=port->edSetInPort();
886  std::set<InPort *>::iterator iter;
887  for(iter=ports.begin();iter != ports.end(); iter++)
888  {
889  Node* node= (*iter)->getNode();
890  node->getCoupledNodes(coupledSet);
891  }
892  }
893 }
void ElementaryNode::getCoupledTasks ( std::set< Task * > &  coupledSet)
virtual

Calls getCoupledNodes for Task interface.

Implements YACS::ENGINE::Task.

Definition at line 869 of file ElementaryNode.cxx.

References getCoupledNodes().

870 {
871  getCoupledNodes(coupledSet);
872 }
ComposedNode * ElementaryNode::getDynClonerIfExists ( const ComposedNode levelToStop) const

Definition at line 583 of file ElementaryNode.cxx.

References YACS::ENGINE::Node::_father.

584 {
585  for(ComposedNode *iter=_father;iter!=levelToStop && iter!=0; iter=iter->_father)
586  if(!iter->isPlacementPredictableB4Run())
587  return iter;
588  return 0;
589 }
std::string ElementaryNode::getErrorDetails ( )
virtual

Give a description of error when node status is ERROR.

Definition at line 802 of file ElementaryNode.cxx.

References YACS::ENGINE::Node::_errorDetails.

Referenced by YACS::ENGINE::DistributedPythonNode::dealException(), and YACS::ENGINE::SalomeNode::execute().

803 {
804  return _errorDetails;
805 }
string ElementaryNode::getInPortName ( const InPort inPort) const throw (Exception)
virtual

get the input port name used by the current node (see composed nodes)

Implements YACS::ENGINE::Node.

Definition at line 725 of file ElementaryNode.cxx.

References YACS::ENGINE::Node::getName().

726 {
727  Node *node = inPort->getNode();
728  if ( node != this )
729  {
730  string what("InputPort "); what += inPort->getName(); what += " does not belong to node "; what += node->getName();
731  throw Exception(what);
732  }
733  return inPort->getName();
734 }
InputDataStreamPort * ElementaryNode::getInputDataStreamPort ( const std::string &  name) const throw (Exception)
virtual

Implements YACS::ENGINE::Node.

Reimplemented in YACS::ENGINE::DSToDFForLoop.

Definition at line 237 of file ElementaryNode.cxx.

Referenced by getReadyTasks(), and YACS::HMI::CommandAddIDSPortFromCatalog::localReverse().

238 {
239  return getPort<InputDataStreamPort>(name,_setOfInputDataStreamPort);
240 }
InputPort * ElementaryNode::getInputPort ( const std::string &  name) const throw (Exception)
virtual
std::list<InputPort *> YACS::ENGINE::ElementaryNode::getLocalInputPorts ( ) const
inlinevirtual

Implements YACS::ENGINE::Node.

Definition at line 84 of file ElementaryNode.hxx.

Referenced by YACS::HMI::SubjectElementaryNode::loadChildren().

84 { return _setOfInputPort; }
std::list<OutputPort *> YACS::ENGINE::ElementaryNode::getLocalOutputPorts ( ) const
inlinevirtual

Implements YACS::ENGINE::Node.

Definition at line 85 of file ElementaryNode.hxx.

Referenced by YACS::HMI::SubjectElementaryNode::loadChildren().

85 { return _setOfOutputPort; }
int YACS::ENGINE::ElementaryNode::getMaxLevelOfParallelism ( ) const
inlinevirtual

Implements YACS::ENGINE::Node.

Reimplemented in YACS::ENGINE::InlineNode.

Definition at line 109 of file ElementaryNode.hxx.

109 { return 1; }
int ElementaryNode::getNumberOfInputPorts ( ) const
virtual
int ElementaryNode::getNumberOfOutputPorts ( ) const
virtual
string ElementaryNode::getOutPortName ( const OutPort outPort) const throw (Exception)
virtual

Implements YACS::ENGINE::Node.

Definition at line 736 of file ElementaryNode.cxx.

References YACS::ENGINE::Node::getName().

737 {
738  Node *node = outPort->getNode();
739  if ( node != this )
740  {
741  string what("OutputPort "); what += outPort->getName(); what += " does not belong to node "; what += node->getName();
742  throw Exception(what);
743  }
744  return outPort->getName();
745 }
OutputDataStreamPort * ElementaryNode::getOutputDataStreamPort ( const std::string &  name) const throw (Exception)
virtual

Implements YACS::ENGINE::Node.

Reimplemented in YACS::ENGINE::DFToDSForLoop.

Definition at line 242 of file ElementaryNode.cxx.

Referenced by getReadyTasks(), and YACS::HMI::CommandAddODSPortFromCatalog::localReverse().

243 {
244  return getPort<OutputDataStreamPort>(name,_setOfOutputDataStreamPort);
245 }
OutputPort * ElementaryNode::getOutputPort ( const std::string &  name) const throw (Exception)
virtual
template<class PORT >
PORT * YACS::ENGINE::ElementaryNode::getPort ( const std::string &  name,
const std::list< PORT * > &  setOfPorts 
) const throw (Exception)
protected

protected: get a port in a list given it's name

Definition at line 155 of file ElementaryNode.hxx.

156  {
157  for(typename std::list<PORT *>::const_iterator iter=setOfPorts.begin();iter!=setOfPorts.end();iter++)
158  {
159  if((*iter)->getName()==name)
160  return *iter;
161  }
162  std::string what="ElementaryNode::getPort : unexisting "; what+=PORT::NAME;
163  what+=" with name ";
164  what+=name;
165  throw Exception(what);
166  }
list< ProgressWeight > ElementaryNode::getProgressWeight ( ) const
virtual

Get the progress weight for all elementary nodes.

Only elementary nodes have weight. At this stage weight is 0 or 1 (it can be modified later following the kind of father)

Implements YACS::ENGINE::Node.

Definition at line 556 of file ElementaryNode.cxx.

References YACS::DONE, getState(), PMMLBasicsTestLauncher::ret, YACS::ENGINE::ProgressWeight::weightDone, and YACS::ENGINE::ProgressWeight::weightTotal.

557 {
558  list<ProgressWeight> ret;
559  ProgressWeight myWeight;
560  myWeight.weightTotal=1;
561  if (getState() == YACS::DONE)
562  myWeight.weightDone=1;
563  else
564  myWeight.weightDone=0;
565  ret.push_back(myWeight);
566  return ret;
567 }
void ElementaryNode::getReadyTasks ( std::vector< Task * > &  tasks)
virtual

add this node task to a given set of ready tasks, if this task is ready to activate

Implements YACS::ENGINE::Node.

Reimplemented in YACS::ENGINE::DSToDFForLoop, and YACS::ENGINE::DFToDSForLoop.

Definition at line 360 of file ElementaryNode.cxx.

References YACS::ENGINE::InPort::_backLinks, YACS::ENGINE::Node::_father, YACS::ENGINE::Node::_propertyMap, YACS::ENGINE::OutputDataStreamPort::_setOfInputDataStreamPort, _setOfOutputPort, YACS::ENGINE::Node::_state, YACS::ENGINE::Node::clone(), createMultiDatastreamPorts(), DEBTRACE, YACS::ENGINE::ComposedNode::edAddDFLink(), YACS::ENGINE::ComposedNode::edAddLink(), YACS::ENGINE::InGate::exNotifyFromPrecursor(), exUpdateState(), YACS::ENGINE::InGate::getBackLinks(), YACS::ENGINE::InputDataStreamPort::getConnectedOutputDataStreamPort(), getContainer(), YACS::ENGINE::Node::getInGate(), getInputDataStreamPort(), getInputPort(), YACS::ENGINE::Node::getName(), getOutputDataStreamPort(), YACS::ENGINE::Node::getProc(), getSetOfInputDataStreamPort(), getSetOfInputPort(), getSetOfOutputDataStreamPort(), CORBAEngineTest::i, init(), YACS::ENGINE::Node::setName(), YACS::ENGINE::Container::setProperty(), YACS::TOACTIVATE, YACS::TOLOAD, and YACS::TORECONNECT.

Referenced by YACS::ENGINE::OptimizerLoop::getReadyTasks(), YACS::ENGINE::Switch::getReadyTasks(), YACS::ENGINE::Loop::getReadyTasks(), and YACS::ENGINE::ForEachLoop::getReadyTasks().

361 {
362  DEBTRACE("ElementaryNode::getReadyTasks: " << getName() << " " << _state);
363 
364  int multi = 1;
365  std::map<std::string,std::string>::iterator it=_propertyMap.find("multi");
366  if(it != _propertyMap.end())
367  {
368  std::string multi_str = it->second;
369  std::istringstream iss(multi_str);
370  if (!(iss >> multi))
371  throw Exception("Property multi should be set with a stringified int not an: " + multi_str);
372  }
373 
375  {
376  if (multi == 1)
377  {
378  std::map<std::string,std::string>::iterator it=_propertyMap.find("multi_working_dir");
379  if(it != _propertyMap.end())
380  {
381  std::string working_dir_base = it->second;
382  std::ostringstream working_dir_stream;
383  working_dir_stream << working_dir_base;
384  working_dir_stream << 1;
385  this->getContainer()->setProperty("workingdir", working_dir_stream.str());
386  }
387  tasks.push_back(this);
388  }
389  else
390  {
391 
392  // Check output port -> cannot clone an Elementary Node with Output Ports connected
393  std::list<OutputPort *>::iterator it_output = _setOfOutputPort.begin();
394  for (;it_output != _setOfOutputPort.end(); it_output++)
395  {
396  if ((*it_output)->isConnected())
397  {
398  throw Exception("Property multi cannot be set on nodes with dataflow output ports connected");
399  }
400  }
401 
402  // Add my instance
403  std::map<std::string,std::string>::iterator it=_propertyMap.find("multi_working_dir");
404  if(it != _propertyMap.end())
405  {
406  std::string working_dir_base = it->second;
407  std::ostringstream working_dir_stream;
408  working_dir_stream << working_dir_base;
409  working_dir_stream << 1;
410  this->getContainer()->setProperty("workingdir", working_dir_stream.str());
411  }
412  tasks.push_back(this);
413 
414  // Step 1: Create clones
415  for (int i = 1; i < multi; i++)
416  {
417  // Clone
418  YACS::ENGINE::ElementaryNode * new_node = static_cast<YACS::ENGINE::ElementaryNode *>(clone(_father, false));
419  new_node->createMultiDatastreamPorts();
420 
421  // Change name
422  std::string iname;
423  std::stringstream inamess;
424  inamess << getName() << "_" << i;
425  iname=inamess.str();
426  DEBTRACE("Create clone "<< iname << " of node " << getName());
427  new_node->setName(iname);
428 
429  // For each input port connect it with the original output port
430  std::list<InputPort *> clone_list_inputPorts = new_node->getSetOfInputPort();
431  for(list<InputPort *>::const_iterator iter1=clone_list_inputPorts.begin(); iter1!=clone_list_inputPorts.end(); iter1++)
432  {
433  std::string input_port_name = (*iter1)->getName();
434  // Get Port Name in master node
435  InputPort * master_port = getInputPort(input_port_name);
436  for (std::set<OutPort *>::const_iterator itt=master_port->_backLinks.begin(); itt!=master_port->_backLinks.end();itt++)
437  {
438  // Connect dataflow
439  getProc()->edAddDFLink((*itt),(*iter1));
440  }
441  }
442 
443  // InputDataStreamPort connections
444  std::list<InputDataStreamPort *> clone_list_inputDatastreamPorts = new_node->getSetOfInputDataStreamPort();
445  for(list<InputDataStreamPort *>::iterator iter = clone_list_inputDatastreamPorts.begin(); iter != clone_list_inputDatastreamPorts.end(); iter++)
446  {
447  std::string port_name = (*iter)->getName();
448  InputDataStreamPort * orig_port = getInputDataStreamPort(port_name);
449 
450  std::set<OutputDataStreamPort *> connected_ports = orig_port->getConnectedOutputDataStreamPort();
451 
452  // Create datastream ports if not created
453  std::set<OutputDataStreamPort *>::const_iterator iter3;
454  for(iter3=connected_ports.begin();iter3!=connected_ports.end();iter3++)
455  {
456  ElementaryNode * node = (ElementaryNode *) (*iter3)->getNode();
458 
459  std::string good_port_name;
460  std::stringstream temp_name;
461  std::string out_name = (*iter3)->getName();
462  out_name.erase(out_name.end()-1);
463  temp_name << out_name << i;
464  good_port_name = temp_name.str();
465  getProc()->edAddLink(node->getOutputDataStreamPort(good_port_name), (*iter));
466  }
467  }
468 
469  // OutputDataStreamPort connections
470  std::list<OutputDataStreamPort *> clone_list_outputDatastreamPorts = new_node->getSetOfOutputDataStreamPort();
471  for(list<OutputDataStreamPort *>::iterator iter = clone_list_outputDatastreamPorts.begin(); iter != clone_list_outputDatastreamPorts.end(); iter++)
472  {
473  std::string port_name = (*iter)->getName();
474  OutputDataStreamPort * orig_port = getOutputDataStreamPort(port_name);
475  std::set<InputDataStreamPort *> dest_input_port = orig_port->_setOfInputDataStreamPort;
476  for(set<InputDataStreamPort *>::iterator dest_port = dest_input_port.begin(); dest_port != dest_input_port.end(); dest_port++)
477  {
478  ElementaryNode * dest_node = (ElementaryNode *)(*dest_port)->getNode();
479  // Add InputPort to dest node
480  dest_node->createMultiDatastreamPorts();
481 
482  std::string good_port_name;
483  std::stringstream temp_name;
484  std::string in_name = (*dest_port)->getName();
485  in_name.erase(in_name.end()-1);
486  temp_name << in_name << i;
487  good_port_name = temp_name.str();
488  getProc()->edAddLink((*iter), dest_node->getInputDataStreamPort(good_port_name));
489  }
490  }
491 
492  // Init node
493  new_node->init(false);
494  new_node->exUpdateState();
495 
496  // Set Control Link to done
497  std::list<OutGate *> clone_cl_back = new_node->getInGate()->getBackLinks();
498  for(std::list<OutGate *>::const_iterator iter=clone_cl_back.begin(); iter!=clone_cl_back.end(); iter++)
499  new_node->getInGate()->exNotifyFromPrecursor((*iter));
500 
501  // Add clone
502  std::map<std::string,std::string>::iterator it=_propertyMap.find("multi_working_dir");
503  if(it != _propertyMap.end())
504  {
505  std::string working_dir_base = it->second;
506  std::ostringstream working_dir_stream;
507  working_dir_stream << working_dir_base;
508  working_dir_stream << i+1;
509  new_node->getContainer()->setProperty("workingdir", working_dir_stream.str());
510  }
511  tasks.push_back(new_node);
512  }
513  }
514  }
515 }
list< ElementaryNode * > ElementaryNode::getRecursiveConstituents ( ) const
virtual
Returns
a set with only this node. (Same method in composed nodes)

Implements YACS::ENGINE::Node.

Definition at line 544 of file ElementaryNode.cxx.

References PMMLBasicsTestLauncher::ret.

545 {
546  list<ElementaryNode *> ret;
547  ret.push_back((ElementaryNode *)this);
548  return ret;
549 }
std::list<InputDataStreamPort *> YACS::ENGINE::ElementaryNode::getSetOfInputDataStreamPort ( ) const
inlinevirtual
std::list<InputPort *> YACS::ENGINE::ElementaryNode::getSetOfInputPort ( ) const
inlinevirtual
std::vector< std::pair< InPort *, OutPort * > > ElementaryNode::getSetOfLinksComingInCurrentScope ( ) const
virtual

Implements YACS::ENGINE::Node.

Definition at line 219 of file ElementaryNode.cxx.

References getAllInPortsComingFromOutsideOfCurrentScope(), and PMMLBasicsTestLauncher::ret.

220 {
221  vector< pair<InPort *, OutPort *> > ret;
222  set<InPort *> ports=getAllInPortsComingFromOutsideOfCurrentScope();
223  for(set<InPort *>::iterator iter2=ports.begin();iter2!=ports.end();iter2++)
224  {
225  set<OutPort *> temp2=(*iter2)->edSetOutPort();
226  for(set<OutPort *>::iterator iter3=temp2.begin();iter3!=temp2.end();iter3++)
227  {
228  std::set<OutPort *> trueOutPorts;
229  (*iter3)->getAllRepresented(trueOutPorts);
230  for(std::set<OutPort *>::iterator iter4=trueOutPorts.begin();iter4!=trueOutPorts.end();++iter4)
231  ret.push_back(pair<InPort *, OutPort *>(*iter2,*iter4));
232  }
233  }
234  return ret;
235 }
std::vector< std::pair< OutPort *, InPort * > > ElementaryNode::getSetOfLinksLeavingCurrentScope ( ) const
virtual

Implements YACS::ENGINE::Node.

Definition at line 206 of file ElementaryNode.cxx.

References getAllOutPortsLeavingCurrentScope(), and PMMLBasicsTestLauncher::ret.

207 {
208  vector< pair<OutPort *, InPort *> > ret;
209  std::set<OutPort *> ports=getAllOutPortsLeavingCurrentScope();
210  for(set<OutPort *>::iterator iter2=ports.begin();iter2!=ports.end();iter2++)
211  {
212  set<InPort *> temp2=(*iter2)->edSetInPort();
213  for(set<InPort *>::iterator iter3=temp2.begin();iter3!=temp2.end();iter3++)
214  ret.push_back(pair<OutPort *, InPort *>(*iter2,*iter3));
215  }
216  return ret;
217 }
std::list<OutputDataStreamPort *> YACS::ENGINE::ElementaryNode::getSetOfOutputDataStreamPort ( ) const
inlinevirtual
std::list<OutputPort *> YACS::ENGINE::ElementaryNode::getSetOfOutputPort ( ) const
inlinevirtual
YACS::StatesForNode ElementaryNode::getState ( ) const
virtual
void ElementaryNode::init ( bool  start = true)
virtual

initialisation of all input and output ports and gates, for execution

Reimplemented from YACS::ENGINE::Node.

Reimplemented in YACS::ENGINE::PyFuncNode, and YACS::ENGINE::SplitterNode.

Definition at line 97 of file ElementaryNode.cxx.

References YACS::ENGINE::Node::_state, DEBTRACE, YACS::DISABLED, YACS::ENGINE::Node::exDisabledState(), YACS::ENGINE::Node::getName(), initCommonPartWithoutStateManagement(), YACS::READY, and YACS::ENGINE::Node::setState().

Referenced by getReadyTasks(), and YACS::ENGINE::SplitterNode::init().

98 {
99  DEBTRACE("ElementaryNode::init " << getName() << " " << start << " " << _state);
101  if(_state == YACS::DISABLED)
102  {
103  exDisabledState(); // to refresh propagation of DISABLED state
104  return ;
105  }
107 }
void ElementaryNode::initCommonPartWithoutStateManagement ( bool  start)
protected

Definition at line 88 of file ElementaryNode.cxx.

References YACS::ENGINE::Node::_inGate, _setOfInputPort, _setOfOutputPort, and YACS::ENGINE::InGate::exReset().

Referenced by init(), and YACS::ENGINE::PyFuncNode::init().

89 {
90  for(list<OutputPort *>::iterator iter=_setOfOutputPort.begin();iter!=_setOfOutputPort.end();iter++)
91  (*iter)->exInit();
92  for(list<InputPort *>::iterator iter2=_setOfInputPort.begin();iter2!=_setOfInputPort.end();iter2++)
93  (*iter2)->exInit(start);
94  _inGate.exReset();
95 }
virtual void YACS::ENGINE::ElementaryNode::initService ( )
inlinevirtual

Implements YACS::ENGINE::Task.

Definition at line 119 of file ElementaryNode.hxx.

119 { }
bool ElementaryNode::isDeployable ( ) const
virtual

Implements YACS::ENGINE::Task.

Reimplemented in YACS::ENGINE::InlineNode, YACS::ENGINE::ServerNode, and YACS::ENGINE::ServiceNode.

Definition at line 109 of file ElementaryNode.cxx.

110 {
111  return false;
112 }
template<class PORT >
static bool YACS::ENGINE::ElementaryNode::isPortNameAlreadyExist ( const std::string &  portName,
const std::list< PORT * > &  setOfPorts 
)
staticprotected
template<class PORT >
bool YACS::ENGINE::ElementaryNode::isPortNameAlreadyExist ( const std::string &  portName,
const std::list< PORT * > &  setOfPorts 
)

protected: checks existence of a port, given it's name, in a list

Definition at line 221 of file ElementaryNode.hxx.

222  {
223  for(typename std::list<PORT *>::const_iterator iter=setOfPorts.begin();iter!=setOfPorts.end();iter++)
224  {
225  if((*iter)->getName()==portName)
226  return true;
227  }
228  return false;
229  }
bool ElementaryNode::isReady ( )
virtual

Implements YACS::ENGINE::Task.

Definition at line 752 of file ElementaryNode.cxx.

References YACS::ENGINE::Node::_state, and YACS::TOACTIVATE.

753 {
754  return _state==TOACTIVATE;
755 }
virtual void YACS::ENGINE::ElementaryNode::load ( )
inlinevirtual
void ElementaryNode::loaded ( )
virtual

Notify this node that it is loaded.

When an elementary node has been loaded It is ready to be connected

Implements YACS::ENGINE::Task.

Definition at line 772 of file ElementaryNode.cxx.

773 {
774 }
void ElementaryNode::performDuplicationOfPlacement ( const Node other)
protectedvirtual

performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute.

Implements YACS::ENGINE::Node.

Reimplemented in YACS::ENGINE::InlineNode, and YACS::ENGINE::ServiceNode.

Definition at line 68 of file ElementaryNode.cxx.

69 {
70 }
void ElementaryNode::performShallowDuplicationOfPlacement ( const Node other)
protectedvirtual

performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning.

Implements YACS::ENGINE::Node.

Reimplemented in YACS::ENGINE::InlineNode, and YACS::ENGINE::ServiceNode.

Definition at line 72 of file ElementaryNode.cxx.

73 {
74 }
virtual std::string YACS::ENGINE::ElementaryNode::typeName ( )
inlinevirtual

Friends And Related Function Documentation

friend class ComposedNode
friend

Definition at line 45 of file ElementaryNode.hxx.

Member Data Documentation

bool YACS::ENGINE::ElementaryNode::_createDatastreamPorts
protected

Definition at line 53 of file ElementaryNode.hxx.

Referenced by createMultiDatastreamPorts(), and ElementaryNode().

bool YACS::ENGINE::ElementaryNode::_multi_port_node
protected

Definition at line 54 of file ElementaryNode.hxx.

Referenced by createMultiDatastreamPorts(), and ElementaryNode().

std::list<InputDataStreamPort *> YACS::ENGINE::ElementaryNode::_setOfInputDataStreamPort
protected
std::list<InputPort *> YACS::ENGINE::ElementaryNode::_setOfInputPort
protected
std::list<OutputDataStreamPort *> YACS::ENGINE::ElementaryNode::_setOfOutputDataStreamPort
protected
std::list<OutputPort *> YACS::ENGINE::ElementaryNode::_setOfOutputPort
protected

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