Salome HOME
Merge branch 'V9_2_2_BR'
[modules/yacs.git] / src / engine / Switch.cxx
index 2c6fb63442f86ba696ae6adeee5156476d1d7ff8..314c619271386912d805c9f8e7fb2a6569913ff9 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2019  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
@@ -400,6 +400,31 @@ int Switch::getNumberOfInputPorts() const
   return StaticDefinedComposedNode::getNumberOfInputPorts()+1;
 }
 
+int Switch::getMaxLevelOfParallelism() const
+{
+  int ret(0);
+  for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
+    ret=std::max(ret,((*it).second)->getMaxLevelOfParallelism());
+  return ret;
+}
+
+void Switch::getWeightRegardingDPL(ComplexWeight *weight)
+{
+  ComplexWeight localWeight;
+  for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
+  {
+    ((*it).second)->getWeightRegardingDPL(&localWeight);
+    weight->max(localWeight);
+    localWeight.setToZero();
+  }
+}
+
+void Switch::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap)
+{
+  for(std::map< int , Node * >::const_iterator it=_mapOfNode.begin();it!=_mapOfNode.end();it++)
+    (*it).second->partitionRegardingDPL(pd,zeMap);
+}
+
 void Switch::edRemoveChild(Node *node) throw(YACS::Exception)
 {
   map< int , Node * >::iterator iter=_mapOfNode.begin();
@@ -572,6 +597,34 @@ int Switch::getMaxCase()
   return aCase;
 }
 
+//! Get the progress weight of the graph
+/*!
+ * Only elementary nodes have weight. If the switch node is not done, we add the weight of all his descendants,
+ * otherwise only the weight of the used case count.
+ */
+list<ProgressWeight> Switch::getProgressWeight() const
+{
+  list<ProgressWeight> ret;
+  list<Node *> setOfNode=edGetDirectDescendants();
+  if (getState() == YACS::DONE)
+    {
+      for(list<Node *>::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
+      {
+        if (getEffectiveState(*iter) == YACS::DONE)
+          ret=(*iter)->getProgressWeight();
+      }
+    }
+  else
+    {
+      for(list<Node *>::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
+        {
+          list<ProgressWeight> myCurrentSet=(*iter)->getProgressWeight();
+          ret.insert(ret.end(),myCurrentSet.begin(),myCurrentSet.end());
+        }
+    }
+  return ret;
+}
+
 bool Switch::edAddChild(Node *node) throw(YACS::Exception)
 {
   int aCase = getMaxCase() + 1;