37 using namespace YACS::ENGINE;
48 for(list<Node *>::const_iterator iter=other.
_setOfNode.begin();iter!=other.
_setOfNode.end();iter++)
49 _setOfNode.push_back((*iter)->simpleClone(
this,editionOnly));
53 vector< pair<OutGate *, InGate *> >::iterator iter1=cfLinksToReproduce.begin();
54 for(;iter1!=cfLinksToReproduce.end();iter1++)
59 vector< pair<OutPort *, InPort *> >::iterator iter2=linksToReproduce.begin();
60 for(;iter2!=linksToReproduce.end();iter2++)
63 InPort* pin = iter2->second;
118 ret+=(*iter)->getOutGate()->getNbOfInGatesConnected();
124 return new Bloc(*
this,father,editionOnly);
141 (*iter)->getReadyTasks(tasks);
159 if((*iter)->exIsControlReady())
160 (*iter)->exUpdateState();
176 if(isNodeAlreadyAggregated(node))
178 if(node->_father==
this)
182 string what =
"Bloc::edAddChild : node "; what += node->getName();
183 what +=
" is already grand children of node";
190 string what =
"Bloc::edAddChild: node is not orphan: "; what += node->getName();
194 checkNoCrossHierachyWith(node);
196 if(isNameAlreadyUsed(node->getName()))
198 string what(
"Bloc::edAddChild : name "); what+=node->getName();
199 what+=
" already exists in the scope of "; what+=_name;
204 _setOfNode.push_back(node);
221 list<Node *>::iterator iter=find(_setOfNode.begin(),_setOfNode.end(),node);
222 if(iter!=_setOfNode.end())
224 _setOfNode.erase(iter);
232 list<Node *>::const_iterator it=
_setOfNode.begin();
234 (*it)->_colour=
White;
236 std::vector< list<Node *> >
ret;
240 ret.push_back(list<Node *>());
241 list<Node *>& ll(ret.back());
242 std::queue<Node *> fifo; fifo.push(start);
245 Node *cur(fifo.front()); fifo.pop();
248 OutGate *og(cur->getOutGate());
249 list<InGate *> og2(og->edSetInGate());
250 for(list<InGate *>::const_iterator it2=og2.begin();it2!=og2.end();it2++)
252 Node *cur2((*it2)->getNode());
253 if(cur2->_colour==
White)
260 InGate *ig(cur->getInGate());
261 list<OutGate *> bl(ig->getBackLinks());
262 for(list<OutGate *>::const_iterator it3=bl.begin();it3!=bl.end();it3++)
264 Node *cur3((*it3)->getNode());
265 if(cur3->_colour==
White)
279 for (list<Node *>::const_iterator iter = _setOfNode.begin(); iter != _setOfNode.end(); iter++)
280 if ((*iter)->getName() == name)
282 string what(
"node "); what+= name ; what+=
" is not a child of Bloc "; what += getName();
314 if((*iter)->getName()==name)
323 for (list<Node *>::iterator iter=outNodes.begin();iter!=outNodes.end(); iter++)
325 verdict=(nodeSet.insert(*iter)).second;
338 set<Node *> currentNodesToTest;
344 if(!(currentNodesToTest.insert(node)).second)
345 throw Exception(
"Cycle has been detected",1);
350 vector< pair<OutGate *, InGate *> >
ret;
353 list<InGate *> outCFLinksOfCurNode=(*iter)->_outGate.edSetInGate();
354 for(list<InGate *>::iterator iter2=outCFLinksOfCurNode.begin();iter2!=outCFLinksOfCurNode.end();iter2++)
355 ret.push_back(pair<OutGate *, InGate *>(&(*iter)->_outGate,*iter2));
392 DEBTRACE(
"Bloc::updateStateOnFinishedEventFrom: " << ex.
what());
423 os <<
" subgraph cluster_" <<
getId() <<
" {\n" ;
425 for(list<Node *>::const_iterator iter=nodes.begin();iter!=nodes.end();iter++)
427 (*iter)->writeDot(os);
428 string p=(*iter)->
getId();
430 if((*iter)->_inGate._backLinks.size() == 0) os <<
getId() <<
" -> " << p <<
";\n";
431 list<Node *>outnodes = (*iter)->getOutNodes();
432 for(list<Node *>::const_iterator itout=outnodes.begin();itout!=outnodes.end();itout++)
434 os << p <<
" -> " << (*itout)->getId() <<
";\n";
438 os <<
getId() <<
"[fillcolor=\"" ;
441 os <<
"\" label=\"" <<
"Bloc:" ;
458 for(std::vector< std::list<Node *> >::const_iterator it=r.begin();it!=r.end();it++)
474 for(std::set< std::pair<Node *, Node *> >::const_iterator it=linksToKill.begin();it!=linksToKill.end();it++)
483 _fwLinks=
new map<Node *,set<Node *> >;
484 _bwLinks=
new map<Node *,set<Node *> >;
487 std::set< std::pair< Node*, Node* > > links;
493 for(std::list<InGate *>::const_iterator it2=ingates.begin();it2!=ingates.end();it2++)
496 Node* n2=(*it2)->getNode();
497 links.insert(std::pair< Node*, Node* >(n1,n2));
498 std::set<Node *> bwn1=(*_bwLinks)[n1];
499 std::set<Node *> fwn1=(*_fwLinks)[n1];
500 std::set<Node *> fwn2=(*_fwLinks)[n2];
501 std::set<Node *> bwn2=(*_bwLinks)[n2];
502 std::pair<std::set<Node*>::iterator,
bool>
ret;
503 for(std::set<Node *>::const_iterator iter2=bwn1.begin();iter2!=bwn1.end();iter2++)
505 for(std::set<Node *>::const_iterator it3=fwn2.begin();it3!=fwn2.end();it3++)
507 ret=(*_fwLinks)[*iter2].insert(*it3);
508 if(ret.second==
false)
511 if(links.find(std::pair< Node*, Node* >(*iter2,*it3)) != links.end())
515 ret=(*_fwLinks)[*iter2].insert(n2);
516 if(ret.second==
false)
519 if(links.find(std::pair< Node*, Node* >(*iter2,n2)) != links.end())
523 for(std::set<Node *>::const_iterator it3=fwn2.begin();it3!=fwn2.end();it3++)
525 ret=(*_fwLinks)[n1].insert(*it3);
526 if(ret.second==
false)
529 if(links.find(std::pair< Node*, Node* >(n1,*it3)) != links.end())
533 ret=(*_fwLinks)[n1].insert(n2);
534 if(ret.second==
false)
540 for(std::set<Node *>::const_iterator iter2=fwn2.begin();iter2!=fwn2.end();iter2++)
542 (*_bwLinks)[*iter2].insert(bwn1.begin(),bwn1.end());
543 (*_bwLinks)[*iter2].insert(n1);
545 (*_bwLinks)[n2].insert(bwn1.begin(),bwn1.end());
546 (*_bwLinks)[n2].insert(n1);
591 std::vector<OutPort *>& fwCross,
611 fwCross.push_back(start);
627 set<Node *>& nexts=fw ? (*_fwLinks)[start] : (*_bwLinks)[start];
628 return nexts.find(end)!=nexts.end();
641 set<Node *>& nexts=(*_fwLinks)[start];
642 set<Node *>& preds=(*_bwLinks)[start];
643 return nexts.find(end)==nexts.end() && preds.find(end)==preds.end();
658 map<Node *,list <OutPort *> > classPerNodes;
659 for(list< OutPort *>::const_iterator iter1=starts.begin();iter1!=starts.end();iter1++)
661 set<Node *> allNodes;
662 for(map<
Node *,list <OutPort *> >::iterator iter2=classPerNodes.begin();iter2!=classPerNodes.end();iter2++)
663 allNodes.insert((*iter2).first);
664 vector<Node *> okAndUseless1,useless2;
672 for(list< OutPort *>::const_iterator iter1=starts.begin();iter1!=starts.end();iter1++)
680 (*iter)->_colour=
White;
681 (*iter)->getInGate()->exReset();
682 (*iter)->getOutGate()->exReset();
696 const std::vector<Node *>& candidates,
unsigned char& alreadyFed,
699 for(vector<Node *>::const_iterator iter=candidates.begin();iter!=candidates.end();iter++)
701 const list<OutPort *>& mySet=(*pool.find(*iter)).second;
710 else if(alreadyFed==
FED_ST)
715 if(dynamic_cast<ElementaryNode *>(*iter))
720 else if(alreadyFed==
FED_ST)
722 for(list<OutPort *>::const_iterator iter2=mySet.begin();iter2!=mySet.end();iter2++)
726 ((
ComposedNode *)(*iter))->checkCFLinks(mySet,end,alreadyFed,direction,info);
741 const std::set<Node *>& candidates,
unsigned char& alreadyFed,
745 for(set<Node *>::const_iterator iter=candidates.begin();iter!=candidates.end();iter++)
747 const list<OutPort *>& mySet=(*pool.find(*iter)).second;
752 else if(alreadyFed==
FED_ST)
757 if(dynamic_cast<ElementaryNode *>(*iter))
762 else if(alreadyFed==
FED_ST)
764 for(list<OutPort *>::const_iterator iter2=mySet.begin();iter2!=mySet.end();iter2++)
773 else if(alreadyFed==
FED_ST)
775 for(list<OutPort *>::const_iterator iter2=mySet.begin();iter2!=mySet.end();iter2++)
780 if(!candidates.empty())
793 set<Node *>::iterator iter=allNodes.begin();
794 while(iter!=allNodes.end())
796 set<Node *>& whereToFind=(*_bwLinks)[*iter];
797 std::set<Node *>::iterator iter2;
798 for(iter2=allNodes.begin();iter2!=allNodes.end();iter2++)
799 if((*iter)!=(*iter2))
800 if(whereToFind.find(*iter2)==whereToFind.end())
802 if(iter2!=allNodes.end())
806 okAndUseless1.push_back((*iter));
807 allNodes.erase(iter);
808 iter=allNodes.begin();
819 set<Node *>::iterator iter=allNodes.begin();
820 while(iter!=allNodes.end())
822 set<Node *>& whereToFind=(*_fwLinks)[*iter];
823 std::set<Node *>::iterator iter2;
824 for(iter2=allNodes.begin();iter2!=allNodes.end();iter2++)
825 if((*iter)!=(*iter2))
826 if(whereToFind.find(*iter2)==whereToFind.end())
828 if(iter2!=allNodes.end())
834 useless2.push_back((*iter));
835 allNodes.erase(iter);
836 iter=allNodes.begin();
848 vector<Node *>::const_iterator iter=path.begin(); iter++;
849 vector<Node *>::const_iterator iter2=path.end(); iter2-=1;
850 for(;iter!=iter2;iter++)
851 fastFinder[*iter].insert(*(iter+1));
861 list< vector<Node *> >::const_iterator whereToPeerAt;
862 for(list< vector<Node *> >::const_iterator iter=res.begin();iter!=res.end();iter++)
863 if((*iter).size()>maxSize)
865 maxSize=(*iter).size();
871 vector<Node *>::const_iterator iter2=(*whereToPeerAt).begin();
872 map<Node *,bool>::iterator iter4;
873 set<Node *> searcher(iter2+1,(*whereToPeerAt).end());
874 for(;iter2!=((*whereToPeerAt).end()-2);iter2++)
876 list< pair<InGate *,bool> >& nexts=(*iter2)->getOutGate()->edMapInGate();
877 for(list< pair<InGate *,bool> >::iterator iter4=nexts.begin();iter4!=nexts.end();iter4++)
878 if((*iter4).first->getNode()!=*(iter2+1))
879 if(searcher.find((*iter4).first->getNode())!=searcher.end())
881 searcher.erase(*iter2);