]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphBase/DataFlowBase_LoadXml.cxx
Salome HOME
NRI : Merge from V1_2.
[modules/superv.git] / src / GraphBase / DataFlowBase_LoadXml.cxx
1 //  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DataFlowBase_LoadXml.cxx
25 //  Module : SUPERV
26
27 using namespace std;
28 #include "DataFlowBase_XmlHandler.hxx"
29
30 //#include <qaccel.h>
31 #include <qxml.h>
32 #include <qmessagebox.h>
33
34 // Pour Jean
35 // Fonction Load qui utilise un Parser de fichier xml de Dataflow
36 // Utilise DataFlowEditor_XmlHandler.hxx et .cxx
37
38 //#include "SALOME_NamingService.hxx"
39
40 //#include <SALOMEconfig.h>
41 //#include CORBA_CLIENT_HEADER(SALOME_SuperVision)
42
43 #include "DataFlowBase_Graph.hxx"
44
45 bool GraphBase::Graph::LoadXml( CORBA::ORB_ptr _Orb ,
46                                 const char* myFileName ,
47                                 GraphBase::SGraph & aDataFlow )
48 {
49   char * FileName = new char[ strlen( myFileName ) + 5 ] ;
50   strcpy( FileName , myFileName ) ;
51   QString aqstrFileName(FileName);
52   QFile afile( aqstrFileName);
53
54   if ( !afile.exists() || !afile.open( IO_ReadOnly ) )  {
55     strcat( FileName , ".xml" ) ;
56     aqstrFileName = QString(FileName);
57     QFile afile( aqstrFileName );
58     if ( !afile.exists() || !afile.open( IO_ReadOnly ) )  {
59       return false;
60     }
61     afile.close();
62   }
63   else
64     afile.close();
65
66   QString qstrFileName(FileName);
67   QFile file( qstrFileName);
68   GraphBase::XmlHandler::XmlHandler * myXmlHandler = new GraphBase::XmlHandler::XmlHandler( _Orb , true );
69   QXmlInputSource source( file );
70   QXmlSimpleReader reader;
71   reader.setContentHandler( myXmlHandler );
72   reader.setErrorHandler( myXmlHandler );
73   bool ok = reader.parse( source );
74   file.close();
75   if ( !ok ) {
76 //    QMessageBox::critical( 0,
77 //                         QString( "INF_PARSE_ERROR" ),
78 //                         QString( myXmlHandler->errorProtocol() ) );
79     return false;
80   }
81
82   aDataFlow = myXmlHandler->GetDataFlow() ;
83   delete myXmlHandler ;
84   // Dataflow is now loaded.
85   return true ;
86 }
87
88