-// Copyright (C) 2006-2015 CEA/DEN, EDF R&D
+// Copyright (C) 2006-2016 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
ll.push_back(cur);
//
OutGate *og(cur->getOutGate());
- set<InGate *> og2(og->edSetInGate());
- for(set<InGate *>::const_iterator it2=og2.begin();it2!=og2.end();it2++)
+ list<InGate *> og2(og->edSetInGate());
+ for(list<InGate *>::const_iterator it2=og2.begin();it2!=og2.end();it2++)
{
Node *cur2((*it2)->getNode());
if(cur2->_colour==White)
bool insertNodeChildrenInSet(Node *node, std::set<Node *>& nodeSet)
{
bool verdict=true;
- set<Node *> outNodes=node->getOutNodes();
- for (set<Node *>::iterator iter=outNodes.begin();iter!=outNodes.end(); iter++)
+ list<Node *> outNodes=node->getOutNodes();
+ for (list<Node *>::iterator iter=outNodes.begin();iter!=outNodes.end(); iter++)
{
verdict=(nodeSet.insert(*iter)).second;
if (verdict) verdict = insertNodeChildrenInSet((*iter),nodeSet);
vector< pair<OutGate *, InGate *> > ret;
for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
{
- set<InGate *> outCFLinksOfCurNode=(*iter)->_outGate.edSetInGate();
- for(set<InGate *>::iterator iter2=outCFLinksOfCurNode.begin();iter2!=outCFLinksOfCurNode.end();iter2++)
+ list<InGate *> outCFLinksOfCurNode=(*iter)->_outGate.edSetInGate();
+ for(list<InGate *>::iterator iter2=outCFLinksOfCurNode.begin();iter2!=outCFLinksOfCurNode.end();iter2++)
ret.push_back(pair<OutGate *, InGate *>(&(*iter)->_outGate,*iter2));
}
return ret;
void Bloc::writeDot(std::ostream &os) const
{
- os << " subgraph cluster_" << getId() << " {\n" ;
- list<Node *>nodes=getChildren();
- for(list<Node *>::const_iterator iter=nodes.begin();iter!=nodes.end();iter++)
+ os << " subgraph cluster_" << getId() << " {\n" ;
+ list<Node *>nodes=getChildren();
+ for(list<Node *>::const_iterator iter=nodes.begin();iter!=nodes.end();iter++)
{
- (*iter)->writeDot(os);
- string p=(*iter)->getId();
- //not connected node
- if((*iter)->_inGate._backLinks.size() == 0) os << getId() << " -> " << p << ";\n";
- set<Node *>outnodes = (*iter)->getOutNodes();
- for(set<Node *>::const_iterator itout=outnodes.begin();itout!=outnodes.end();itout++)
+ (*iter)->writeDot(os);
+ string p=(*iter)->getId();
+ //not connected node
+ if((*iter)->_inGate._backLinks.size() == 0) os << getId() << " -> " << p << ";\n";
+ list<Node *>outnodes = (*iter)->getOutNodes();
+ for(list<Node *>::const_iterator itout=outnodes.begin();itout!=outnodes.end();itout++)
{
- os << p << " -> " << (*itout)->getId() << ";\n";
+ os << p << " -> " << (*itout)->getId() << ";\n";
}
}
- os << "}\n" ;
- os << getId() << "[fillcolor=\"" ;
- YACS::StatesForNode state=getEffectiveState();
- os << getColorState(state);
- os << "\" label=\"" << "Bloc:" ;
- os << getQualifiedName() <<"\"];\n";
+ os << "}\n" ;
+ os << getId() << "[fillcolor=\"" ;
+ YACS::StatesForNode state=getEffectiveState();
+ os << getColorState(state);
+ os << "\" label=\"" << "Bloc:" ;
+ os << getQualifiedName() <<"\"];\n";
}
void Bloc::accept(Visitor* visitor)
return ret;
}
-/*!
- * Updates mutable structures _fwLinks and _bwLinks with the result of computation (CPU consuming method).
- * _fwLinks is a map with a Node* as key and a set<Node*> as value. The set gives
- * all nodes that are forwardly connected to the key node
- * _bwLinks is a map for backward dependencies
- * The method is : for all CF link (n1->n2)
- * add n2 and _fwLinks[n2] in forward dependencies of n1 and _bwLinks[n1]
- * add n1 and _bwLinks[n1] in backward dependencies of n2 and _fwLinks[n2]
- * For useless links
- * If a node is already in a forward dependency when adding and the direct link
- * already exists so it's a useless link (see the code !)
- */
-void Bloc::performCFComputations(LinkInfo& info) const
+void Bloc::removeRecursivelyRedundantCL()
+{
+ StaticDefinedComposedNode::removeRecursivelyRedundantCL();
+ LinkInfo info(I_CF_USELESS);
+ initComputation();
+ performCFComputationsOnlyOneLevel(info);
+ std::set< std::pair<Node *, Node *> > linksToKill(info.getInfoUselessLinks());
+ for(std::set< std::pair<Node *, Node *> >::const_iterator it=linksToKill.begin();it!=linksToKill.end();it++)
+ edRemoveCFLink((*it).first,(*it).second);
+ destructCFComputations(info);
+}
+
+void Bloc::performCFComputationsOnlyOneLevel(LinkInfo& info) const
{
- StaticDefinedComposedNode::performCFComputations(info);
delete _fwLinks;//Normally useless
delete _bwLinks;//Normally useless
_fwLinks=new map<Node *,set<Node *> >;
for(list<Node *>::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++)
{
Node* n1=*iter;
- std::set<InGate *> ingates=n1->getOutGate()->edSetInGate();
- for(std::set<InGate *>::const_iterator it2=ingates.begin();it2!=ingates.end();it2++)
+ std::list<InGate *> ingates=n1->getOutGate()->edSetInGate();
+ for(std::list<InGate *>::const_iterator it2=ingates.begin();it2!=ingates.end();it2++)
{
//CF link : n1 -> (*it2)->getNode()
Node* n2=(*it2)->getNode();
}
}
+/*!
+ * Updates mutable structures _fwLinks and _bwLinks with the result of computation (CPU consuming method).
+ * _fwLinks is a map with a Node* as key and a set<Node*> as value. The set gives
+ * all nodes that are forwardly connected to the key node
+ * _bwLinks is a map for backward dependencies
+ * The method is : for all CF link (n1->n2)
+ * add n2 and _fwLinks[n2] in forward dependencies of n1 and _bwLinks[n1]
+ * add n1 and _bwLinks[n1] in backward dependencies of n2 and _fwLinks[n2]
+ * For useless links
+ * If a node is already in a forward dependency when adding and the direct link
+ * already exists so it's a useless link (see the code !)
+ */
+void Bloc::performCFComputations(LinkInfo& info) const
+{
+ StaticDefinedComposedNode::performCFComputations(info);
+ performCFComputationsOnlyOneLevel(info);
+}
+
void Bloc::destructCFComputations(LinkInfo& info) const
{
StaticDefinedComposedNode::destructCFComputations(info);
set<Node *> searcher(iter2+1,(*whereToPeerAt).end());//to boost research
for(;iter2!=((*whereToPeerAt).end()-2);iter2++)
{
- map<InGate *,bool>::iterator iter4;
- map<InGate *,bool>& nexts=(*iter2)->getOutGate()->edMapInGate();
- for(iter4=nexts.begin();iter4!=nexts.end();iter4++)
+ list< pair<InGate *,bool> >& nexts=(*iter2)->getOutGate()->edMapInGate();
+ for(list< pair<InGate *,bool> >::iterator iter4=nexts.begin();iter4!=nexts.end();iter4++)
if((*iter4).first->getNode()!=*(iter2+1))
if(searcher.find((*iter4).first->getNode())!=searcher.end())
info.pushUselessCFLink(*iter2,(*iter4).first->getNode());