Salome HOME
WIP
[modules/yacs.git] / src / engine / VisitorSaveSchema.cxx
index eed7e1b21df03a6cfd7ff3c30eec0fc42254d2d9..85a30463cd9bb58df5d2a426f8a855f9b62420aa 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
@@ -134,6 +134,7 @@ void VisitorSaveSchema::visitForEachLoop(ForEachLoop *node)
     _out << " state=\"disabled\"";
   if (!nbranch->isEmpty())
     _out << " nbranch=\"" << nbranch->getIntValue() << "\"";
+  _out << " loopWeight=\"" << node->getWeight()->getSimpleLoopWeight() << "\"";
   if (node->edGetSamplePort())
     _out << " type=\"" << node->edGetSamplePort()->edGetType()->name() << "\"";
   _out << ">" << endl;
@@ -147,6 +148,29 @@ void VisitorSaveSchema::visitForEachLoop(ForEachLoop *node)
   DEBTRACE("END visitForEachLoop " << _root->getChildName(node));
 }
 
+void VisitorSaveSchema::visitForEachLoopDyn(ForEachLoopDyn *node)
+{
+  DEBTRACE("START visitForEachLoopDyn " << _root->getChildName(node));
+  beginCase(node);
+  int depth = depthNode(node);
+
+  _out << indent(depth) << "<foreachdyn name=\"" << node->getName() << "\"";
+  if (node->getState() == YACS::DISABLED)
+    _out << " state=\"disabled\"";
+  _out << " loopWeight=\"" << node->getWeight()->getSimpleLoopWeight() << "\"";
+  if (node->edGetSamplePort())
+    _out << " type=\"" << node->edGetSamplePort()->edGetType()->name() << "\"";
+  _out << ">" << endl;
+  
+  writeProperties(node);
+  node->DynParaLoop::accept(this);
+  writeSimpleDataLinks(node);
+  writeSimpleStreamLinks(node);
+  _out << indent(depth) << "</foreachdyn>" << endl;
+  endCase(node);
+  DEBTRACE("END visitForEachLoopDyn " << _root->getChildName(node));
+}
+
 void VisitorSaveSchema::visitOptimizerLoop(OptimizerLoop *node)
 {
   DEBTRACE("START visitOptimizerLoop " << _root->getChildName(node));
@@ -159,6 +183,7 @@ void VisitorSaveSchema::visitOptimizerLoop(OptimizerLoop *node)
     _out << " state=\"disabled\"";
   if (!nbranch->isEmpty())
     _out << " nbranch=\"" << nbranch->getIntValue() << "\"";
+  _out << " loopWeight=\"" << node->getWeight()->getSimpleLoopWeight() << "\"";
   _out << " lib=\"" << node->getAlgLib() << "\"";
   _out << " entry=\"" << node->getSymbol() << "\"";
   _out << ">" << endl;
@@ -222,10 +247,13 @@ void VisitorSaveSchema::visitInlineNode(InlineNode *node)
   DEBTRACE("START visitInlineNode " << _root->getChildName(node));
   beginCase(node);
   int depth = depthNode(node);
-  if(node->getExecutionMode()=="local")
+  if(node->getExecutionMode()==InlineNode::LOCAL_STR)
     _out << indent(depth) << "<inline name=\"" << node->getName() << "\"";
   else
-    _out << indent(depth) << "<remote name=\"" << node->getName() << "\"";
+    {
+      _out << indent(depth) << "<remote name=\"" << node->getName() << "\"";
+      _out << " elementaryWeight=\"" << node->getWeight()->getElementaryWeight() << "\"";
+    }
   if (node->getState() == YACS::DISABLED)
     _out << " state=\"disabled\">" << endl;
   else
@@ -245,7 +273,7 @@ void VisitorSaveSchema::visitInlineNode(InlineNode *node)
   writeOutputPorts(node);
   writeOutputDataStreamPorts(node);
 
-  if(node->getExecutionMode()=="local")
+  if(node->getExecutionMode()==InlineNode::LOCAL_STR)
     _out << indent(depth) << "</inline>" << endl;
   else
     _out << indent(depth) << "</remote>" << endl;
@@ -259,10 +287,13 @@ void VisitorSaveSchema::visitInlineFuncNode(InlineFuncNode *node)
   DEBTRACE("START visitInlineFuncNode " << _root->getChildName(node));
   beginCase(node);
   int depth = depthNode(node);
-  if(node->getExecutionMode()=="local")
+  if(node->getExecutionMode()==InlineNode::LOCAL_STR)
     _out << indent(depth) << "<inline name=\"" << node->getName() << "\"";
   else
-    _out << indent(depth) << "<remote name=\"" << node->getName() << "\"";
+    {
+      _out << indent(depth) << "<remote name=\"" << node->getName() << "\"";
+      _out << " elementaryWeight=\"" << node->getWeight()->getElementaryWeight() << "\"";
+    }
   if (node->getState() == YACS::DISABLED)
     _out << " state=\"disabled\">" << endl;
   else
@@ -284,7 +315,7 @@ void VisitorSaveSchema::visitInlineFuncNode(InlineFuncNode *node)
   writeOutputPorts(node);
   writeOutputDataStreamPorts(node);
 
-  if(node->getExecutionMode()=="local")
+  if(node->getExecutionMode()==InlineNode::LOCAL_STR)
     _out << indent(depth) << "</inline>" << endl;
   else
     _out << indent(depth) << "</remote>" << endl;
@@ -797,8 +828,8 @@ void VisitorSaveSchema::writeControls(ComposedNode *node)
   for (list<Node*>::iterator ic = setOfChildren.begin(); ic != setOfChildren.end(); ++ic)
     {
       // --- Control links from direct descendant to nodes inside the bloc
-      set<InGate*> setOfInGates = (*ic)->getOutGate()->edSetInGate();
-      for (set<InGate*>::iterator ig = setOfInGates.begin(); ig != setOfInGates.end(); ++ig)
+      list<InGate*> setOfInGates = (*ic)->getOutGate()->edSetInGate();
+      for (list<InGate*>::iterator ig = setOfInGates.begin(); ig != setOfInGates.end(); ++ig)
         {
           Node *to = (*ig)->getNode();
           if (node->isInMyDescendance(to))
@@ -840,7 +871,7 @@ void VisitorSaveSchema::writeSimpleDataLinks(ComposedNode *node)
 
   for (list<Node*>::iterator ic = setOfChildren.begin(); ic != setOfChildren.end(); ++ic)
     // add "splitter" node of ForEachLoop nodes to the set of children
-    if ( dynamic_cast<ForEachLoop*>( *ic ) )
+    if ( dynamic_cast<ForEachLoopGen*>( *ic ) )
       {
         Node *nodeToInsert=(*ic)->getChildByName(ForEachLoop::NAME_OF_SPLITTERNODE);
         if(find(setOfChildrenPlusSplitters.begin(),setOfChildrenPlusSplitters.end(),nodeToInsert)==setOfChildrenPlusSplitters.end())
@@ -870,13 +901,13 @@ void VisitorSaveSchema::writeSimpleDataLinks(ComposedNode *node)
                   DEBTRACE( "BINGO!" );
 
                   string fromName;
-                  if ( dynamic_cast<SplitterNode*>(from) && dynamic_cast<ForEachLoop*>(from->getFather()) )
+                  if ( dynamic_cast<SplitterNode*>(from) && dynamic_cast<ForEachLoopGen*>(from->getFather()) )
                     fromName = from->getFather()->getName();
                   else
                     fromName = node->getChildName(from);
 
                   string childName;
-                  if ( dynamic_cast<SplitterNode*>(to) && dynamic_cast<ForEachLoop*>(to->getFather()) )
+                  if ( dynamic_cast<SplitterNode*>(to) && dynamic_cast<ForEachLoopGen*>(to->getFather()) )
                     childName = node->getChildName(to->getFather());
                   else
                     childName = node->getChildName(to);
@@ -1082,11 +1113,6 @@ void VisitorSaveSchema::writeParametersNode(ComposedNode *proc, Node *node)
 {
   int depth = 1;
   list<InputPort *> setOfInputPort = node->getLocalInputPorts();
-  if (ForEachLoop* foreach = dynamic_cast<ForEachLoop*>(node))
-    {
-      DEBTRACE("writeParametersNode foreach");
-      setOfInputPort.push_back( foreach->edGetSeqOfSamplesPort());
-    }
   list<InputPort *>::iterator iter;
   for(iter = setOfInputPort.begin(); iter != setOfInputPort.end(); ++iter)
     {