1 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : DataFlowBase_LoadXml.cxx
28 #include "DataFlowBase_XmlHandler.hxx"
32 #include <qmessagebox.h>
35 // Fonction Load qui utilise un Parser de fichier xml de Dataflow
36 // Utilise DataFlowEditor_XmlHandler.hxx et .cxx
38 //#include "SALOME_NamingService.hxx"
40 //#include <SALOMEconfig.h>
41 //#include CORBA_CLIENT_HEADER(SALOME_SuperVision)
43 #include "DataFlowBase_Graph.hxx"
45 bool GraphBase::Graph::LoadXml( CORBA::ORB_ptr _Orb ,
46 const char* myFileName ,
47 GraphBase::SGraph & aDataFlow )
49 char * FileName = new char[ strlen( myFileName ) + 5 ] ;
50 strcpy( FileName , myFileName ) ;
51 QString aqstrFileName(FileName);
52 QFile afile( aqstrFileName);
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 ) ) {
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 );
76 // QMessageBox::critical( 0,
77 // QString( "INF_PARSE_ERROR" ),
78 // QString( myXmlHandler->errorProtocol() ) );
82 aDataFlow = myXmlHandler->GetDataFlow() ;
84 // Dataflow is now loaded.