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 *> >;
}
}
+/*!
+ * 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);
void findAllNodesStartingFrom(Node *start, std::set<Node *>& result, std::map<Node *, std::set<Node *> >& accelStr, LinkInfo& info) const;
virtual std::string typeName() { return "YACS__ENGINE__Bloc"; }
int getMaxLevelOfParallelism() const;
+ void removeRecursivelyRedundantCL();
protected:
bool areAllSubNodesFinished() const;
bool areAllSubNodesDone() const;
YACS::Event updateStateOnFinishedEventFrom(Node *node);
YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);
void initComputation() const;
+ void performCFComputationsOnlyOneLevel(LinkInfo& info) const;
void performCFComputations(LinkInfo& info) const;
void destructCFComputations(LinkInfo& info) const;
void checkControlDependancy(OutPort *start, InPort *end, bool cross,
return ret;
}
+/*!
+ * This method recursively all redundant control links in this.
+ */
+void ComposedNode::removeRecursivelyRedundantCL()
+{
+ std::list<Node *> dd(edGetDirectDescendants());
+ for(std::list<Node *>::const_iterator it=dd.begin();it!=dd.end();it++)
+ {
+ ComposedNode *elt(dynamic_cast<ComposedNode *>(*it));
+ if(elt)
+ elt->removeRecursivelyRedundantCL();
+ }
+}
+
list<ElementaryNode *> ComposedNode::getRecursiveConstituents() const
{
list<ElementaryNode *> ret;
void edRemoveLink(OutGate *start, InGate *end) throw(Exception);
virtual bool isRepeatedUnpredictablySeveralTimes() const { return false; }
virtual std::list<Node *> edGetDirectDescendants() const = 0;
+ virtual void removeRecursivelyRedundantCL();
std::list<ElementaryNode *> getRecursiveConstituents() const;
std::list<Node *> getAllRecursiveNodes();
virtual std::list<Node *> getAllRecursiveConstituents(); // first implementation