Version: 8.3.0
YACS::ENGINE::Loop Class Referenceabstract

Base class for loop node. More...

#include <Loop.hxx>

Inheritance diagram for YACS::ENGINE::Loop:
Collaboration diagram for YACS::ENGINE::Loop:

Public Member Functions

 Loop (const Loop &other, ComposedNode *father, bool editionOnly)
 
 Loop (const std::string &name)
 
 ~Loop ()
 
void init (bool start=true)
 
int getNbOfTurns () const
 
NodeedSetNode (Node *DISOWNnode)
 
virtual bool edAddChild (Node *DISOWNnode) throw (Exception)
 
NodeedRemoveNode ()
 
virtual void checkBasicConsistency () const throw (Exception)
 
virtual InputPortgetDecisionPort () const =0
 Returns the port which value is used to take decision about the continuation of the loop. More...
 
void getReadyTasks (std::vector< Task * > &tasks)
 Collect all the child nodes that are ready. More...
 
void edRemoveChild (Node *node) throw (Exception)
 Remove a child node. More...
 
bool isRepeatedUnpredictablySeveralTimes () const
 
std::list< Node * > edGetDirectDescendants () const
 
std::list< InputPort * > getSetOfInputPort () const
 
int getNumberOfInputPorts () const
 
int getMaxLevelOfParallelism () const
 
NodegetChildByShortName (const std::string &name) const throw (Exception)
 
virtual bool edAddDFLink (OutPort *start, InPort *end) throw (Exception)
 Connect an OutPort to an InPort and add control link if necessary. More...
 
void writeDot (std::ostream &os) const
 Dump the node state to a stream. More...
 
virtual void accept (Visitor *visitor)
 
virtual std::string typeName ()
 
- Public Member Functions inherited from YACS::ENGINE::StaticDefinedComposedNode
bool isPlacementPredictableB4Run () const
 
bool isMultiplicitySpecified (unsigned &value) const
 
void forceMultiplicity (unsigned value)
 
void selectRunnableTasks (std::vector< Task * > &tasks)
 
- Public Member Functions inherited from YACS::ENGINE::ComposedNode
virtual ~ComposedNode ()
 
bool isFinished ()
 
virtual void shutdown (int level)
 Stop all pending activities of the composed node. More...
 
virtual void resetState (int level)
 Reset the state of the node and its children depending on the parameter level. More...
 
std::string getName () const
 
std::string getTaskName (Task *task) const
 
DeploymentTree getDeploymentTree () const
 Essentially for test. Use checkDeploymentTree instead to be sure that returned DeploymentTree is consistent. More...
 
DeploymentTree checkDeploymentTree (bool deep) const throw (Exception)
 Perform check of deployment consistency of the current graph. More...
 
std::vector< Task * > getNextTasks (bool &isMore)
 
void notifyFrom (const Task *sender, YACS::Event event, const Executor *execInst)
 Notify the node a task has emitted an event. More...
 
bool edAddLink (OutPort *start, InPort *end) throw (Exception)
 Add a dataflow link between two data ports. More...
 
bool edAddLink (OutGate *start, InGate *end) throw (Exception)
 Add a controlflow link between two control ports. More...
 
bool edAddCFLink (Node *nodeS, Node *nodeE) throw (Exception)
 Add a controlflow link between two nodes. More...
 
void edRemoveCFLink (Node *nodeS, Node *nodeE) throw (Exception)
 Remove a controlflow link. More...
 
void edRemoveLink (OutPort *start, InPort *end) throw (Exception)
 Remove a dataflow link. More...
 
void edRemoveLink (OutGate *start, InGate *end) throw (Exception)
 Remove a controlflow link. More...
 
virtual void removeRecursivelyRedundantCL ()
 
std::list< ElementaryNode * > getRecursiveConstituents () const
 
std::list< Node * > getAllRecursiveNodes ()
 Get all children nodes elementary and composed including this node. More...
 
virtual std::list< Node * > getAllRecursiveConstituents ()
 Idem getAllRecursiveNodes, but this node is NOT included. More...
 
std::list< ProgressWeightgetProgressWeight () const
 Get the progress weight for all elementary nodes. More...
 
std::string getInPortName (const InPort *) const throw (Exception)
 Get the input port name. More...
 
std::string getOutPortName (const OutPort *) const throw (Exception)
 
int getNumberOfOutputPorts () const
 
std::list< OutputPort * > getSetOfOutputPort () const
 
std::list< InputPort * > getLocalInputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
std::list< OutputPort * > getLocalOutputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
std::set< OutPort * > getAllOutPortsLeavingCurrentScope () const
 List all output ports of children nodes that are linked to out of scope input ports. More...
 
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope () const
 List all input ports that are linked to out of scope ports. More...
 
std::list< InputDataStreamPort * > getSetOfInputDataStreamPort () const
 
std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort () const
 
OutPortgetOutPort (const std::string &name) const throw (Exception)
 
InputPortgetInputPort (const std::string &name) const throw (Exception)
 Get an input port given its name. More...
 
OutputPortgetOutputPort (const std::string &name) const throw (Exception)
 Get an output port given its name. More...
 
InputDataStreamPortgetInputDataStreamPort (const std::string &name) const throw (Exception)
 
OutputDataStreamPortgetOutputDataStreamPort (const std::string &name) const throw (Exception)
 
std::vector< std::pair
< OutPort *, InPort * > > 
getSetOfInternalLinks () const
 
virtual std::vector< std::pair
< OutPort *, InPort * > > 
getSetOfLinksLeavingCurrentScope () const
 
void checkConsistency (LinkInfo &info) const throw (Exception)
 
virtual std::vector< std::pair
< InPort *, OutPort * > > 
getSetOfLinksComingInCurrentScope () const
 
virtual void edUpdateState ()
 update the status of the node More...
 
virtual std::string getErrorReport ()
 returns a string that contains an error report if the node is in error More...
 
ComposedNodegetRootNode () const throw (Exception)
 
bool isNodeAlreadyAggregated (const Node *node) const
 Check that Node 'node' is already a direct son of this. More...
 
virtual bool isNameAlreadyUsed (const std::string &name) const
 
NodeisInMyDescendance (Node *nodeToTest) const
 Returns the parent of a node that is the direct child of this node. More...
 
std::string getChildName (const Node *node) const throw (Exception)
 
virtual std::string getMyQualifiedName (const Node *directSon) const
 
NodegetChildByName (const std::string &name) const throw (Exception)
 
void loaded ()
 
void connected ()
 
virtual void cleanNodes ()
 Clean the composed node in case of not clean exit. More...
 
virtual std::string getProgress () const
 
- Public Member Functions inherited from YACS::ENGINE::Node
virtual ~Node ()
 
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 getState () const
 
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 exUpdateState ()
 Update the node state. 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)
 
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 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 getContainerLog ()
 returns a string that contains the name of the container log file if it exists More...
 
virtual void ensureLoading ()
 Put this node into TOLOAD state when possible. More...
 
virtual void getCoupledNodes (std::set< Task * > &coupledNodes)
 
- Public Member Functions inherited from YACS::ENGINE::Scheduler
virtual void exUpdateState ()=0
 
virtual ~Scheduler ()
 

Static Public Member Functions

static TypeCodeMappingDF2DS (TypeCode *type) throw (Exception)
 
static TypeCodeMappingDS2DF (TypeCode *type) throw (Exception)
 

Protected Member Functions

void buildDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
 
void buildDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
void getDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView) throw (Exception)
 
void getDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView) throw (Exception)
 
void releaseDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView) throw (Exception)
 
void releaseDelegateOf (OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView) throw (Exception)
 
void checkNoCyclePassingThrough (Node *node) throw (Exception)
 
void checkControlDependancy (OutPort *start, InPort *end, bool cross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &fw, std::vector< OutPort * > &fwCross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &bw, LinkInfo &info) const
 
void checkCFLinks (const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
 check control flow links More...
 
- Protected Member Functions inherited from YACS::ENGINE::StaticDefinedComposedNode
 StaticDefinedComposedNode (const std::string &name)
 
 StaticDefinedComposedNode (const StaticDefinedComposedNode &other, ComposedNode *father)
 
void checkControlDependancy (OutPort *start, InPort *end, bool cross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &fw, std::vector< OutPort * > &fwCross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &bw, LinkInfo &info) const
 
- Protected Member Functions inherited from YACS::ENGINE::ComposedNode
 ComposedNode (const std::string &name)
 
 ComposedNode (const ComposedNode &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 edDisconnectAllLinksWithMe ()
 
YACS::Event updateStateFrom (Node *node, YACS::Event event, const Executor *execInst)
 Update node state on receiving event from a node. More...
 
virtual YACS::Event updateStateOnStartEventFrom (Node *node)
 Method used to notify the node that a child node has started. More...
 
virtual YACS::Event updateStateOnFinishedEventFrom (Node *node)=0
 
virtual YACS::Event updateStateOnFailedEventFrom (Node *node, const Executor *execInst)
 Method used to notify the node that a child node has failed. More...
 
virtual void checkLinkPossibility (OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd) throw (Exception)
 
void checkInMyDescendance (Node *nodeToTest) const throw (Exception)
 Check if a node is in the descendance of this node. More...
 
template<class PORT >
std::string getPortName (const PORT *port) const throw (Exception)
 
void checkNoCrossHierachyWith (Node *node) const throw (Exception)
 
virtual void performCFComputations (LinkInfo &info) const
 perform recursively all CF computations. More...
 
virtual void destructCFComputations (LinkInfo &info) const
 destroy recursively all results of initial computations. More...
 
NodegetLowestNodeDealingAll (const std::list< OutPort * > &ports) const
 
void checkLinksCoherenceRegardingControl (const std::vector< OutPort * > &starts, InputPort *end, LinkInfo &info) const throw (Exception)
 
void solveObviousOrDelegateCFLinks (const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
 
- 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

static bool isNecessaryToBuildSpecificDelegateDF2DS (const std::list< ComposedNode * > &pointsOfView)
 

Protected Attributes

Node_node
 
int _nbOfTurns
 
FakeNodeForLoop_nodeForNullTurnOfLoops
 
std::set< DSToDFForLoop * > _inputsTraducer
 
std::set< DFToDSForLoop * > _outputsTraducer
 

Friends

class DSToDFForLoop
 
class FakeNodeForLoop
 
void NbDoneLoader (Loop *node, int val)
 

Additional Inherited Members

- 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::ComposedNode
static const char SEP_CHAR_BTW_LEVEL [] ="."
 
static const unsigned char FED_ST = 2
 
static const unsigned char FREE_ST = 0
 
static const unsigned char FED_DS_ST = 1
 

Detailed Description

Base class for loop node.

See Also
ForLoop
WhileLoop

Definition at line 145 of file Loop.hxx.

Constructor & Destructor Documentation

Loop::Loop ( const Loop other,
ComposedNode father,
bool  editionOnly 
)

Definition at line 293 of file Loop.cxx.

References _node, and YACS::ENGINE::Node::simpleClone().

294 {
295  if(other._node)
296  _node=other._node->simpleClone(this,editionOnly);
297 }
Loop::Loop ( const std::string &  name)

Definition at line 299 of file Loop.cxx.

Loop::~Loop ( )

Definition at line 303 of file Loop.cxx.

References _inputsTraducer, _node, _nodeForNullTurnOfLoops, and _outputsTraducer.

304 {
305  delete _node;
307  for(set<DSToDFForLoop *>::iterator iter1=_inputsTraducer.begin();iter1!=_inputsTraducer.end();iter1++)
308  delete (*iter1);
309  for(set<DFToDSForLoop *>::iterator iter2=_outputsTraducer.begin();iter2!=_outputsTraducer.end();iter2++)
310  delete (*iter2);
311 }

Member Function Documentation

void Loop::accept ( Visitor visitor)
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::ForLoop, and YACS::ENGINE::WhileLoop.

Definition at line 656 of file Loop.cxx.

References YACS::ENGINE::Visitor::visitLoop().

657 {
658  visitor->visitLoop(this);
659 }
void Loop::buildDelegateOf ( InPort *&  port,
OutPort initialStart,
const std::list< ComposedNode * > &  pointsOfView 
)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 441 of file Loop.cxx.

References _inputsTraducer, DSToDFForLoop, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::DataPort::getNameOfTypeOfCurrentInstance(), isNecessaryToBuildSpecificDelegateDF2DS(), MappingDF2DS(), YACS::ENGINE::InputPort::NAME, and YACS::ENGINE::OutputPort::NAME.

442 {
443  string typeOfPortInstance=port->getNameOfTypeOfCurrentInstance();
444  if(typeOfPortInstance!=InputPort::NAME ||
445  (typeOfPortInstance == InputPort::NAME &&
448  return ;
449  InputPort *portCasted=(InputPort *)port;
450  set<DSToDFForLoop*>::iterator iter;
451  //Determinig if a DSToDFForLoop node has already been created for delegation of 'port'
452  for(iter=_inputsTraducer.begin();iter!=_inputsTraducer.end();iter++)
453  if((*iter)->getOutputPort("")->isAlreadyInSet(portCasted))
454  break;
455  if(iter==_inputsTraducer.end())
456  {//first time that 'port' is delegated on higher level
457  pair<set<DSToDFForLoop*>::iterator, bool> iter2=_inputsTraducer.insert(new DSToDFForLoop(this,portCasted->getName(),Loop::MappingDF2DS(portCasted->edGetType())));
458  iter=iter2.first;
459  (*iter)->getOutputPort("")->addInPort(portCasted);
460  }
461  else
462  (*iter)->loopHasOneMoreRef();
463  port=(*iter)->getInputDataStreamPort("");
464 }
void Loop::buildDelegateOf ( std::pair< OutPort *, OutPort * > &  port,
InPort finalTarget,
const std::list< ComposedNode * > &  pointsOfView 
)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 466 of file Loop.cxx.

References _outputsTraducer, YACS::ENGINE::OutPort::addInPort(), YACS::ENGINE::ComposedNode::edAddLink(), YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::Node::getInGate(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::DataPort::getNameOfTypeOfCurrentInstance(), YACS::ENGINE::Node::getOutGate(), YACS::ENGINE::OutPort::isAlreadyLinkedWith(), YACS::ENGINE::ComposedNode::isInMyDescendance(), isNecessaryToBuildSpecificDelegateDF2DS(), YACS::ENGINE::DFToDSForLoop::loopHasOneMoreRef(), YACS::ENGINE::InputPort::NAME, and YACS::ENGINE::OutputPort::NAME.

467 {
468  string typeOfPortInstance=(port.first)->getNameOfTypeOfCurrentInstance();
469  if(typeOfPortInstance!=OutputPort::NAME ||
470  ( typeOfPortInstance == OutputPort::NAME &&
473  return ;
474  OutPort *portCasted=port.first;
475  set<DFToDSForLoop*>::iterator iter;
476  //Determinig if a DFToDSForLoop node has already been created for delegation of 'port'
477  for(iter=_outputsTraducer.begin();iter!=_outputsTraducer.end();iter++)
478  if(portCasted->isAlreadyLinkedWith((*iter)->getInputPort("")))
479  break;
480  DFToDSForLoop *kl;
481  if(iter==_outputsTraducer.end())
482  {//first time that 'port' is delegated on higher level
483  //_outputsTraducer.insert(new DFToDSForLoop(this,portCasted->getName(),portCasted->edGetType()));
484  kl=new DFToDSForLoop(this,portCasted->getName(),portCasted->edGetType());
485  pair<set<DFToDSForLoop*>::iterator, bool> iter2=_outputsTraducer.insert(kl);
486  iter=iter2.first;
487  portCasted->addInPort((*iter)->getInputPort(""));
488  }
489  else
490  {
491  kl=*iter;
492  kl->loopHasOneMoreRef();
493  }
494  edAddLink(isInMyDescendance((port.first)->getNode())->getOutGate(),kl->getInGate());
495  port.first=(*iter)->getOutputDataStreamPort("");
496 }
void Loop::checkBasicConsistency ( ) const throw (Exception)
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 675 of file Loop.cxx.

References _node, YACS::ENGINE::ComposedNode::checkBasicConsistency(), and DEBTRACE.

676 {
677  DEBTRACE("Loop::checkBasicConsistency");
679  if(!_node)
680  throw Exception("For a loop, internal node is mandatory");
681 }
void Loop::checkCFLinks ( const std::list< OutPort * > &  starts,
InputPort end,
unsigned char &  alreadyFed,
bool  direction,
LinkInfo info 
) const
protectedvirtual

check control flow links

Parameters
startsIf different of 0, must aggregate at leat 1 element.
end:
alreadyFedin/out parameter. Indicates if 'end' ports is already and surely set or fed by an another port.
directionIf true : forward direction else backward direction.
info: informations collectedduring the check

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 594 of file Loop.cxx.

References YACS::ENGINE::ComposedNode::checkCFLinks(), YACS::ENGINE::Port::getNode(), and YACS::ENGINE::ComposedNode::solveObviousOrDelegateCFLinks().

595 {
596  Node *nodeEnd=end->getNode();
597  if(nodeEnd==this)
598  {//In this case 'end' port is a special port of this (for exemple ForLoop::_nbOfTimesPort)
599  //ASSERT(!direction) see Loop::checkControlDependancy (bw only)
600  solveObviousOrDelegateCFLinks(starts,end,alreadyFed,direction,info);
601  }
602  else
603  StaticDefinedComposedNode::checkCFLinks(starts,end,alreadyFed,direction,info);
604 }
void Loop::checkControlDependancy ( OutPort start,
InPort end,
bool  cross,
std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &  fw,
std::vector< OutPort * > &  fwCross,
std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &  bw,
LinkInfo info 
) const
protectedvirtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 661 of file Loop.cxx.

References YACS::ENGINE::StaticDefinedComposedNode::checkControlDependancy(), and getDecisionPort().

666 {
667  //First testing if end==getDecisionPort. This is the only case possible in theory.
668  if(end!=getDecisionPort())
669  return StaticDefinedComposedNode::checkControlDependancy(start,end,cross,fw,fwCross,bw,info);
670  if(cross)
671  throw Exception("Internal error occured - cross type link detected on decision port of a loop. Forbidden !");
672  fw[(ComposedNode *)this].push_back(start);
673 }
void Loop::checkNoCyclePassingThrough ( Node node) throw (Exception)
protectedvirtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 589 of file Loop.cxx.

590 {
591  //throw Exception("Loop::checkNoCyclePassingThrough : Internal error occured");
592 }
bool Loop::edAddChild ( Node DISOWNnode) throw (Exception)
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 347 of file Loop.cxx.

348 {
349  return edSetNode(node);
350 }
bool Loop::edAddDFLink ( OutPort start,
InPort end 
) throw (Exception)
virtual

Connect an OutPort to an InPort and add control link if necessary.

Connect the ports with a data link (edAddLink) In a Loop don't add control flow link : use this only to add data back links

Parameters
start: the OutPort to connect
end: the InPort to connect
Returns
true if a new link has been created, false otherwise.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 629 of file Loop.cxx.

630 {
631  return edAddLink(start,end);
632 }
std::list< Node * > Loop::edGetDirectDescendants ( ) const
virtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 395 of file Loop.cxx.

References _node, and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::ForLoop::getProgressWeight().

396 {
397  list<Node *> ret;
398  if(_node)
399  ret.push_back(_node);
400  return ret;
401 }
void Loop::edRemoveChild ( Node node) throw (Exception)
virtual

Remove a child node.

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 387 of file Loop.cxx.

References YACS::ENGINE::ComposedNode::edRemoveChild().

388 {
390  if(_node==node)
391  _node=0;
392  modified();
393 }
Node * Loop::edRemoveNode ( )
Node * Loop::edSetNode ( Node DISOWNnode)

Definition at line 325 of file Loop.cxx.

References YACS::ENGINE::Node::_father, _node, YACS::ENGINE::ComposedNode::checkNoCrossHierachyWith(), YACS::ENGINE::ComposedNode::edRemoveChild(), YACS::ENGINE::Node::getName(), YACS::ENGINE::Node::modified(), and PMMLBasicsTestLauncher::ret.

326 {
327  if(_node==node)
328  return 0;
329  if(node)
330  {
331  if(node->_father)
332  {
333  string what = "Loop::edSetNode: node "; what += node->getName(); what += " is not orphan ! ";
334  throw Exception(what);
335  }
336  }
339  Node *ret=_node;
340  _node=node;
341  _node->_father=this;
342  //set _modified flag so that edUpdateState() can refresh state
343  modified();
344  return ret;
345 }
Node * Loop::getChildByShortName ( const std::string &  name) const throw (Exception)
virtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 422 of file Loop.cxx.

423 {
424  if (_node)
425  if(name==_node->getName())
426  return _node;
427  string what("node "); what+= name ; what+=" is not a child of loop node "; what += getName();
428  throw Exception(what);
429 }
virtual InputPort* YACS::ENGINE::Loop::getDecisionPort ( ) const
pure virtual

Returns the port which value is used to take decision about the continuation of the loop.

Implemented in YACS::ENGINE::ForLoop, and YACS::ENGINE::WhileLoop.

Referenced by checkControlDependancy(), and getSetOfInputPort().

void Loop::getDelegateOf ( InPort *&  port,
OutPort initialStart,
const std::list< ComposedNode * > &  pointsOfView 
) throw (Exception)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 498 of file Loop.cxx.

References YACS::ENGINE::DataPort::getName(), YACS::ENGINE::InputPort::NAME, and YACS::ENGINE::OutputPort::NAME.

499 {
500  string typeOfPortInstance=port->getNameOfTypeOfCurrentInstance();
501  if(typeOfPortInstance!=InputPort::NAME ||
502  (typeOfPortInstance == InputPort::NAME &&
505  return ;
506  InputPort *portCasted=(InputPort *)port;
507  set<DSToDFForLoop*>::iterator iter;
508  for(iter=_inputsTraducer.begin();iter!=_inputsTraducer.end();iter++)
509  if((*iter)->getOutputPort("")->isAlreadyInSet(portCasted))
510  break;
511  if(iter==_inputsTraducer.end())
512  {
513  string what("Loop::getDelegateOf : Port with name "); what+=portCasted->getName(); what+=" not exported by loop "; what+=_name;
514  throw Exception(what);
515  }
516  else
517  port=(*iter)->getInputDataStreamPort("");
518 }
void Loop::getDelegateOf ( std::pair< OutPort *, OutPort * > &  port,
InPort finalTarget,
const std::list< ComposedNode * > &  pointsOfView 
) throw (Exception)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 520 of file Loop.cxx.

References YACS::ENGINE::DataPort::getName(), YACS::ENGINE::OutPort::isAlreadyLinkedWith(), YACS::ENGINE::InputPort::NAME, and YACS::ENGINE::OutputPort::NAME.

522 {
523  string typeOfPortInstance=(port.first)->getNameOfTypeOfCurrentInstance();
524  if(typeOfPortInstance!=OutputPort::NAME ||
525  ( typeOfPortInstance == OutputPort::NAME &&
528  return ;
529  OutPort *portCasted=port.first;
530  set<DFToDSForLoop*>::iterator iter;
531  for(iter=_outputsTraducer.begin();iter!=_outputsTraducer.end();iter++)
532  if(portCasted->isAlreadyLinkedWith((*iter)->getInputPort("")))
533  break;
534  if(iter==_outputsTraducer.end())
535  {
536  string what("Loop::getDelegateOf : Port with name "); what+=portCasted->getName(); what+=" not exported by loop "; what+=_name;
537  throw Exception(what);
538  }
539  else
540  port.first=(*iter)->getOutputDataStreamPort("");
541 }
int Loop::getMaxLevelOfParallelism ( ) const
virtual

Implements YACS::ENGINE::Node.

Definition at line 415 of file Loop.cxx.

References _node, and YACS::ENGINE::Node::getMaxLevelOfParallelism().

416 {
417  if(!_node)
418  return 0;
420 }
int Loop::getNumberOfInputPorts ( ) const
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 410 of file Loop.cxx.

References YACS::ENGINE::ComposedNode::getNumberOfInputPorts().

411 {
413 }
void Loop::getReadyTasks ( std::vector< Task * > &  tasks)
virtual

Collect all the child nodes that are ready.

Parameters
tasks: vector of tasks to collect ready nodes

Implements YACS::ENGINE::Node.

Definition at line 365 of file Loop.cxx.

References _inputsTraducer, _node, _nodeForNullTurnOfLoops, _outputsTraducer, YACS::ENGINE::Node::_state, YACS::ACTIVATED, YACS::ENGINE::ElementaryNode::getReadyTasks(), YACS::ENGINE::Node::getReadyTasks(), YACS::ENGINE::Node::setState(), and YACS::TOACTIVATE.

366 {
367  if(!_node)
368  return;
369  /*
370  * To change the way ComposedNode state is handled, uncomment the following line
371  * see Bloc::getReadyTasks
372  */
377  else
378  {
379  _node->getReadyTasks(tasks);
380  for(set<DSToDFForLoop *>::iterator iter1=_inputsTraducer.begin();iter1!=_inputsTraducer.end();iter1++)
381  (*iter1)->getReadyTasks(tasks);
382  for(set<DFToDSForLoop *>::iterator iter2=_outputsTraducer.begin();iter2!=_outputsTraducer.end();iter2++)
383  (*iter2)->getReadyTasks(tasks);
384  }
385 }
std::list< InputPort * > Loop::getSetOfInputPort ( ) const
virtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 403 of file Loop.cxx.

References getDecisionPort(), YACS::ENGINE::ComposedNode::getSetOfInputPort(), and PMMLBasicsTestLauncher::ret.

404 {
406  ret.push_back(getDecisionPort());
407  return ret;
408 }
void Loop::init ( bool  start = true)
virtual

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

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::WhileLoop.

Definition at line 313 of file Loop.cxx.

References _nbOfTurns, _node, _nodeForNullTurnOfLoops, YACS::ENGINE::ComposedNode::init(), and YACS::ENGINE::Node::init().

Referenced by YACS::ENGINE::ForLoop::init(), and YACS::ENGINE::WhileLoop::init().

314 {
316  _nbOfTurns=0;
317  if(_node)
318  _node->init(start); // if start is true, refresh the internal node
319  else
320  throw Exception("Loop::initLoop : no nodes specifies to be repeated ");
323 }
bool Loop::isNecessaryToBuildSpecificDelegateDF2DS ( const std::list< ComposedNode * > &  pointsOfView)
staticprotected
Note
: States if a DF port must be considered on an upper level in hierarchy as a DS port or not from 'pointsOfView' observers.
Returns
:
  • True : a traduction DF->DS has to be done
  • False : no traduction needed

Definition at line 612 of file Loop.cxx.

References PMMLBasicsTestLauncher::ret.

Referenced by buildDelegateOf().

613 {
614  bool ret=false;
615  for(list<ComposedNode *>::const_iterator iter=pointsOfView.begin();iter!=pointsOfView.end() && !ret;iter++)
616  ret=(*iter)->isRepeatedUnpredictablySeveralTimes();
617  return ret;
618 }
bool YACS::ENGINE::Loop::isRepeatedUnpredictablySeveralTimes ( ) const
inlinevirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 171 of file Loop.hxx.

171 { return true; }
TypeCode * Loop::MappingDF2DS ( TypeCode type) throw (Exception)
static

Definition at line 431 of file Loop.cxx.

Referenced by buildDelegateOf(), and YACS::ENGINE::DFToDSForLoop::DFToDSForLoop().

432 {
433  return type;
434 }
TypeCode * Loop::MappingDS2DF ( TypeCode type) throw (Exception)
static

Definition at line 436 of file Loop.cxx.

437 {
438  return type;
439 }
void Loop::releaseDelegateOf ( InPort *&  port,
OutPort initialStart,
const std::list< ComposedNode * > &  pointsOfView 
) throw (Exception)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 543 of file Loop.cxx.

References YACS::ENGINE::DataPort::getName(), YACS::ENGINE::InputPort::NAME, and YACS::ENGINE::OutputPort::NAME.

544 {
545  string typeOfPortInstance=port->getNameOfTypeOfCurrentInstance();
546  if(typeOfPortInstance!=InputPort::NAME ||
547  ( typeOfPortInstance == InputPort::NAME &&
550  return ;
551  InputPort *portCasted=(InputPort *)port;
552  set<DSToDFForLoop*>::iterator iter;
553  for(iter=_inputsTraducer.begin();iter!=_inputsTraducer.end();iter++)
554  if((*iter)->getOutputPort("")->isAlreadyInSet(portCasted))
555  break;
556  if(iter==_inputsTraducer.end())
557  {
558  string what("Loop::releaseDelegateOf Port with name "); what+=portCasted->getName(); what+=" not exported by loop "; what+=_name;
559  throw Exception(what);
560  }
561  else
562  {
563  port=(*iter)->getInputDataStreamPort("");
564  if((*iter)->loopHasOneLessRef())
565  {
566  (*iter)->getOutputPort("")->removeInPort(portCasted,false);
567  delete (*iter);
568  _inputsTraducer.erase(iter);
569  }
570  }
571 }
void Loop::releaseDelegateOf ( OutPort portDwn,
OutPort portUp,
InPort finalTarget,
const std::list< ComposedNode * > &  pointsOfView 
) throw (Exception)
protectedvirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Definition at line 573 of file Loop.cxx.

574 {
575  if(portDwn==portUp)
576  return ;
577  set<DFToDSForLoop*>::iterator iter;
578  for(iter=_outputsTraducer.begin();iter!=_outputsTraducer.end();iter++)
579  if((*iter)->getOutputDataStreamPort("")==portUp)
580  break;
581  if((*iter)->loopHasOneLessRef())
582  {
583  portDwn->removeInPort((*iter)->getInputPort(""),false);
584  delete (*iter);
585  _outputsTraducer.erase(iter);
586  }
587 }
virtual std::string YACS::ENGINE::Loop::typeName ( )
inlinevirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::ForLoop, and YACS::ENGINE::WhileLoop.

Definition at line 182 of file Loop.hxx.

182 {return "YACS__ENGINE__Loop";}
void Loop::writeDot ( std::ostream &  os) const
virtual

Dump the node state to a stream.

Parameters
os: the output stream

Reimplemented from YACS::ENGINE::Node.

Definition at line 638 of file Loop.cxx.

References _node, YACS::ENGINE::Node::getColorState(), YACS::ENGINE::Node::getEffectiveState(), YACS::ENGINE::Node::getId(), YACS::ENGINE::Node::getQualifiedName(), CORBAEngineTest::state, and YACS::ENGINE::Node::writeDot().

639 {
640  os << " subgraph cluster_" << getId() << " {\n" ;
641  //only one node in a loop
642  if(_node)
643  {
644  _node->writeDot(os);
645  os << getId() << " -> " << _node->getId() << ";\n";
646  }
647  os << "}\n" ;
648  os << getId() << "[fillcolor=\"" ;
650  os << getColorState(state);
651  os << "\" label=\"" << "Loop:" ;
652  os << getQualifiedName() <<"\"];\n";
653 }

Friends And Related Function Documentation

friend class DSToDFForLoop
friend

Definition at line 147 of file Loop.hxx.

Referenced by buildDelegateOf().

friend class FakeNodeForLoop
friend
void NbDoneLoader ( Loop node,
int  val 
)
friend

Member Data Documentation

std::set<DSToDFForLoop *> YACS::ENGINE::Loop::_inputsTraducer
protected

Definition at line 154 of file Loop.hxx.

Referenced by buildDelegateOf(), getReadyTasks(), and ~Loop().

FakeNodeForLoop* YACS::ENGINE::Loop::_nodeForNullTurnOfLoops
protected
std::set<DFToDSForLoop *> YACS::ENGINE::Loop::_outputsTraducer
protected

Definition at line 155 of file Loop.hxx.

Referenced by buildDelegateOf(), getReadyTasks(), and ~Loop().


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