50 for(list<Node *>::const_iterator iter=other.
_setOfNode.begin();iter!=other.
_setOfNode.end();iter++)
51 _setOfNode.push_back((*iter)->simpleClone(
this,editionOnly));
55 vector< pair<OutGate *, InGate *> >::iterator iter1=cfLinksToReproduce.begin();
56 for(;iter1!=cfLinksToReproduce.end();iter1++)
61 vector< pair<OutPort *, InPort *> >::iterator iter2=linksToReproduce.begin();
62 for(;iter2!=linksToReproduce.end();iter2++)
65 InPort* pin = iter2->second;
120 ret+=(*iter)->getOutGate()->getNbOfInGatesConnected();
126 return new Bloc(*
this,father,editionOnly);
143 (*iter)->getReadyTasks(tasks);
161 if((*iter)->exIsControlReady())
162 (*iter)->exUpdateState();
184 string what =
"Bloc::edAddChild : node "; what += node->
getName();
185 what +=
" is already grand children of node";
192 string what =
"Bloc::edAddChild: node is not orphan: "; what += node->
getName();
200 string what(
"Bloc::edAddChild : name "); what+=node->
getName();
201 what+=
" already exists in the scope of "; what+=
_name;
234 list<Node *>::const_iterator it=
_setOfNode.begin();
236 (*it)->_colour=
White;
238 std::vector< list<Node *> > ret;
242 ret.push_back(list<Node *>());
243 list<Node *>& ll(ret.back());
244 std::queue<Node *> fifo; fifo.push(start);
247 Node *cur(fifo.front()); fifo.pop();
252 for(list<InGate *>::const_iterator it2=og2.begin();it2!=og2.end();it2++)
254 Node *cur2((*it2)->getNode());
264 for(list<OutGate *>::const_iterator it3=bl.begin();it3!=bl.end();it3++)
266 Node *cur3((*it3)->getNode());
282 if ((*iter)->getName() == name)
284 string what(
"node "); what+= name ; what+=
" is not a child of Bloc "; what +=
getName();
316 if((*iter)->getName()==name)
325 for (list<Node *>::iterator iter=outNodes.begin();iter!=outNodes.end(); iter++)
327 verdict=(nodeSet.insert(*iter)).second;
340 set<Node *> currentNodesToTest;
346 if(!(currentNodesToTest.insert(node)).second)
347 throw Exception(
"Cycle has been detected",1);
352 vector< pair<OutGate *, InGate *> > ret;
355 list<InGate *> outCFLinksOfCurNode=(*iter)->_outGate.edSetInGate();
356 for(list<InGate *>::iterator iter2=outCFLinksOfCurNode.begin();iter2!=outCFLinksOfCurNode.end();iter2++)
357 ret.push_back(pair<OutGate *, InGate *>(&(*iter)->_outGate,*iter2));
394 DEBTRACE(
"Bloc::updateStateOnFinishedEventFrom: " <<
ex.what());
425 os <<
" subgraph cluster_" <<
getId() <<
" {\n" ;
427 for(list<Node *>::const_iterator iter=nodes.begin();iter!=nodes.end();iter++)
429 (*iter)->writeDot(os);
430 string p=(*iter)->
getId();
432 if((*iter)->_inGate._backLinks.size() == 0) os <<
getId() <<
" -> " <<
p <<
";\n";
434 for(list<Node *>::const_iterator itout=outnodes.begin();itout!=outnodes.end();itout++)
436 os <<
p <<
" -> " << (*itout)->
getId() <<
";\n";
440 os <<
getId() <<
"[fillcolor=\"" ;
443 os <<
"\" label=\"" <<
"Bloc:" ;
466 std::list< AbstractPoint * > pts;
467 for(std::vector< std::list<Node *> >::const_iterator it=
r.begin();it!=
r.end();it++)
490 for(std::set< std::pair<Node *, Node *> >::const_iterator it=linksToKill.begin();it!=linksToKill.end();it++)
498 throw Exception(
"Bloc::partitionRegardingDPL : NULL pointer !");
508 _fwLinks=
new map<Node *,set<Node *> >;
509 _bwLinks=
new map<Node *,set<Node *> >;
512 std::set< std::pair< Node*, Node* > > links;
518 for(std::list<InGate *>::const_iterator it2=ingates.begin();it2!=ingates.end();it2++)
521 Node* n2=(*it2)->getNode();
522 links.insert(std::pair< Node*, Node* >(n1,n2));
523 std::set<Node *> bwn1=(*_bwLinks)[n1];
524 std::set<Node *> fwn1=(*_fwLinks)[n1];
525 std::set<Node *> fwn2=(*_fwLinks)[n2];
526 std::set<Node *> bwn2=(*_bwLinks)[n2];
527 std::pair<std::set<Node*>::iterator,
bool> ret;
528 for(std::set<Node *>::const_iterator iter2=bwn1.begin();iter2!=bwn1.end();iter2++)
530 for(std::set<Node *>::const_iterator it3=fwn2.begin();it3!=fwn2.end();it3++)
532 ret=(*_fwLinks)[*iter2].insert(*it3);
533 if(ret.second==
false)
536 if(links.find(std::pair< Node*, Node* >(*iter2,*it3)) != links.end())
540 ret=(*_fwLinks)[*iter2].insert(n2);
541 if(ret.second==
false)
544 if(links.find(std::pair< Node*, Node* >(*iter2,n2)) != links.end())
548 for(std::set<Node *>::const_iterator it3=fwn2.begin();it3!=fwn2.end();it3++)
550 ret=(*_fwLinks)[n1].insert(*it3);
551 if(ret.second==
false)
554 if(links.find(std::pair< Node*, Node* >(n1,*it3)) != links.end())
558 ret=(*_fwLinks)[n1].insert(n2);
559 if(ret.second==
false)
565 for(std::set<Node *>::const_iterator iter2=fwn2.begin();iter2!=fwn2.end();iter2++)
567 (*_bwLinks)[*iter2].insert(bwn1.begin(),bwn1.end());
568 (*_bwLinks)[*iter2].insert(n1);
570 (*_bwLinks)[n2].insert(bwn1.begin(),bwn1.end());
571 (*_bwLinks)[n2].insert(n1);
616 std::vector<OutPort *>& fwCross,
636 fwCross.push_back(start);
652 set<Node *>& nexts=fw ? (*_fwLinks)[start] : (*_bwLinks)[start];
653 return nexts.find(end)!=nexts.end();
666 set<Node *>& nexts=(*_fwLinks)[start];
667 set<Node *>& preds=(*_bwLinks)[start];
668 return nexts.find(end)==nexts.end() && preds.find(end)==preds.end();
683 map<Node *,list <OutPort *> > classPerNodes;
684 for(list< OutPort *>::const_iterator iter1=starts.begin();iter1!=starts.end();iter1++)
686 set<Node *> allNodes;
687 for(map<
Node *,list <OutPort *> >::iterator iter2=classPerNodes.begin();iter2!=classPerNodes.end();iter2++)
688 allNodes.insert((*iter2).first);
689 vector<Node *> okAndUseless1,useless2;
697 for(list< OutPort *>::const_iterator iter1=starts.begin();iter1!=starts.end();iter1++)
705 (*iter)->_colour=
White;
706 (*iter)->getInGate()->exReset();
707 (*iter)->getOutGate()->exReset();
721 const std::vector<Node *>& candidates,
unsigned char& alreadyFed,
724 for(vector<Node *>::const_iterator iter=candidates.begin();iter!=candidates.end();iter++)
726 const list<OutPort *>& mySet=(*pool.find(*iter)).second;
735 else if(alreadyFed==
FED_ST)
745 else if(alreadyFed==
FED_ST)
747 for(list<OutPort *>::const_iterator iter2=mySet.begin();iter2!=mySet.end();iter2++)
766 const std::set<Node *>& candidates,
unsigned char& alreadyFed,
770 for(set<Node *>::const_iterator iter=candidates.begin();iter!=candidates.end();iter++)
772 const list<OutPort *>& mySet=(*pool.find(*iter)).second;
777 else if(alreadyFed==
FED_ST)
787 else if(alreadyFed==
FED_ST)
789 for(list<OutPort *>::const_iterator iter2=mySet.begin();iter2!=mySet.end();iter2++)
798 else if(alreadyFed==
FED_ST)
800 for(list<OutPort *>::const_iterator iter2=mySet.begin();iter2!=mySet.end();iter2++)
805 if(!candidates.empty())
818 set<Node *>::iterator iter=allNodes.begin();
819 while(iter!=allNodes.end())
821 set<Node *>& whereToFind=(*_bwLinks)[*iter];
822 std::set<Node *>::iterator iter2;
823 for(iter2=allNodes.begin();iter2!=allNodes.end();iter2++)
824 if((*iter)!=(*iter2))
825 if(whereToFind.find(*iter2)==whereToFind.end())
827 if(iter2!=allNodes.end())
831 okAndUseless1.push_back((*iter));
832 allNodes.erase(iter);
833 iter=allNodes.begin();
844 set<Node *>::iterator iter=allNodes.begin();
845 while(iter!=allNodes.end())
847 set<Node *>& whereToFind=(*_fwLinks)[*iter];
848 std::set<Node *>::iterator iter2;
849 for(iter2=allNodes.begin();iter2!=allNodes.end();iter2++)
850 if((*iter)!=(*iter2))
851 if(whereToFind.find(*iter2)==whereToFind.end())
853 if(iter2!=allNodes.end())
859 useless2.push_back((*iter));
860 allNodes.erase(iter);
861 iter=allNodes.begin();
873 vector<Node *>::const_iterator iter=path.begin(); iter++;
874 vector<Node *>::const_iterator iter2=path.end(); iter2-=1;
875 for(;iter!=iter2;iter++)
876 fastFinder[*iter].insert(*(iter+1));
886 list< vector<Node *> >::const_iterator whereToPeerAt;
887 for(list< vector<Node *> >::const_iterator iter=res.begin();iter!=res.end();iter++)
888 if((*iter).size()>maxSize)
890 maxSize=(*iter).size();
896 vector<Node *>::const_iterator iter2=(*whereToPeerAt).begin();
897 map<Node *,bool>::iterator iter4;
898 set<Node *> searcher(iter2+1,(*whereToPeerAt).end());
899 for(;iter2!=((*whereToPeerAt).end()-2);iter2++)
901 list< pair<InGate *,bool> >& nexts=(*iter2)->getOutGate()->edMapInGate();
902 for(list< pair<InGate *,bool> >::iterator iter4=nexts.begin();iter4!=nexts.end();iter4++)
903 if((*iter4).first->getNode()!=*(iter2+1))
904 if(searcher.find((*iter4).first->getNode())!=searcher.end())
906 searcher.erase(*iter2);
bool insertNodeChildrenInSet(Node *node, std::set< Node * > &nodeSet)
Composed node to group elementary and composed nodes.
void removeRecursivelyRedundantCL()
Node * getChildByShortName(const std::string &name) const
void checkCFLinks(const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
Check control flow links.
std::list< Node * > _setOfNode
int getNumberOfCFLinks() const
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
bool areLinked(Node *start, Node *end, bool fw) const
Check if two nodes are linked.
void checkNoCyclePassingThrough(Node *node)
bool isNameAlreadyUsed(const std::string &name) const
void accept(Visitor *visitor)
std::vector< std::list< Node * > > splitIntoIndependantGraph() const
std::list< AbstractPoint * > analyzeParallelism() const
Node * simpleClone(ComposedNode *father, bool editionOnly=true) const
bool isFinished()
Indicate if the bloc execution is finished.
std::vector< std::pair< OutGate *, InGate * > > getSetOfInternalCFLinks() const
bool areAllSubNodesFinished() const
void seekOkAndUseless1(std::vector< Node * > &okAndUseless1, std::set< Node * > &allNodes) const
void performCFComputationsOnlyOneLevel(LinkInfo &info) const
static void updateWithNewFind(const std::vector< Node * > &path, std::map< Node *, std::set< Node * > > &fastFinder)
void partitionRegardingDPL(const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)
static void verdictForOkAndUseless1(const std::map< Node *, std::list< OutPort * > > &pool, InputPort *end, const std::vector< Node * > &candidates, unsigned char &alreadyFed, bool direction, LinkInfo &info)
static void verdictForCollapses(const std::map< Node *, std::list< OutPort * > > &pool, InputPort *end, const std::set< Node * > &candidates, unsigned char &alreadyFed, bool direction, LinkInfo &info)
YACS::Event updateStateOnFinishedEventFrom(Node *node)
std::map< Node *, std::set< Node * > > * _bwLinks
For internal calculations.
bool areAllSubNodesDone() const
int getMaxLevelOfParallelism() const
bool arePossiblyRunnableAtSameTime(Node *start, Node *end) const
Check if two nodes can run in parallel.
void getWeightRegardingDPL(ComplexWeight *weight)
void init(bool start=true)
Initialize the bloc.
YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst)
Notify this bloc that a node has failed.
std::map< Node *, std::set< Node * > > * _fwLinks
For internal calculations.
bool edAddChild(Node *DISOWNnode)
Add a child node to the bloc.
static void findUselessLinksIn(const std::list< std::vector< Node * > > &res, LinkInfo &info)
void performCFComputations(LinkInfo &info) const
void seekUseless2(std::vector< Node * > &useless2, std::set< Node * > &allNodes) const
void initComputation() const
std::list< Node * > getChildren() const
void exUpdateState()
Update the bloc state.
void getReadyTasks(std::vector< Task * > &tasks)
Collect all nodes that are ready to execute.
void edRemoveChild(Node *node)
virtual void writeDot(std::ostream &os) const
Dump to the input stream a dot representation of the node.
void destructCFComputations(LinkInfo &info) const
destroy recursively all results of initial computations.
Base class for all composed nodes.
std::string getChildName(const Node *node) const
Node * getChildByName(const std::string &name) const
static const unsigned char FREE_ST
OutPort * getOutPort(const std::string &name) const
std::vector< std::pair< OutPort *, InPort * > > getSetOfInternalLinks() const
void checkNoCrossHierachyWith(Node *node) const
std::string getName() const
void edRemoveCFLink(Node *nodeS, Node *nodeE)
Remove a controlflow link.
virtual void edRemoveChild(Node *node)
Remove a child node.
bool isNodeAlreadyAggregated(const Node *node) const
Check that Node 'node' is already a direct son of this.
std::string getPortName(const PORT *port) const
virtual void removeRecursivelyRedundantCL()
virtual void performCFComputations(LinkInfo &info) const
perform recursively all CF computations.
static const unsigned char FED_ST
static const unsigned char FED_DS_ST
bool edAddCFLink(Node *nodeS, Node *nodeE)
Add a controlflow link between two nodes.
bool edAddLink(OutPort *start, InPort *end)
Add a dataflow link between two data ports.
virtual void destructCFComputations(LinkInfo &info) const
destroy recursively all results of initial computations.
Node * isInMyDescendance(Node *nodeToTest) const
Returns the parent of a node that is the direct child of this node.
static ComposedNode * getLowestCommonAncestor(Node *node1, Node *node2)
Retrieves the lowest common ancestor of 2 nodes.
Base class for all calculation nodes.
void getWeightRegardingDPL(ComplexWeight *weight)
void partitionRegardingDPL(const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap) const
int getMaxLevelOfParallelism() const
std::list< OutGate * > getBackLinks()
Class that deal with list of semantics links for high level analysis.
void pushErrLink(OutPort *semStart, InPort *end, ErrReason reason)
void pushInfoLink(OutPort *semStart, InPort *end, InfoReason reason)
void startCollapseTransac()
void pushUselessCFLink(Node *start, Node *end)
std::set< std::pair< Node *, Node * > > getInfoUselessLinks() const
void endCollapseTransac()
void pushWarnLink(OutPort *semStart, InPort *end, WarnReason reason)
Base class for all nodes.
virtual void exForwardFinished()
std::string getColorState(YACS::StatesForNode state) const
Return the color associated to a state.
virtual void modified()
Sets Node in modified state and its father if it exists.
std::string getQualifiedName() const
same as Node::getName() in most cases, but differs for children of switch
std::list< Node * > getOutNodes() const
const std::string getId() const
virtual void init(bool start=true)
void setState(YACS::StatesForNode theState)
Sets the given state for node.
InPort * getInPort(const std::string &name) const
const std::string & getName() const
virtual void exForwardFailed()
virtual YACS::StatesForNode getEffectiveState() const
Return the node state in the context of its father.
YACS::StatesForNode _state
std::list< InGate * > edSetInGate() const
AbstractPoint * getUniqueAndReleaseIt() const
virtual void visitBloc(Bloc *node)=0
@ E_DS_LINK_UNESTABLISHABLE
@ W_COLLAPSE_EL_AND_USELESS
@ W_BACK_COLLAPSE_AND_USELESS
@ W_BACK_COLLAPSE_EL_AND_USELESS