Salome HOME
Correction of bug MANTIS23234 CEA1726.
[modules/yacs.git] / src / engine / DynParaLoop.cxx
index 71a5fe368fd348bb45f22c7cdbfd28e833d4f616..db101aebadadf8de673135da8abc0b6eee390f4a 100644 (file)
@@ -154,6 +154,34 @@ int DynParaLoop::getNumberOfOutputPorts() const
   return ComposedNode::getNumberOfOutputPorts()+1;
 }
 
+/*!
+ * DynParaLoop creates at runtime (exupdateState) clone of nodes. One clone per branch.
+ * This method returns the id of the branch given the node \a node.
+ * If \a node is not a dynamically created node in \a this -1 is returned.
+ */
+int DynParaLoop::getBranchIDOfNode(Node *node) const
+{
+  if(_node)
+    {
+      for(std::vector<Node *>::const_iterator it=_execNodes.begin();it!=_execNodes.end();it++)
+        if(node==*it)
+          return std::distance(_execNodes.begin(),it);
+    }
+  if(_finalizeNode)
+    {
+      for(std::vector<Node *>::const_iterator it=_execFinalizeNodes.begin();it!=_execFinalizeNodes.end();it++)
+        if(node==*it)
+          return std::distance(_execFinalizeNodes.begin(),it);
+    }
+  if(_initNode)
+    {
+      for(std::vector<Node *>::const_iterator it=_execInitNodes.begin();it!=_execInitNodes.end();it++)
+        if(node==*it)
+          return std::distance(_execInitNodes.begin(),it);
+    }
+  return -1;
+}
+
 std::list<OutputPort *> DynParaLoop::getSetOfOutputPort() const
 {
   list<OutputPort *> ret=ComposedNode::getSetOfOutputPort();
@@ -865,7 +893,7 @@ Node * DynParaLoop::getFinalizeNode()
 
 int DynParaLoop::getMaxLevelOfParallelism() const
 {
-  return _nbOfBranches.getIntValue();
+  return _nbOfBranches.getIntValue() * _node->getMaxLevelOfParallelism();
 }
 
 void DynParaLoop::shutdown(int level)