Salome HOME
Error Messages
[modules/superv.git] / src / GraphBase / DataFlowBase_XmlHandler.cxx
index 3a6f82dbe719717a9d5848f9ea1d45219b9a2914..829889c5329d8f66d729d364fda18fad7fc6020a 100644 (file)
@@ -47,22 +47,27 @@ GraphBase::XmlHandler::XmlHandler( CORBA::ORB_ptr Orb ,
     step[i] = 0 ;
   }
   VXSize = 0 ;
+  GraphsNumber = 0 ;
 }
 
 GraphBase::XmlHandler::XmlHandler() {}
 
 GraphBase::XmlHandler::~XmlHandler() {}
 
-QString GraphBase::XmlHandler::errorProtocol()
-{
-    return errorProt;
+QString GraphBase::XmlHandler::errorProtocol() {
+  return errorProt;
 }
 
-bool GraphBase::XmlHandler::startDocument()
-{
-    // at the beginning of parsing: do some initialization
-    errorProt = "";
-    return TRUE;
+bool GraphBase::XmlHandler::startDocument() {
+  MESSAGE( "====================startDocument " ) ;
+// at the beginning of parsing: do some initialization
+  errorProt = "";
+  return TRUE;
+}
+
+bool GraphBase::XmlHandler::endDocument() {
+  MESSAGE( "====================endDocument " ) ;
+  return TRUE;
 }
 
 bool GraphBase::XmlHandler::startElement( const QString&, const QString&, 
@@ -75,13 +80,26 @@ bool GraphBase::XmlHandler::startElement( const QString&, const QString&,
   MESSAGE( "====================startElement " << depth << " " << qName)
    
 #endif
-  if ( qName == "dataflow" && depth == 0 ) {
+
+  if ( ( qName == "dataflow" || qName == "supergraph" ) && depth == 0 ) {
     // Dataflow detected
+    aListOfDataFlows.resize( GraphsNumber + 1 ) ;
+    int i ;
+    for ( i = 0 ; i < maxlevel ; i++ ) {
+      fieldname[i] = NULLSTRING ;
+      fieldvalue[i] = NULLSTRING ;
+      step[i] = 0 ;
+    }
+    VXSize = 0 ;
     dataflowxml = TRUE;
   }
   if ( dataflowxml ) {
-//    fieldname[depth++] = (const char * ) qName ;
-    fieldname[depth++] = qName.latin1() ;
+    if ( qName == "supergraph" ) {
+      fieldname[depth] = qName.latin1() ;
+    }
+    else {
+      fieldname[depth++] = qName.latin1() ;
+    }
   }
   if ( depth == maxlevel+1 )
     return false ;
@@ -103,25 +121,37 @@ bool GraphBase::XmlHandler::endElement( const QString&,
                                         const QString&,
                                         const QString& qName) {
 
+  if ( qName == "supergraph" ) {
+#if TRACE
+    MESSAGE( " ====================endElement supergraph" ) ;
+#endif
+    return TRUE ;
+  }
+
+// ERRORs :
+// * On a eu endElement(dataflow)
+// * Ou bien on a eu uniquement startElement(dataflow) et qName != fieldname et fieldvalue != NULLSTRING
   if ( !dataflowxml ||
        ( qName != QString( fieldname[depth].c_str() ) &&
          fieldvalue[depth] != NULLSTRING ) ) {
-    MESSAGE( "endElement ERROR " << dataflowxml << " qName " << qName
-             << " fieldname<< fieldname[depth] << " fieldvalue "
+    MESSAGE( "endElement ERROR dataflowxml " << dataflowxml << " qName " << qName
+             << " fieldname[" << depth << "] "<< fieldname[depth] << " fieldvalue "
              << fieldvalue[depth] )
     return returnfalse( this , "top" , qName ) ;
   }
-  if ( fieldvalue[depth] == NULLSTRING )
+  if ( fieldvalue[depth] == NULLSTRING ) {
     depth -= 1 ;
+  }
 
 #if TRACE
-  MESSAGE( " ==========endElement step[" << depth << "]="
+  MESSAGE( " ====================endElement step[" << depth << "]="
            << step[depth] << " qName " << qName << " fieldvalue '"
            << fieldvalue[depth] << "'")
 #endif
   switch ( depth ) {
     case 0 : {
       if ( step[depth] == 0 && qName == "dataflow" ) {
+        GraphsNumber += 1 ;
         dataflowxml = false ;
       }
       else
@@ -133,7 +163,7 @@ bool GraphBase::XmlHandler::endElement( const QString&,
       switch ( step[depth] ) {
         case 0 :
           if ( qName == "info-list" ) {
-//            aDataFlow.Info = aNode ;
+//            aListOfDataFlows[ GraphsNumber ].Info = aNode ;
             step[depth]++ ;
           }
           else
@@ -176,17 +206,18 @@ bool GraphBase::XmlHandler::endElement( const QString&,
           if ( qName == "node" ) {
 // Node ok
             if ( step[1] == 0 ) {
-              aDataFlow.Info = aNode ;
+              aListOfDataFlows[ GraphsNumber ].Info = aNode ;
            }
             else if ( step[1] == 1 ) {
-              int sizenode = aDataFlow.Nodes.size() ;
-              aDataFlow.Nodes.resize( sizenode+1 ) ;                
-              aDataFlow.Nodes[ sizenode ] = aNode ;               
+              int sizenode = aListOfDataFlows[ GraphsNumber ].Nodes.size() ;
+              aListOfDataFlows[ GraphsNumber ].Nodes.resize( sizenode+1 ) ;                
+              aListOfDataFlows[ GraphsNumber ].Nodes[ sizenode ] = aNode ;               
            }
             step[3] = 0 ;
             aNode.theService.ServiceinParameter.length( 0 ) ;
             aNode.theService.ServiceoutParameter.length( 0 ) ;
-            aNode.theListOfParameters.resize( 0 ) ;
+            aNode.theListOfInDataStreams.resize( 0 ) ;
+            aNode.theListOfOutDataStreams.resize( 0 ) ;
             aNode.theListOfFuncName.resize( 0 ) ;
             aNode.theListOfPythonFunctions.resize( 0 ) ;
             break ;
@@ -200,15 +231,15 @@ bool GraphBase::XmlHandler::endElement( const QString&,
          }
         case 1 :
           if ( qName == "link" ) {
-            int sizelink = aDataFlow.Links.size() ;
-            aDataFlow.Links.resize( sizelink+1 ) ;                
-            aDataFlow.Links[ sizelink ] = aLink ;               
+            int sizelink = aListOfDataFlows[ GraphsNumber ].Links.size() ;
+            aListOfDataFlows[ GraphsNumber ].Links.resize( sizelink+1 ) ;                
+            aListOfDataFlows[ GraphsNumber ].Links[ sizelink ] = aLink ;               
             if ( VXSize ) {
-              aDataFlow.Links[ sizelink ].aListOfCoords.resize( VXSize ) ;
+              aListOfDataFlows[ GraphsNumber ].Links[ sizelink ].aListOfCoords.resize( VXSize ) ;
               int ic ;
               for ( ic = 0 ; ic < VXSize ; ic++ ) {
-                aDataFlow.Links[ sizelink ].aListOfCoords[ ic ].theX = VX[ic] ;
-                aDataFlow.Links[ sizelink ].aListOfCoords[ ic ].theY = VY[ic] ;
+                aListOfDataFlows[ GraphsNumber ].Links[ sizelink ].aListOfCoords[ ic ].theX = VX[ic] ;
+                aListOfDataFlows[ GraphsNumber ].Links[ sizelink ].aListOfCoords[ ic ].theY = VY[ic] ;
              }
            }
             VXSize = 0 ;
@@ -226,15 +257,15 @@ bool GraphBase::XmlHandler::endElement( const QString&,
           if ( qName == "data" ) {
 // Data ok
             if ( constructor ) {
-              int sizedata = aDataFlow.Datas.size() ;
-              aDataFlow.Datas.resize( sizedata+1 ) ;                
-              aDataFlow.Datas[ sizedata ] = aLink ;               
+              int sizedata = aListOfDataFlows[ GraphsNumber ].Datas.size() ;
+              aListOfDataFlows[ GraphsNumber ].Datas.resize( sizedata+1 ) ;                
+              aListOfDataFlows[ GraphsNumber ].Datas[ sizedata ] = aLink ;               
               if ( VXSize ) {
-                aDataFlow.Datas[ sizedata ].aListOfCoords.resize( VXSize ) ;
+                aListOfDataFlows[ GraphsNumber ].Datas[ sizedata ].aListOfCoords.resize( VXSize ) ;
                 int ic ;
                 for ( ic = 0 ; ic < VXSize ; ic++ ) {
-                  aDataFlow.Datas[ sizedata ].aListOfCoords[ ic ].theX = VX[ic] ;
-                  aDataFlow.Datas[ sizedata ].aListOfCoords[ ic ].theY = VY[ic] ;
+                  aListOfDataFlows[ GraphsNumber ].Datas[ sizedata ].aListOfCoords[ ic ].theX = VX[ic] ;
+                  aListOfDataFlows[ GraphsNumber ].Datas[ sizedata ].aListOfCoords[ ic ].theY = VY[ic] ;
                }
              }
            }
@@ -299,12 +330,45 @@ bool GraphBase::XmlHandler::endElement( const QString&,
 // kind ok
             sscanf( fieldvalue[depth].c_str() ,"%d" , (int * ) &aNode.theKind ) ;
             fieldvalue[depth] = NULLSTRING ;
+            if ( aNode.theKind != SUPERV::DataStreamGraph ) {
+              step[depth]++ ;
+              step[4] = 0 ;
+           }
+            break ;
+          }
+          else if ( qName == "streamgraph-timeout" ) {
+            if ( fieldvalue[depth] == NULLSTRING )
+              return returnfalse( this , "depth3-3" , qName ) ;
+            sscanf( fieldvalue[depth].c_str() ,"%d" , (int * ) &aNode.theTimeout ) ;
+            fieldvalue[depth] = NULLSTRING ;
+//              step[depth]++ ;
+//              step[4] = 0 ;
+            break ;
+          }
+          else if ( qName == "streamgraph-datastreamtrace" ) {
+            if ( fieldvalue[depth] == NULLSTRING )
+              return returnfalse( this , "depth3-3" , qName ) ;
+            sscanf( fieldvalue[depth].c_str() ,"%d" , (int * ) &aNode.theDataStreamTrace ) ;
+            fieldvalue[depth] = NULLSTRING ;
+//              step[depth]++ ;
+//              step[4] = 0 ;
+            break ;
+          }
+          else if ( qName == "streamgraph-deltatime" ) {
+            if ( fieldvalue[depth] == NULLSTRING )
+              return returnfalse( this , "depth3-3" , qName ) ;
+            sscanf( fieldvalue[depth].c_str() ,"%lf" , (double * ) &aNode.theDeltaTime ) ;
+            fieldvalue[depth] = NULLSTRING ;
             step[depth]++ ;
             step[4] = 0 ;
+            break ;
           }
-          else
-            return returnfalse( this , "depth3-3" , qName ) ;
-          break ;
+          else {
+            step[depth]++ ;
+            step[4] = 0 ;
+         }
+//            return returnfalse( this , "depth3-3" , qName ) ;
+//          break ;
         case 4 :
           if ( qName == "coupled-node" ) {
             if ( fieldvalue[depth] == NULLSTRING )
@@ -335,7 +399,7 @@ bool GraphBase::XmlHandler::endElement( const QString&,
             return returnfalse( this , "depth3-5" , qName ) ;
           break ;
         case 6 :
-          if ( qName == "Parameter-list" ) {
+          if ( qName == "DataStream-list" || qName == "Parameter-list" ) {
             if ( fieldvalue[depth] != NULLSTRING )
               return returnfalse( this , "depth3-6" , qName ) ;
             fieldvalue[depth] = NULLSTRING ;
@@ -645,7 +709,7 @@ bool GraphBase::XmlHandler::endElement( const QString&,
             aLink.aLinkValue = CORBA::Any() ;
             switch ( Kind ) {
             case CORBA::tk_string: {
-              aLink.aLinkValue <<= (char *) NULL ;
+              aLink.aLinkValue <<= (char *) "";
               char * t;
               aLink.aLinkValue >>= t;
 #if TRACE
@@ -772,21 +836,23 @@ bool GraphBase::XmlHandler::endElement( const QString&,
           if ( qName == "inParameter" ) {
             if ( fieldvalue[depth] != NULLSTRING )
               return returnfalse( this , "depth4-6" , qName ) ;
-            int size = aNode.theListOfParameters.size() ;
-            aNode.theListOfParameters.resize( size+1 ) ;
-            aNode.theListOfParameters[size].theInParameter = aParameter ;
-            step[depth]++ ;
+            int size = aNode.theListOfInDataStreams.size() ;
+            aNode.theListOfInDataStreams.resize( size+1 ) ;
+            aNode.theListOfInDataStreams[ size ] = anInDataStreamParameter ;
+            break ;
 // One more aParameter input
           }
           else
-            return returnfalse( this , "depth4-6" , qName ) ;
-          break ;
+            step[depth]++ ;
+//            return returnfalse( this , "depth4-6" , qName ) ;
+//          break ;
         case 7 :
           if ( qName == "outParameter" ) {
             if ( fieldvalue[depth] != NULLSTRING )
               return returnfalse( this , "depth4-7" , qName ) ;
-            int size = aNode.theListOfParameters.size() ;
-            aNode.theListOfParameters[size-1].theOutParameter = aParameter ;
+            int size = aNode.theListOfOutDataStreams.size() ;
+            aNode.theListOfOutDataStreams.resize( size+1 ) ;
+            aNode.theListOfOutDataStreams[ size ] = anOutDataStreamParameter ;
 // One more aParameter output
             step[4] = 6 ;
             step[5] = 4 ;
@@ -868,46 +934,103 @@ bool GraphBase::XmlHandler::endElement( const QString&,
           if ( qName == "inParameter-type" ) {
             if ( fieldvalue[depth] == NULLSTRING )
               return returnfalse( this , "depth5-4" , qName ) ;
-            if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) {
-              aParameter.Parametertype = fieldvalue[depth].c_str() ;
-           }
-            else {
-              aParameter.Parametertype = "" ;
-           }
+            sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anInDataStreamParameter.theDataStreamParameter.Parametertype ) ;
             fieldvalue[depth] = NULLSTRING ;
             step[depth]++ ;
+#if TRACE
+  //cout << "InDataStreamParameter.inParameter-type " << anInDataStreamParameter.theDataStreamParameter.Parametertype << " step[" << depth << "]" << step[depth] << endl ;
+#endif
+            break ;
           }
           else
-            return returnfalse( this , "depth5-4" , qName ) ;
-          break ;
+            step[depth] = 6 ;
+//            return returnfalse( this , "depth5-4" , qName ) ;
+//          break ;
         case 5 :
           if ( qName == "inParameter-name" ) {
             if ( fieldvalue[depth] == NULLSTRING )
               return returnfalse( this , "depth5-5" , qName ) ;
             if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) {
-              aParameter.Parametername = fieldvalue[depth].c_str() ;
+              anInDataStreamParameter.theDataStreamParameter.Parametername = fieldvalue[depth].c_str() ;
            }
             else {
-              aParameter.Parametername = "" ;
+              anInDataStreamParameter.theDataStreamParameter.Parametername = "" ;
            }
             fieldvalue[depth] = NULLSTRING ;
-            step[depth]++ ;
+#if TRACE
+  //cout << "InDataStreamParameter.inParameter-name " << anInDataStreamParameter.theDataStreamParameter.Parametername << " step[" << depth << "]" << step[depth] << endl ;
+#endif
+//            step[depth]++ ;
+//            step[depth] = 4 ;
+            break ;
           }
-          else
-            return returnfalse( this , "depth5-5" , qName ) ;
-          break ;
+          else if ( qName == "inParameter-dependency" ) {
+            if ( fieldvalue[depth] == NULLSTRING )
+              return returnfalse( this , "depth5-5" , qName ) ;
+            sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anInDataStreamParameter.theDataStreamParameter.Parameterdependency ) ;
+            fieldvalue[depth] = NULLSTRING ;
+#if TRACE
+  //cout << "InDataStreamParameter.inParameter-dependency " << anInDataStreamParameter.theDataStreamParameter.Parameterdependency << " step[" << depth << "]"
+                 << step[depth] << endl ;
+#endif
+//            step[depth]++ ;
+//            step[depth] = 4 ;
+            break ;
+          }
+          else if ( qName == "inParameter-schema" ) {
+            if ( fieldvalue[depth] == NULLSTRING )
+              return returnfalse( this , "depth5-5" , qName ) ;
+            sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anInDataStreamParameter.theKindOfSchema ) ;
+            fieldvalue[depth] = NULLSTRING ;
+#if TRACE
+  //cout << "InDataStreamParameter.inParameter-schema " << anInDataStreamParameter.theKindOfSchema << " step[" << depth << "]"
+                 << step[depth] << endl ;
+#endif
+//            step[depth]++ ;
+//            step[depth] = 4 ;
+            break ;
+          }
+          else if ( qName == "inParameter-interpolation" ) {
+            if ( fieldvalue[depth] == NULLSTRING )
+              return returnfalse( this , "depth5-5" , qName ) ;
+            sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anInDataStreamParameter.theKindOfInterpolation ) ;
+            fieldvalue[depth] = NULLSTRING ;
+#if TRACE
+  //cout << "InDataStreamParameter.inParameter-interpolation " << anInDataStreamParameter.theKindOfInterpolation << " step[" << depth << "]"
+                 << step[depth] << endl ;
+#endif
+//            step[depth]++ ;
+//            step[depth] = 4 ;
+            break ;
+          }
+          else if ( qName == "inParameter-extrapolation" ) {
+            if ( fieldvalue[depth] == NULLSTRING )
+              return returnfalse( this , "depth5-5" , qName ) ;
+            sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anInDataStreamParameter.theKindOfExtrapolation ) ;
+            fieldvalue[depth] = NULLSTRING ;
+//            step[depth]++ ;
+            step[depth] = 4 ;
+#if TRACE
+  //cout << "InDataStreamParameter.inParameter-extrapolation " << anInDataStreamParameter.theKindOfExtrapolation << " step[" << depth << "]"
+                 << step[depth] << endl ;
+#endif
+            break ;
+          }
+//          else
+//            return returnfalse( this , "depth5-5" , qName ) ;
+//          break ;
         case 6 :
           if ( qName == "outParameter-type" ) {
             if ( fieldvalue[depth] == NULLSTRING )
               return returnfalse( this , "depth5-6" , qName ) ;
-            if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) {
-              aParameter.Parametertype = fieldvalue[depth].c_str() ;
-           }
-            else {
-              aParameter.Parametertype = "" ;
-           }
+            sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anOutDataStreamParameter.theDataStreamParameter.Parametertype ) ;
             fieldvalue[depth] = NULLSTRING ;
-            step[depth]++ ;
+//            step[depth]++ ;
+            step[depth] = 7 ;
+#if TRACE
+  //cout << "OutDataStreamParameter.outParameter-type " << anOutDataStreamParameter.theDataStreamParameter.Parametertype << " step[" << depth << "]"
+                 << step[depth] << endl ;
+#endif
           }
           else
             return returnfalse( this , "depth5-6" , qName ) ;
@@ -917,13 +1040,42 @@ bool GraphBase::XmlHandler::endElement( const QString&,
             if ( fieldvalue[depth] == NULLSTRING )
               return returnfalse( this , "depth5-7" , qName ) ;
             if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) {
-              aParameter.Parametername = fieldvalue[depth].c_str() ;
+              anOutDataStreamParameter.theDataStreamParameter.Parametername = fieldvalue[depth].c_str() ;
            }
             else {
-              aParameter.Parametername = "" ;
+              anOutDataStreamParameter.theDataStreamParameter.Parametername = "" ;
            }
             fieldvalue[depth] = NULLSTRING ;
-            step[depth]++ ;
+#if TRACE
+  //cout << "OutDataStreamParameter.outParameter-name " << anOutDataStreamParameter.theDataStreamParameter.Parametername << " step[" << depth << "]"
+                 << step[depth] << endl ;
+#endif
+//            step[depth]++ ;
+//            step[depth] = 6 ;
+          }
+          else if ( qName == "outParameter-dependency" ) {
+            if ( fieldvalue[depth] == NULLSTRING )
+              return returnfalse( this , "depth5-7" , qName ) ;
+            sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anOutDataStreamParameter.theDataStreamParameter.Parameterdependency ) ;
+            fieldvalue[depth] = NULLSTRING ;
+#if TRACE
+  //cout << "OutDataStreamParameter.outParameter-dependency " << anOutDataStreamParameter.theDataStreamParameter.Parameterdependency << " step[" << depth << "]"
+                 << step[depth] << endl ;
+#endif
+//            step[depth]++ ;
+//            step[depth] = 6 ;
+          }
+          else if ( qName == "outParameter-values" ) {
+            if ( fieldvalue[depth] == NULLSTRING )
+              return returnfalse( this , "depth5-7" , qName ) ;
+            sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anOutDataStreamParameter.theNumberOfValues ) ;
+            fieldvalue[depth] = NULLSTRING ;
+//            step[depth]++ ;
+            step[depth] = 6 ;
+#if TRACE
+  //cout << "OutDataStreamParameter.outParameter-values " << anOutDataStreamParameter.theNumberOfValues << " step[" << depth << "]"
+                 << step[depth] << endl ;
+#endif
           }
           else
             return returnfalse( this , "depth5-7" , qName ) ;
@@ -1042,6 +1194,9 @@ bool GraphBase::XmlHandler::endElement( const QString&,
     }
   }
 
+#if TRACE
+  //cout << "return from endElement " << qName << " step[" << depth << "]" << step[depth] << endl ;
+#endif
   return TRUE;
 }
 
@@ -1055,7 +1210,7 @@ bool GraphBase::XmlHandler::characters( const QString& ch ) {
   depth -= 1 ;
 #if TRACE
   MESSAGE( "characters step[" << depth << "]=" << step[depth]
-       << " ch " << ch << " fieldvalue_must_be_NULL " << fieldvalue[depth] )
+       << " ch " << ch << " fieldvalue_must_be_NULL : '" << fieldvalue[depth] << "'" ) ;
 #endif
   if ( depth < 0 || fieldvalue[depth] != NULLSTRING )
     return returnfalse( this , "characters " , ch ) ;
@@ -1067,7 +1222,7 @@ bool GraphBase::XmlHandler::characters( const QString& ch ) {
 
 
 QString GraphBase::XmlHandler::errorString() {
-  cout << "the document is not in the quote file format" << endl ;
+  //cout << "the document is not in the quote file format" << endl ;
   return "the document is not in the quote file format";
 }
 
@@ -1077,7 +1232,7 @@ bool GraphBase::XmlHandler::fatalError( const QXmlParseException& exception ) {
     .arg( exception.message() )
     .arg( exception.lineNumber() )
     .arg( exception.columnNumber() );
-  cout << "GraphBase::XmlHandler::fatalError " << errorProt.latin1() << endl ;
+  //cout << "GraphBase::XmlHandler::fatalError " << errorProt.latin1() << endl ;
   return QXmlDefaultHandler::fatalError( exception );
 }