1 // Copyright (C) 2006-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "DynParaLoop.hxx"
21 #include "LinkInfo.hxx"
22 #include "OutPort.hxx"
23 #include "Container.hxx"
24 #include "ComponentInstance.hxx"
25 #include "ServiceNode.hxx"
26 #include "InlineNode.hxx"
27 #include "ElementaryNode.hxx"
28 #include "Visitor.hxx"
34 #include "YacsTrace.hxx"
37 using namespace YACS::ENGINE;
39 const char DynParaLoop::NAME_OF_SPLITTED_SEQ_OUT[] = "evalSamples";
40 const char DynParaLoop::OLD_NAME_OF_SPLITTED_SEQ_OUT[] = "SmplPrt"; // For backward compatibility with 5.1.4
42 const char DynParaLoop::NAME_OF_NUMBER_OF_BRANCHES[]="nbBranches";
44 DynParaLoop::DynParaLoop(const std::string& name, TypeCode *typeOfDataSplitted)
45 : ComposedNode(name),_node(0),_initNode(0),_finalizeNode(0),_nbOfEltConsumed(0),
46 _nbOfBranches(NAME_OF_NUMBER_OF_BRANCHES,this,Runtime::_tc_int),
47 _splittedPort(NAME_OF_SPLITTED_SEQ_OUT,this,typeOfDataSplitted),_initializingCounter(0),_unfinishedCounter(0),_failedCounter(0)
51 DynParaLoop::~DynParaLoop()
58 DynParaLoop::DynParaLoop(const DynParaLoop& other, ComposedNode *father, bool editionOnly)
59 : ComposedNode(other,father), _nbOfBranches(other._nbOfBranches,this),
60 _splittedPort(other._splittedPort,this), _node(0), _initNode(0), _finalizeNode(0),
61 _nbOfEltConsumed(0),_initializingCounter(0),_unfinishedCounter(0),_failedCounter(0)
64 _node=other._node->clone(this,editionOnly);
66 _initNode=other._initNode->clone(this,editionOnly);
67 if(other._finalizeNode)
68 _finalizeNode = other._finalizeNode->clone(this,editionOnly);
69 const AnyOutputPort& startOfLinksToReproduce=other._splittedPort;
70 set<InPort *> endsOfLinksToReproduce=startOfLinksToReproduce.edSetInPort();
71 for(set<InPort *>::iterator iter=endsOfLinksToReproduce.begin();iter!=endsOfLinksToReproduce.end();iter++)
72 edAddLink(&_splittedPort,getInPort(other.getPortName(*iter)));
75 Node *DynParaLoop::edSetNode(Node *node)
77 return checkConsistencyAndSetNode(_node, node);
80 //! This method is used to factorize methods edSetNode, edSetInitNode and edSetFinalizeNode
81 Node * DynParaLoop::checkConsistencyAndSetNode(Node* &nodeToReplace, Node* node)
83 if (node == NULL || nodeToReplace == node)
86 throw Exception(string("Can't set node: node ") + node->getName() + " is not orphan.");
87 if (_node && _node != nodeToReplace && _node->getName() == node->getName())
88 throw Exception(string("Can't set node: node ") + node->getName() +
89 " has the same name than exec node already in " + _name + ".");
90 if (_initNode && _initNode != nodeToReplace && _initNode->getName() == node->getName())
91 throw Exception(string("Can't set node: node ") + node->getName() +
92 " has the same name than init node already in " + _name + ".");
93 if (_finalizeNode && _finalizeNode != nodeToReplace && _finalizeNode->getName() == node->getName())
94 throw Exception(string("Can't set node: node ") + node->getName() +
95 " has the same name than finalize node already in " + _name + ".");
96 checkNoCrossHierachyWith(node);
97 ComposedNode::edRemoveChild(nodeToReplace);
98 Node * ret = nodeToReplace;
100 nodeToReplace->_father = this;
101 // set _modified flag so that edUpdateState can refresh state
106 void DynParaLoop::init(bool start)
108 ComposedNode::init(start);
111 string what("DynParaLoop::init : no node specified for ForEachLoop with name "); what +=_name;
112 throw Exception(what);
115 if (_initNode) _initNode->init(start);
116 if (_finalizeNode) _finalizeNode->init(start);
117 _nbOfBranches.exInit(start);
118 _splittedPort.exInit();
123 Node *DynParaLoop::edSetInitNode(Node *node)
125 return checkConsistencyAndSetNode(_initNode, node);
128 Node * DynParaLoop::edSetFinalizeNode(Node * node)
130 return checkConsistencyAndSetNode(_finalizeNode, node);
133 //! Connect an OutPort to an InPort and add control link if necessary
135 * Connect the ports with a data link (edAddLink)
136 * In a Loop don't add control flow link : use this only to add data back links
138 * \param start : the OutPort to connect
139 * \param end : the InPort to connect
140 * \return true if a new link has been created, false otherwise.
142 bool DynParaLoop::edAddDFLink(OutPort *start, InPort *end) throw(YACS::Exception)
144 return edAddLink(start,end);
147 int DynParaLoop::getNumberOfInputPorts() const
149 return ComposedNode::getNumberOfInputPorts()+1;
152 int DynParaLoop::getNumberOfOutputPorts() const
154 return ComposedNode::getNumberOfOutputPorts()+1;
157 std::list<OutputPort *> DynParaLoop::getSetOfOutputPort() const
159 list<OutputPort *> ret=ComposedNode::getSetOfOutputPort();
160 ret.push_back((OutputPort *)&_splittedPort);
164 std::list<OutputPort *> DynParaLoop::getLocalOutputPorts() const
166 list<OutputPort *> ret=ComposedNode::getLocalOutputPorts();
167 ret.push_back((OutputPort *)&_splittedPort);
171 OutPort *DynParaLoop::getOutPort(const std::string& name) const throw(YACS::Exception)
173 if (name == NAME_OF_SPLITTED_SEQ_OUT || name == OLD_NAME_OF_SPLITTED_SEQ_OUT)
174 return (OutPort *)&_splittedPort;
175 return ComposedNode::getOutPort(name);
179 OutputPort *DynParaLoop::getOutputPort(const std::string& name) const throw(YACS::Exception)
181 if (name == NAME_OF_SPLITTED_SEQ_OUT || name == OLD_NAME_OF_SPLITTED_SEQ_OUT)
182 return (OutputPort *)&_splittedPort;
183 return ComposedNode::getOutputPort(name);
186 bool DynParaLoop::isPlacementPredictableB4Run() const
191 Node *DynParaLoop::edRemoveNode()
193 return removeNode(_node);
196 //! This method is used to factorize methods edRemoveNode, edRemoveInitNode and edRemoveFinalizeNode
197 Node * DynParaLoop::removeNode(Node* &nodeToRemove)
201 ComposedNode::edRemoveChild(nodeToRemove);
202 Node * ret = nodeToRemove;
208 Node *DynParaLoop::edRemoveInitNode()
210 return removeNode(_initNode);
213 Node * DynParaLoop::edRemoveFinalizeNode()
215 return removeNode(_finalizeNode);
218 void DynParaLoop::edRemoveChild(Node *node) throw(YACS::Exception)
220 ComposedNode::edRemoveChild(node);
225 if(node==_finalizeNode)
230 bool DynParaLoop::edAddChild(Node *DISOWNnode) throw(YACS::Exception)
232 return edSetNode(DISOWNnode);
235 std::list<Node *> DynParaLoop::edGetDirectDescendants() const
239 ret.push_back(_node);
241 ret.push_back(_initNode);
243 ret.push_back(_finalizeNode);
247 std::list<InputPort *> DynParaLoop::getSetOfInputPort() const
249 list<InputPort *> ret=ComposedNode::getSetOfInputPort();
250 ret.push_back((InputPort *)&_nbOfBranches);
254 InputPort *DynParaLoop::getInputPort(const std::string& name) const throw(YACS::Exception)
256 if(name==NAME_OF_NUMBER_OF_BRANCHES)
257 return (InputPort *)&_nbOfBranches;
258 return ComposedNode::getInputPort(name);
261 std::list<InputPort *> DynParaLoop::getLocalInputPorts() const
263 list<InputPort *> ret=ComposedNode::getLocalInputPorts();
264 ret.push_back((InputPort *)&_nbOfBranches);
268 unsigned DynParaLoop::getNumberOfBranchesCreatedDyn() const throw(YACS::Exception)
270 if(_execNodes.empty())
271 throw Exception("ForEachLoop::getNumberOfBranches : No branches created dynamically ! - ForEachLoop needs to run or to be runned to call getNumberOfBranches");
273 return _execNodes.size();
276 Node *DynParaLoop::getChildByShortName(const std::string& name) const throw(YACS::Exception)
278 if (_node && name == _node->getName())
280 if (_initNode && name == _initNode->getName())
282 if (_finalizeNode && name == _finalizeNode->getName())
283 return _finalizeNode;
284 std::string what("node "); what+= name ; what+=" is not a child of DynParaLoop node "; what += getName();
285 throw Exception(what);
288 Node *DynParaLoop::getChildByNameExec(const std::string& name, unsigned id) const throw(YACS::Exception)
290 if(id>=getNumberOfBranchesCreatedDyn())
291 throw Exception("ForEachLoop::getChildByNameExec : invalid id - too large compared with dynamically created branches.");
292 if (_node && name == _node->getName())
293 return _execNodes[id];
294 if (_initNode && name == _initNode->getName())
295 return _execInitNodes[id];
296 if (_finalizeNode && name == _finalizeNode->getName())
297 return _execFinalizeNodes[id];
298 std::string what("node "); what+= name ; what+=" is not a child of DynParaLoop node "; what += getName();
299 throw Exception(what);
302 void DynParaLoop::cleanDynGraph()
304 vector<Node *>::iterator iter;
305 for(iter=_execNodes.begin() ; iter!=_execNodes.end() ; iter++)
308 for(iter=_execInitNodes.begin() ; iter!=_execInitNodes.end() ; iter++)
310 _execInitNodes.clear();
311 for(iter=_execFinalizeNodes.begin() ; iter!=_execFinalizeNodes.end() ; iter++)
313 _execFinalizeNodes.clear();
317 * This method applies on newly cloned on exec nodes (_execNodes/_execInitNodes)
318 * the setting of input ports coming from outside of 'this'
320 void DynParaLoop::prepareInputsFromOutOfScope(int branchNb)
322 set< InPort * > portsToSetVals=getAllInPortsComingFromOutsideOfCurrentScope();
324 // This tweak is to fix problems with nested dynamic loops where links are not cloned properly
325 list<InPort *> temp = getSetOfInPort();
326 for(list<InPort *>::iterator iter2=temp.begin();iter2!=temp.end();iter2++)
328 if ((*iter2)->edSetOutPort().size() == 1 && *(*iter2)->edSetOutPort().begin() == NULL)
330 portsToSetVals.insert(*iter2);
334 // local input ports are not candidates for dynamically duplicated inport.
335 list<InputPort *> localPorts = getLocalInputPorts();
336 for(list<InputPort *>::iterator iter = localPorts.begin() ; iter != localPorts.end() ; iter++)
337 portsToSetVals.erase(*iter);
338 for(set< InPort * >::iterator iter=portsToSetVals.begin();iter!=portsToSetVals.end();iter++)
340 InputPort *curPortCasted=(InputPort *) *iter;//Cast granted by ForEachLoop::buildDelegateOf(InPort)
341 void *val=curPortCasted->get();
342 InputPort *portToSet=getDynInputPortByAbsName(branchNb,getInPortName(*iter),true);
343 if(portToSet)//portToSet==0 in case of portToSet==_splitterNode._dataPortToDispatch of ForEach
345 portToSet->put((const void *)val);
346 portToSet->edNotifyReferencedBy(0);//This is to indicate that somewhere somebody deals with this inputport
347 //even if no direct physical link exists. This exclusively for _execNodes[branchNb]::init on the next turn of loop.
352 void DynParaLoop::putValueOnBranch(Any *val, unsigned branchId, bool first)
354 bool isDispatched = false;
355 set<InPort *> inPrtLkdWthSplttdPrt=_splittedPort.edSetInPort();
356 for(set<InPort *>::iterator iter=inPrtLkdWthSplttdPrt.begin();iter!=inPrtLkdWthSplttdPrt.end();iter++)
358 std::string portNameOnCurPrt=getPortName(*iter);
359 InputPort *portOnGivenBranch=getDynInputPortByAbsName(branchId,portNameOnCurPrt,first);//Cast granted because impossible to have cross protocol with _splittedPort
360 //see OptimizerLoop::buildDelegateOf
361 if(portOnGivenBranch)
364 portOnGivenBranch->edNotifyReferencedBy(0);
365 InputPort *traducer=getRuntime()->adapt(portOnGivenBranch,
366 Runtime::RUNTIME_ENGINE_INTERACTION_IMPL_NAME,_splittedPort.edGetType());
367 traducer->put((const void *)val);
369 if(traducer!=portOnGivenBranch)
375 Any *tmp=val->clone();
376 _splittedPort.setValue(tmp);
381 DynParaLoop::TypeOfNode DynParaLoop::getIdentityOfNotifyerNode(const Node *node, unsigned& id)
383 vector<Node *>::iterator iter;
385 for (iter=_execNodes.begin() ; iter!=_execNodes.end() ; iter++,id++)
389 for (iter=_execInitNodes.begin() ; iter!=_execInitNodes.end() ; iter++,id++)
393 for (iter=_execFinalizeNodes.begin() ; iter!=_execFinalizeNodes.end() ; iter++,id++)
395 return FINALIZE_NODE;
398 bool DynParaLoop::isMultiplicitySpecified(unsigned& value) const
400 if(_nbOfBranches.edIsManuallyInitialized())
401 if(_nbOfBranches.edGetNumberOfLinks()==0)
403 value=_nbOfBranches.getIntValue();
409 void DynParaLoop::forceMultiplicity(unsigned value)
411 _nbOfBranches.edRemoveAllLinksLinkedWithMe();
412 _nbOfBranches.edInit((int)value);
415 void DynParaLoop::buildDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView)
417 string typeOfPortInstance=port->getNameOfTypeOfCurrentInstance();
418 if(typeOfPortInstance!=InputPort::NAME)
419 throw Exception("DynParaLoop::buildDelegateOf : A link with datastream end inside DynParaLoop this is not possible");
422 void DynParaLoop::buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
425 if(isInMyDescendance(port.first->getNode())==_initNode)
426 throw Exception("DynParaLoop::buildDelegateOf : uncorrect ForEach link : a link starting from init node can't leave the scope of ForEachLoop node it belongs to.");
427 if(port.first==&_splittedPort)
428 throw Exception("DynParaLoop::buildDelegateOf : uncorrect ForEach link : splitted port must be link within the scope of ForEachLoop node it belongs to.");
431 void DynParaLoop::checkCFLinks(const std::list<OutPort *>& starts, InputPort *end, unsigned char& alreadyFed, bool direction, LinkInfo& info) const
433 const char what[]="DynParaLoop::checkCFLinks : internal error.";
434 //First dealing checkCFLinks forwarding...
435 if(isInMyDescendance(end->getNode())==0)//no chance that _splittedPort is in starts due to buildDelegate.
436 solveObviousOrDelegateCFLinks(starts,end,alreadyFed,direction,info);
438 {//no forwarding here.
440 throw Exception(what);
441 //ASSERT(direction) : see DynParaLoop::checkControlDependancy only 'fw' filled.
442 if(*(starts.begin())!=&_splittedPort)
443 throw Exception(what);
444 if(alreadyFed==FREE_ST)
446 else if(alreadyFed==FED_ST)
447 {//Shame ! splittedPort fills a port already fed...
448 info.pushInfoLink(*(starts.begin()),end,I_USELESS);
454 * \param start : start port
455 * \param end : end port
456 * \param cross indicates if start -> end link is a DS link behind.
457 * \param fw out parameter.
458 * \param fwCross out parameter storing links where a cross has been detected.
459 * \param bw out parameter where backward links are stored.
460 * \param info : collected information
462 void DynParaLoop::checkControlDependancy(OutPort *start, InPort *end, bool cross,
463 std::map < ComposedNode *, std::list < OutPort * >, SortHierarc >& fw,
464 std::vector<OutPort *>& fwCross,
465 std::map< ComposedNode *, std::list < OutPort *>, SortHierarc >& bw,
466 LinkInfo& info) const
468 if(start==&_splittedPort)
469 fw[(ComposedNode *)this].push_back(start);
471 throw Exception("DynParaLoop::checkControlDependancy : Internal error occured - should never been called !");
475 * \note : For a given name 'name' of port in absolute form from this, returns the corresponding InputPort
476 * instance of the port for the branch # 'branchNb'.
477 * The port can be part of _node or _initNode if it exists (if 'initNodeAdmitted' is true).
478 * \b WARNING : no check performed on 'branchNb' value to see if it is compatible with size of '_execNodes'.
479 * This method is called to dispatch value on each InputPort linked to this->._splitterNode._splittedPort
481 InputPort *DynParaLoop::getDynInputPortByAbsName(int branchNb, const std::string& name, bool initNodeAdmitted)
483 string portName, nodeName;
484 splitNamesBySep(name,Node::SEP_CHAR_IN_PORT,nodeName,portName,true);
485 Node *staticChild = getChildByName(nodeName);
486 Node *desc=isInMyDescendance(staticChild);
489 splitNamesBySep(name,Node::SEP_CHAR_IN_PORT,nodeName,portName,false);
490 return _execNodes[branchNb]->getInputPort(portName);
492 else if(desc==_initNode)
495 splitNamesBySep(name,Node::SEP_CHAR_IN_PORT,nodeName,portName,false);
496 return _execInitNodes[branchNb]->getInputPort(portName);
501 void DynParaLoop::checkBasicConsistency() const throw(YACS::Exception)
503 DEBTRACE("DynParaLoop::checkBasicConsistency");
504 ComposedNode::checkBasicConsistency();
506 throw Exception("For a dynamic loop, internal node is mandatory");
509 std::string DynParaLoop::getErrorReport()
511 DEBTRACE("DynParaLoop::getErrorReport: " << getName() << " " << _state);
512 YACS::StatesForNode effectiveState=getEffectiveState();
514 if(effectiveState != YACS::INVALID && effectiveState != YACS::ERROR && effectiveState != YACS::FAILED)
517 std::string report="<error node= " + getName();
518 switch(effectiveState)
521 report=report+" state= INVALID";
524 report=report+" state= ERROR";
527 report=report+" state= FAILED";
532 report=report + ">\n" ;
533 if(_errorDetails != "")
534 report=report+_errorDetails+"\n";
536 if(_execNodes.empty())
539 list<Node *> constituents=edGetDirectDescendants();
540 for(list<Node *>::iterator iter=constituents.begin(); iter!=constituents.end(); iter++)
542 std::string rep=(*iter)->getErrorReport();
545 report=report+rep+"\n";
552 for(vector<Node *>::iterator iter=_execInitNodes.begin();iter!=_execInitNodes.end();iter++)
554 std::string rep=(*iter)->getErrorReport();
557 report=report+rep+"\n";
560 for(vector<Node *>::iterator iter=_execNodes.begin();iter!=_execNodes.end();iter++)
562 std::string rep=(*iter)->getErrorReport();
565 report=report+rep+"\n";
568 for(vector<Node *>::iterator iter=_execFinalizeNodes.begin();iter!=_execFinalizeNodes.end();iter++)
570 std::string rep=(*iter)->getErrorReport();
573 report=report+rep+"\n";
578 report=report+"</error>";
582 void DynParaLoop::forwardExecStateToOriginalBody(Node *execNode)
585 Node * origNode = NULL;
586 switch (getIdentityOfNotifyerNode(execNode,id))
590 origNode = _initNode;
600 origNode = _finalizeNode;
607 YASSERT(origNode != NULL)
608 origNode->setState(execNode->getState());
609 origNode->setErrorDetails(execNode->getErrorDetails());
611 ComposedNode* compNode = dynamic_cast<ComposedNode*>(origNode);
612 ComposedNode* compNodeExe = dynamic_cast<ComposedNode*>(execNode);
613 if (compNode && compNodeExe)
615 list<Node *> aChldn = compNodeExe->getAllRecursiveConstituents();
616 list<Node *>::iterator iter=aChldn.begin();
617 for(;iter!=aChldn.end();iter++)
619 Node* node=compNode->getChildByName(compNodeExe->getChildName(*iter));
620 node->setState((*iter)->getState());
621 node->setErrorDetails((*iter)->getErrorDetails());
626 //! Method used to notify the node that a child node has failed
628 * Update the current state and return the change state
630 * \param node : the child node that has failed
631 * \return the state change
633 YACS::Event DynParaLoop::updateStateOnFailedEventFrom(Node *node, const Executor *execInst)
635 DEBTRACE("DynParaLoop::updateStateOnFailedEventFrom " << node->getName());
636 setState(YACS::FAILED);
637 forwardExecStateToOriginalBody(node);
639 switch (getIdentityOfNotifyerNode(node,id))
643 _node->setState(YACS::FAILED);
644 if (_finalizeNode != NULL) _finalizeNode->setState(YACS::FAILED);
649 if (_finalizeNode != NULL) _finalizeNode->setState(YACS::FAILED);
656 //! Clone nodes and make their placement consistent with the placement of the original ones.
658 * For instance, if two original nodes are placed on a component comp1 in a container cont1
659 * and a third one is placed on a component comp2 in the container cont1, the clones of the two
660 * first nodes will be placed on a component comp3 in a container cont2 and the third clone
661 * will be placed on a component comp4 in the container cont2.
663 vector<Node *> DynParaLoop::cloneAndPlaceNodesCoherently(const vector<Node *> & origNodes)
665 DEBTRACE("Begin cloneAndPlaceNodesCoherently")
666 vector<Node *> clones;
667 DeploymentTree treeToDup;
668 vector<list<ElementaryNode *> > origElemNodeList;
669 for (int i=0 ; i<origNodes.size() ; i++)
671 DEBTRACE("Cloning node " << i)
672 if (origNodes[i] == NULL)
674 DEBTRACE("Cloning node " << i << ", NULL" )
675 clones.push_back(NULL);
676 origElemNodeList.push_back(list<ElementaryNode *>());
680 DEBTRACE("Cloning node " << i << "," << origNodes[i]->getName())
681 clones.push_back(origNodes[i]->simpleClone(this, false));
682 list<ElementaryNode *> tasks = origNodes[i]->getRecursiveConstituents();
683 origElemNodeList.push_back(tasks);
684 for (list< ElementaryNode *>::iterator iter=tasks.begin() ; iter!=tasks.end() ; iter++)
685 treeToDup.appendTask(*iter, (*iter)->getDynClonerIfExists(this));
689 DEBTRACE("Placing nodes...")
690 vector<Container *> conts=treeToDup.getAllContainers();
692 //iterate on all containers
693 for(vector<Container *>::iterator iterCt=conts.begin();iterCt!=conts.end();iterCt++)
695 DEBTRACE("Container " << ((*iterCt)?(*iterCt)->getName():"NULL"))
696 vector<ComponentInstance *> comps=treeToDup.getComponentsLinkedToContainer(*iterCt);
697 Container *contCloned=0;
699 contCloned=(*iterCt)->clone();
701 //iterate on all component instances linked to the container
702 for(vector<ComponentInstance *>::iterator iterCp=comps.begin();iterCp!=comps.end();iterCp++)
704 DEBTRACE("Component " << (*iterCp)->getCompoName())
705 vector<Task *> tasks=treeToDup.getTasksLinkedToComponent(*iterCp);
706 ComponentInstance *curCloned=(*iterCp)->clone();
707 DEBTRACE("Assign container " << (*iterCp)->getCompoName())
708 curCloned->setContainer(contCloned);
709 for(vector<Task *>::iterator iterT=tasks.begin();iterT!=tasks.end();iterT++)
711 DEBTRACE("Task " << ((ElementaryNode *)(*iterT))->getName())
713 ElementaryNode * origElemNode = NULL;
714 for (i=0 ; i<origNodes.size() ; i++)
715 if (origNodes[i] != NULL)
717 DEBTRACE("Looking in original node " << i)
718 list<ElementaryNode *>::iterator res=find(origElemNodeList[i].begin(),
719 origElemNodeList[i].end(),
720 (ElementaryNode *)(*iterT));
721 if (res != origElemNodeList[i].end()) {
727 YASSERT(origElemNode != NULL)
728 DEBTRACE("Found task in node " << i)
729 ServiceNode * nodeC = NULL;
730 if (origNodes[i] == origElemNode)
731 nodeC = (ServiceNode *)clones[i];
734 string childName = ((ComposedNode *)origNodes[i])->getChildName(origElemNode);
735 nodeC = (ServiceNode *)clones[i]->getChildByName(childName);
737 DEBTRACE("Assign component: " << (*iterCp)->getCompoName() << "," << nodeC->getName())
738 nodeC->setComponent(curCloned);
740 curCloned->decrRef();
743 // iterate on all tasks linked to the container
744 vector<Task *> tasks=treeToDup.getTasksLinkedToContainer(*iterCt);
745 for(vector<Task *>::iterator iterT=tasks.begin();iterT!=tasks.end();iterT++)
747 DEBTRACE("Task " << ((ElementaryNode *)(*iterT))->getName())
749 ElementaryNode * origElemNode = NULL;
750 for (i=0 ; i<origNodes.size() ; i++)
751 if (origNodes[i] != NULL)
753 DEBTRACE("Looking in original node " << i)
754 list<ElementaryNode *>::iterator res=find(origElemNodeList[i].begin(),
755 origElemNodeList[i].end(),
756 (ElementaryNode *)(*iterT));
757 if (res != origElemNodeList[i].end())
763 YASSERT(origElemNode != NULL)
764 DEBTRACE("Found task in node " << i)
765 InlineFuncNode * nodeC = NULL;
766 if (origNodes[i] == origElemNode)
768 nodeC = (InlineFuncNode *)clones[i];
772 string childName = ((ComposedNode *)origNodes[i])->getChildName(origElemNode);
773 nodeC = (InlineFuncNode *)clones[i]->getChildByName(childName);
775 DEBTRACE("Assign container " << nodeC->getName() << "," << contCloned->getName())
776 nodeC->setContainer(contCloned);
779 // ended with current container
781 contCloned->decrRef();
784 DEBTRACE("End cloneAndPlaceNodesCoherently")
788 void DynParaLoop::accept(Visitor *visitor)
790 visitor->visitDynParaLoop(this);
793 Node * DynParaLoop::getInitNode()
798 Node * DynParaLoop::getExecNode()
803 Node * DynParaLoop::getFinalizeNode()
805 return _finalizeNode;
808 void DynParaLoop::shutdown(int level)
813 std::vector<Node *>::iterator iter;
814 for (iter=_execNodes.begin() ; iter!=_execNodes.end() ; iter++)
815 (*iter)->shutdown(level);
816 for (iter=_execInitNodes.begin() ; iter!=_execInitNodes.end() ; iter++)
817 (*iter)->shutdown(level);
818 for (iter=_execFinalizeNodes.begin() ; iter!=_execFinalizeNodes.end() ; iter++)
819 (*iter)->shutdown(level);