From: mzn Date: Mon, 15 Oct 2007 13:55:54 +0000 (+0000) Subject: Porting KERNEL on new XML reader. X-Git-Tag: V4_1_0a2~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=22a04522660879133601966f3cbacdf06fd7898f;p=modules%2Fkernel.git Porting KERNEL on new XML reader. --- diff --git a/configure.ac b/configure.ac index 334762482..92a8266bc 100644 --- a/configure.ac +++ b/configure.ac @@ -244,20 +244,20 @@ AC_SUBST_FILE(CORBA) echo echo --------------------------------------------- -echo Testing QT +echo BOOST Library echo --------------------------------------------- echo -# Qt must be kept because kernel makes use of qxml and some other -# non-graphical stuff. -CHECK_QT + +CHECK_BOOST echo echo --------------------------------------------- -echo BOOST Library +echo Testing libxml2 echo --------------------------------------------- echo -CHECK_BOOST +CHECK_LIBXML + fi # --- end test corba @@ -434,7 +434,7 @@ summary $basic_mandatory_products check_fatal_error $basic_mandatory_products echo -corba_mandatory_products="omniORB_ok qt_ok boost_ok" +corba_mandatory_products="omniORB_ok boost_ok" if test x$corba_gen = xtrue; then echo --- CORBA mandatory products - default configuration: summary $corba_mandatory_products diff --git a/salome_adm/unix/config_files/Makefile.am b/salome_adm/unix/config_files/Makefile.am index 2cd5f15ce..0c325253e 100644 --- a/salome_adm/unix/config_files/Makefile.am +++ b/salome_adm/unix/config_files/Makefile.am @@ -73,7 +73,6 @@ check_mpich.m4 \ check_omniorb.m4 \ check_opengl.m4 \ check_openpbs.m4 \ -check_qt.m4 \ check_sockets.m4 \ check_swig.m4 \ check_withihm.m4 \ diff --git a/salome_adm/unix/config_files/check_cppunit.m4 b/salome_adm/unix/config_files/check_cppunit.m4 index 4029ea190..e78b4fa24 100644 --- a/salome_adm/unix/config_files/check_cppunit.m4 +++ b/salome_adm/unix/config_files/check_cppunit.m4 @@ -69,8 +69,7 @@ else AC_LANG_CPLUSPLUS CPPFLAGS_old=$CPPFLAGS CPPFLAGS="$CPPFLAGS -I$CPPUNIT_INCLUDES" - CPPFLAGS="$CPPFLAGS $QT_INCLUDES" - + AC_CHECK_HEADER(cppunit/extensions/HelperMacros.h,cppunit_ok=yes,cppunit_ok=no) CPPFLAGS=$CPPFLAGS_old diff --git a/salome_adm/unix/config_files/check_libxml.m4 b/salome_adm/unix/config_files/check_libxml.m4 new file mode 100644 index 000000000..29fc1c31b --- /dev/null +++ b/salome_adm/unix/config_files/check_libxml.m4 @@ -0,0 +1,38 @@ +AC_DEFUN([CHECK_LIBXML],[ + +AC_CHECKING(for libxml) + +# Custom location of libxml2 package can be specified +# through LIBXML_DIR variable +if test "x$LIBXML_DIR" != "x" +then + CPPFLAGS="$CPPFLAGS -I$LIBXML_DIR/include/libxml2" + TMPLIBS="-L$LIBXML_DIR/lib -lxml2 $LIBS" +else + CPPFLAGS="$CPPFLAGS -I/usr/include/libxml2" + TMPLIBS="-lxml2 $LIBS" +fi + +AC_CHECK_HEADER(libxml/parser.h,libxml_ok="yes",libxml_ok="no") + +if test "x$libxml_ok" = "xyes" +then + LIBS_old=$LIBS + LIBS=$TMPLIBS + AC_CHECK_LIB(xml2,xmlInitParser,libxml_ok="yes",libxml_ok="no",) + LIBS=$LIBS_old +fi + +if test "x$libxml_ok" = "xyes" +then + LIBS=$TMPLIBS +fi + +AC_MSG_RESULT(for libxml: $libxml_ok) + +LIBXML_LIBS=$LIBS +AC_SUBST(LIBXML_LIBS) + +])dnl +dnl + diff --git a/src/Container/Makefile.am b/src/Container/Makefile.am index 483524ef7..4b681f518 100644 --- a/src/Container/Makefile.am +++ b/src/Container/Makefile.am @@ -65,7 +65,6 @@ COMMON_CPPFLAGS=\ @PYTHON_INCLUDES@ \ @MPI_INCLUDES@ \ @HDF5_INCLUDES@ \ - @QT_MT_INCLUDES@ \ -I$(srcdir)/../Basics \ -I$(srcdir)/../SALOMELocalTrace \ -I$(srcdir)/../NamingService \ diff --git a/src/LifeCycleCORBA/Makefile.am b/src/LifeCycleCORBA/Makefile.am index 6bee2cf3c..2012177ed 100644 --- a/src/LifeCycleCORBA/Makefile.am +++ b/src/LifeCycleCORBA/Makefile.am @@ -82,7 +82,6 @@ libSalomeLifeCycleCORBA_la_SOURCES = \ libSalomeLifeCycleCORBA_la_CPPFLAGS = \ $(COMMON_CPPFLAGS) \ @PYTHON_INCLUDES@ \ - @QT_MT_INCLUDES@ \ -I$(srcdir)/../Container \ -I$(srcdir)/../Notification diff --git a/src/ModuleCatalog/Makefile.am b/src/ModuleCatalog/Makefile.am index a29139fd2..b0a7fb204 100644 --- a/src/ModuleCatalog/Makefile.am +++ b/src/ModuleCatalog/Makefile.am @@ -62,8 +62,7 @@ COMMON_CPPFLAGS=\ -I$(srcdir)/../Utils \ -I$(top_builddir)/salome_adm/unix \ -I$(top_builddir)/idl \ - @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ \ - @QT_MT_INCLUDES@ + @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ # This local variable defines the list of dependant libraries common to all target in this package. COMMON_LIBS =\ @@ -85,8 +84,7 @@ libSalomeCatalog_la_CPPFLAGS =\ libSalomeCatalog_la_LDFLAGS = -no-undefined -version-info=0:0:0 libSalomeCatalog_la_LIBADD =\ - $(COMMON_LIBS) \ - @QT_MT_LIBS@ + $(COMMON_LIBS) # diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx index 82f1710b8..3c7fa944d 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx @@ -53,7 +53,9 @@ SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler() // Used in the function endElement test_path_prefix_name = "path-prefix-name"; test_computer_name = "computer-name" ; + test_computer_list = "computer-list" ; test_path_prefix = "path-prefix" ; + test_path_prefix_list = "path-prefix-list" ; test_component_name = "component-name"; test_component_username = "component-username"; @@ -99,6 +101,7 @@ SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler() test_constraint = "constraint"; + test_component_list = "component-list"; test_component="component"; if(MYDEBUG) END_OF("SALOME_ModuleCatalog_Handler"); @@ -114,11 +117,14 @@ SALOME_ModuleCatalog_Handler::~SALOME_ModuleCatalog_Handler() if(MYDEBUG) END_OF("~SALOME_ModuleCatalog_Handler()") } -//---------------------------------------------------------------------- -// Function : startDocument -// Purpose : overload handler function -//---------------------------------------------------------------------- -bool SALOME_ModuleCatalog_Handler::startDocument() + +//============================================================================= +/*! + * Processes XML document and fills the list of modules + */ +//============================================================================= + +void SALOME_ModuleCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) { if(MYDEBUG) MESSAGE("Begin parse document"); // Empty the private elements @@ -131,465 +137,393 @@ bool SALOME_ModuleCatalog_Handler::startDocument() _outDataStreamParamList.resize(0); _inParamList.resize(0); _outParamList.resize(0); - return true; -} -//---------------------------------------------------------------------- -// Function : startElement -// Purpose : overload handler function -//---------------------------------------------------------------------- -bool SALOME_ModuleCatalog_Handler::startElement(const QString&, - const QString &, - const QString& qName, - const QXmlAttributes& atts) -{ - _xml_pile.push(qName); + // Get the document root node + xmlNodePtr aCurNode = xmlDocGetRootElement(theDoc); - return true; -} + aCurNode = aCurNode->xmlChildrenNode; -//---------------------------------------------------------------------- -// Function : endElement -// Purpose : overload handler function -//---------------------------------------------------------------------- -bool SALOME_ModuleCatalog_Handler::endElement(const QString&, - const QString &, - const QString& qName) -{ - QString parent, grandparent; - _xml_pile.pop(); - if (!_xml_pile.empty()) { - parent = _xml_pile.top(); - _xml_pile.pop(); - if (!_xml_pile.empty()) grandparent = _xml_pile.top(); - _xml_pile.push(parent); - } - - // Path prefix - - // tag test_path_prefix_name - if((qName.compare(test_path_prefix_name)==0)) { - _pathPrefix.path = content; - return true; - } - - // tag test_computer_name - if((qName.compare(test_computer_name)==0)) { - _pathPrefix.listOfComputer.push_back(content); - return true; - } - - // tag test_path_prefix - if((qName.compare(test_path_prefix)==0)) { - _pathList.push_back(_pathPrefix); - _pathPrefix.listOfComputer.resize(0); - return true; - } - - // Component identification - - // tag test_component_name - if((qName.compare(test_component_name)==0)) { - _aModule.name = content ; - return true; - } - - // tag test_component_username - if((qName.compare(test_component_username)==0)) { - _aModule.username = content ; - return true; - } - - // tag test_component_type - if((qName.compare(test_component_type)==0)) - { - if ((content.compare("MESH") == 0) || - (content.compare("Mesh") == 0) || - (content.compare("mesh") == 0)) - _aModule.type = MESH ; - else if((content.compare("MED") == 0) || - (content.compare("Med") == 0) || - (content.compare("med") == 0)) - _aModule.type = Med ; - else if((content.compare("GEOM") == 0) || - (content.compare("Geom") == 0) || - (content.compare("geom") == 0)) - _aModule.type = GEOM ; - else if((content.compare("SOLVER") == 0) || - (content.compare("Solver") == 0) || - (content.compare("solver") == 0)) - _aModule.type = SOLVER ; - else if((content.compare("SUPERV") == 0) || - (content.compare("Superv") == 0) || - (content.compare("Supervision") == 0) || - (content.compare("superv") == 0)) - _aModule.type = SUPERV ; - else if((content.compare("DATA") == 0) || - (content.compare("Data") == 0) || - (content.compare("data") == 0)) - _aModule.type = DATA ; - else if((content.compare("VISU") == 0) || - (content.compare("Visu") == 0) || - (content.compare("visu") == 0)) - _aModule.type = VISU ; - else if((content.compare("OTHER") == 0) || - (content.compare("Other") == 0) || - (content.compare("other") == 0)) - _aModule.type = OTHER ; - else - // If it'not in all theses cases, the type is affected to OTHER - _aModule.type = OTHER ; - return true; - } - - // tag test_component_multistudy - if((qName.compare(test_component_multistudy)==0)) { - _aModule.multistudy = atoi(content.c_str()) ; - return true; - } - - // tag test_component_impltype - if((qName.compare(QString(test_component_impltype))==0)) - _aModule.implementationType = atoi(content.c_str()) ; - - // tag test_component_icon - if((qName.compare(test_component_icon)==0)) { - _aModule.icon = content ; - return true; - } - - // tag test_component_version - if((qName.compare(test_component_version)==0)) { - _aModule.version = content ; - return true; - } - - // tag test_component_comment - if((qName.compare(test_component_comment)==0)) { - _aModule.comment = content ; - return true; - } - - // interface identification - - // tag test_interface_name - if ((qName.compare(test_interface_name)==0)) { - _aInterface.name = content ; - return true; - } - - // Service identification - - // tag test_service_name - if ((qName.compare(test_service_name)==0)) { - _aService.name = content ; - return true; - } - - //tag test_defaultservice - if ((qName.compare(test_defaultservice)==0)) { - _aService.byDefault = atoi(content.c_str()) ; - return true; - } - - //tag test_typeofnode - if((qName.compare(QString(test_typeofnode))==0)) - _aService.typeOfNode = atoi(content.c_str()) ; - - // Parameter in - - // tag test_inDataStreamParameter_type - if ((qName.compare(test_inDataStreamParameter_type)==0)) { - if (grandparent.compare(test_inDataStreamParameter_list) == 0) - _inDataStreamParam.type = content ; - else - _inParam.type = content ; - return true; - } - - // tag test_inParameter_type - if ((qName.compare(test_inParameter_type)==0)) { - if (grandparent.compare(test_inDataStreamParameter_list) == 0) - _inDataStreamParam.type = content ; - else - _inParam.type = content ; - return true; - } - - //tag test_inDataStreamParameter_name - if ((qName.compare(test_inDataStreamParameter_name)==0)) { - if (grandparent.compare(test_inDataStreamParameter_list) == 0) - _inDataStreamParam.name = content ; - else - _inParam.name = content ; - return true; - } - - //tag test_inParameter_name - if ((qName.compare(test_inParameter_name)==0)) { - if(MYDEBUG) SCRUTE(parent); - if(MYDEBUG) SCRUTE(grandparent); - if (grandparent.compare(test_inDataStreamParameter_list) == 0) - _inDataStreamParam.name = content ; - else - _inParam.name = content ; - return true; - } - - //tag test_inDataStreamParameter_dependency - if ((qName.compare(test_inDataStreamParameter_dependency)==0)) { - _inDataStreamParam.dependency = content ; - return true; - } - - //tag test_inParameter - if ((qName.compare(test_inParameter)==0)) + // Processing the document nodes + while(aCurNode != NULL) { - if (parent.compare(test_inParameter_list)==0) { + // Process path prefix list (tag test_path_prefix_list) + if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_path_prefix_list) ) + { + xmlNodePtr aCurSubNode = aCurNode->xmlChildrenNode; + while(aCurSubNode != NULL) + { + // Forming a PathPrefix structure (tag test_path_prefix) + if ( xmlStrcmp(aCurSubNode->name, (const xmlChar*)test_path_prefix) ) { + aCurSubNode = aCurSubNode->next; + continue; + } + + xmlNodePtr aCurSubSubNode = aCurSubNode->xmlChildrenNode; + while(aCurSubSubNode != NULL) + { + // Tag test_path_prefix_name + if ( !xmlStrcmp(aCurSubSubNode->name, (const xmlChar*)test_path_prefix_name) ) + _pathPrefix.path = (const char*)aCurSubSubNode->content; + + // Tag test_computer_list + if ( !xmlStrcmp(aCurSubSubNode->name, (const xmlChar*)test_computer_list) ) { + xmlNodePtr aComputerNode = aCurSubSubNode->xmlChildrenNode; + while (aComputerNode != NULL) { + // Tag test_computer_name + if ( !xmlStrcmp(aComputerNode->name, (const xmlChar*) test_computer_name) ) + _pathPrefix.listOfComputer.push_back((const char*)aComputerNode->content); + + aComputerNode = aComputerNode->next; + } + } + + aCurSubSubNode = aCurSubSubNode->next; + } + + _pathList.push_back(_pathPrefix); + _pathPrefix.listOfComputer.resize(0); + + aCurSubNode = aCurSubNode->next; + } + } + + //@ Process list of components (tag test_component_list) + if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_component_list) ) + { + xmlNodePtr aComponentNode = aCurNode->xmlChildrenNode; + while(aComponentNode != NULL) + { + // Do not process tags differ from test_component here + if ( xmlStrcmp(aComponentNode->name, (const xmlChar*)test_component) ) { + aComponentNode = aComponentNode->next; + continue; + } + + // Component identification + + // Empty temporary structures + _aModule.name = ""; + _aModule.constraint = ""; + _aModule.icon=""; + _aModule.interfaces.resize(0); + + xmlNodePtr aComponentSubNode = aComponentNode->xmlChildrenNode; + while(aComponentSubNode != NULL) { + + std::string aContent = (const char*)aComponentSubNode->content; + + // Tag test_component_name + if ( !xmlStrcmp(aComponentSubNode->name, (const xmlChar*)test_component_name) ) + _aModule.name = aContent; + + // Tag test_component_username + if ( !xmlStrcmp(aComponentSubNode->name, (const xmlChar*)test_component_username) ) + _aModule.username = aContent; + + // Tag test_component_type + if ( !xmlStrcmp(aComponentSubNode->name, (const xmlChar*)test_component_type) ) { + std::string aType = aContent; + + if ((aType.compare("MESH") == 0) || + (aType.compare("Mesh") == 0) || + (aType.compare("mesh") == 0)) + _aModule.type = MESH ; + else if((aType.compare("MED") == 0) || + (aType.compare("Med") == 0) || + (aType.compare("med") == 0)) + _aModule.type = Med ; + else if((aType.compare("GEOM") == 0) || + (aType.compare("Geom") == 0) || + (aType.compare("geom") == 0)) + _aModule.type = GEOM ; + else if((aType.compare("SOLVER") == 0) || + (aType.compare("Solver") == 0) || + (aType.compare("solver") == 0)) + _aModule.type = SOLVER ; + else if((aType.compare("SUPERV") == 0) || + (aType.compare("Superv") == 0) || + (aType.compare("Supervision") == 0) || + (aType.compare("superv") == 0)) + _aModule.type = SUPERV ; + else if((aType.compare("DATA") == 0) || + (aType.compare("Data") == 0) || + (aType.compare("data") == 0)) + _aModule.type = DATA ; + else if((aType.compare("VISU") == 0) || + (aType.compare("Visu") == 0) || + (aType.compare("visu") == 0)) + _aModule.type = VISU ; + else if((aType.compare("OTHER") == 0) || + (aType.compare("Other") == 0) || + (aType.compare("other") == 0)) + _aModule.type = OTHER ; + else + // If it'not in all theses cases, the type is affected to OTHER + _aModule.type = OTHER ; + } + + // Tag test_component_multistudy + if ( !xmlStrcmp(aComponentSubNode->name, (const xmlChar*)test_component_multistudy) ) + _aModule.multistudy = atoi( aContent.c_str() ); + + // Tag test_component_impltype + if ( !xmlStrcmp(aComponentSubNode->name, (const xmlChar*)test_component_impltype) ) + _aModule.implementationType = atoi(aContent.c_str()); + + // Tag test_component_icon + if ( !xmlStrcmp(aComponentSubNode->name, (const xmlChar*)test_component_icon) ) + _aModule.icon = aContent; + + // Tag test_component_version + if ( !xmlStrcmp(aComponentSubNode->name, (const xmlChar*)test_component_version) ) + _aModule.version = aContent; + + // Tag test_component_comment + if ( !xmlStrcmp(aComponentSubNode->name, (const xmlChar*)test_component_comment) ) + _aModule.comment = aContent; + + // Tag test_constraint + if ( !xmlStrcmp(aComponentSubNode->name, (const xmlChar*)test_constraint) ) + _aModule.constraint = aContent; + + // Process tag test_interface_list: + if ( !xmlStrcmp(aComponentSubNode->name, (const xmlChar*)test_interface_list) ) { + + // Form an interface list for the component + xmlNodePtr aSubNode = aComponentSubNode->xmlChildrenNode; + while(aSubNode != NULL) { + // Tag test_interface_name + if ( !xmlStrcmp(aSubNode->name, (const xmlChar*)test_interface_name) ) + _aInterface.name = (const char*)aSubNode->content; + + // Tag test_service_list + if ( !xmlStrcmp(aSubNode->name, (const xmlChar*)test_service_list) ) { + // Form a service list for the interface + xmlNodePtr aCompServiceNode = aSubNode->xmlChildrenNode; + while(aCompServiceNode != NULL) { + // Tag test_service + if ( !xmlStrcmp(aCompServiceNode->name, (const xmlChar*)test_interface_name) ) { + xmlNodePtr aCompServiceSubNode = aCompServiceNode->xmlChildrenNode; + while(aCompServiceSubNode != NULL) { + // Tag test_service_name + if ( !xmlStrcmp(aCompServiceSubNode->name, (const xmlChar*)test_service_name) ) + _aService.name = (const char*)aCompServiceSubNode->content; + + // Tag test_defaultservice + if ( !xmlStrcmp(aCompServiceSubNode->name, (const xmlChar*)test_defaultservice) ) + _aService.byDefault = (const char*)aCompServiceSubNode->content; + + // Tag test_typeofnode + if ( !xmlStrcmp(aCompServiceSubNode->name, (const xmlChar*)test_typeofnode) ) + _aService.typeOfNode = (const char*)aCompServiceSubNode->content; + + // Tag test_inParameter_list + if ( !xmlStrcmp(aCompServiceSubNode->name, (const xmlChar*)test_inParameter_list) ) { + xmlNodePtr aParamNode = aCompServiceSubNode->xmlChildrenNode; + while(aParamNode != NULL) { + + // Tag test_inParameter + if (xmlStrcmp(aParamNode->name, (const xmlChar*)test_inParameter)) { + aParamNode = aParamNode->next; + continue; + } + + xmlNodePtr aParamItemNode = aParamNode->xmlChildrenNode; + while(aParamItemNode != NULL) { + + // Tag test_inParameter_name + if ( !xmlStrcmp(aParamItemNode->name, (const xmlChar*)test_inParameter_name) ) + _inParam.name = (const char*)aParamItemNode->content; + + // Tag test_inParameter_type + if ( !xmlStrcmp(aParamItemNode->name, (const xmlChar*)test_inParameter_type) ) + _inParam.type = (const char*)aParamItemNode->content; + + aParamItemNode = aParamItemNode->next; + } + + _inParamList.push_back(_inParam) ; - if(MYDEBUG) MESSAGE("add inParameter : " << _inParam.name); - _inParamList.push_back(_inParam) ; + // Empty temporary structures + _inParam.type = ""; + _inParam.name = ""; + + aParamNode = aParamNode->next; + } + + _aService.inParameters = _inParamList; + _inParamList.resize(0); + } + + // Tag test_outParameter_list + if ( !xmlStrcmp(aCompServiceSubNode->name, (const xmlChar*)test_outParameter_list) ) { + xmlNodePtr aParamNode = aCompServiceSubNode->xmlChildrenNode; + while(aParamNode != NULL) { + + // Tag test_outParameter + if (xmlStrcmp(aParamNode->name, (const xmlChar*)test_outParameter)) { + aParamNode = aParamNode->next; + continue; + } + + xmlNodePtr aParamItemNode = aParamNode->xmlChildrenNode; + while(aParamItemNode != NULL) { + + // Tag test_outParameter_name + if ( !xmlStrcmp(aParamItemNode->name, (const xmlChar*)test_outParameter_name) ) + _outParam.name = (const char*)aParamItemNode->content; + + // Tag test_outParameter_type + if ( !xmlStrcmp(aParamItemNode->name, (const xmlChar*)test_outParameter_type) ) + _outParam.type = (const char*)aParamItemNode->content; + + aParamItemNode = aParamItemNode->next; + } + + _outParamList.push_back(_outParam) ; - // Empty temporary structures - _inParam.type = ""; - _inParam.name = ""; - } - else if ((qName.compare(test_inDataStreamParameter)==0)) { + // Empty temporary structures + _outParam.type = ""; + _outParam.name = ""; + + aParamNode = aParamNode->next; + } + + _aService.outParameters = _outParamList; + _outParamList.resize(0); + } + + //@ Tag test_inDataStreamParameter_list + if ( !xmlStrcmp(aCompServiceSubNode->name, (const xmlChar*)test_inDataStreamParameter_list) ) { + xmlNodePtr aParamNode = aCompServiceSubNode->xmlChildrenNode; + while(aParamNode != NULL) { + + // Tag test_inDataStreamParameter + if (xmlStrcmp(aParamNode->name, (const xmlChar*)test_inDataStreamParameter)) { + aParamNode = aParamNode->next; + continue; + } + + xmlNodePtr aParamItemNode = aParamNode->xmlChildrenNode; + while(aParamItemNode != NULL) { + + // Tag test_inDataStreamParameter_name + if ( !xmlStrcmp(aParamItemNode->name, (const xmlChar*)test_inDataStreamParameter_name) ) + _inDataStreamParam.name = (const char*)aParamItemNode->content; + + // Tag test_inDataStreamParameter_type + if ( !xmlStrcmp(aParamItemNode->name, (const xmlChar*)test_inDataStreamParameter_type) ) + _inDataStreamParam.type = (const char*)aParamItemNode->content; + + // Tag test_inDataStreamParameter_dependency + if ( !xmlStrcmp(aParamItemNode->name, (const xmlChar*)test_inDataStreamParameter_dependency) ) + _inDataStreamParam.dependency = (const char*)aParamItemNode->content; + + aParamItemNode = aParamItemNode->next; + } + + _inDataStreamParamList.push_back(_inDataStreamParam) ; - if(MYDEBUG) MESSAGE("add inDataStreamParameter : " << _inDataStreamParam.name); - _inDataStreamParamList.push_back(_inDataStreamParam) ; + // Empty temporary structures + _inDataStreamParam.type = ""; + _inDataStreamParam.name = ""; + _inDataStreamParam.dependency = ""; + + aParamNode = aParamNode->next; + } + + _aService.inDataStreamParameters = _inDataStreamParamList; + _inDataStreamParamList.resize(0); + } + + // Tag test_outDataStreamParameter_list + if ( !xmlStrcmp(aCompServiceSubNode->name, (const xmlChar*)test_outDataStreamParameter_list) ) { + xmlNodePtr aParamNode = aCompServiceSubNode->xmlChildrenNode; + while(aParamNode != NULL) { + + // Tag test_outDataStreamParameter + if (xmlStrcmp(aParamNode->name, (const xmlChar*)test_outDataStreamParameter)) { + aParamNode = aParamNode->next; + continue; + } + + xmlNodePtr aParamItemNode = aParamNode->xmlChildrenNode; + while(aParamItemNode != NULL) { + + // Tag test_outDataStreamParameter_name + if ( !xmlStrcmp(aParamItemNode->name, (const xmlChar*)test_outDataStreamParameter_name) ) + _outDataStreamParam.name = (const char*)aParamItemNode->content; + + // Tag test_outDataStreamParameter_type + if ( !xmlStrcmp(aParamItemNode->name, (const xmlChar*)test_outDataStreamParameter_type) ) + _outDataStreamParam.type = (const char*)aParamItemNode->content; + + // Tag test_outDataStreamParameter_dependency + if ( !xmlStrcmp(aParamItemNode->name, (const xmlChar*)test_outDataStreamParameter_dependency) ) + _outDataStreamParam.dependency = (const char*)aParamItemNode->content; + + aParamItemNode = aParamItemNode->next; + } + + _outDataStreamParamList.push_back(_outDataStreamParam) ; - // Empty temporary structures - _inDataStreamParam.type = ""; - _inDataStreamParam.name = ""; - _inDataStreamParam.dependency = ""; - } - return true; + // Empty temporary structures + _outDataStreamParam.type = ""; + _outDataStreamParam.name = ""; + _outDataStreamParam.dependency = ""; + + aParamNode = aParamNode->next; + } + + _aService.outDataStreamParameters = _outDataStreamParamList; + _outDataStreamParamList.resize(0); + } + + aCompServiceSubNode = aCompServiceSubNode->next; + } + + + // Put formed service into the list + _serviceList.push_back(_aService); + + // Empty temporary structures + _aService.name = ""; + _aService.typeOfNode = 1; + _aService.inParameters.resize(0); + _aService.outParameters.resize(0); + _aService.inDataStreamParameters.resize(0); + _aService.outDataStreamParameters.resize(0); + } + + aCompServiceNode = aCompServiceNode->next; + } + + _aInterface.services = _serviceList ; + + // Empty temporary structures + _serviceList.resize(0); + _interfaceList.push_back(_aInterface); + _aInterface.name =""; + _aInterface.services.resize(0); + } + + aSubNode = aSubNode->next; + } + + _aModule.interfaces = _interfaceList ; + _interfaceList.resize(0); + } + + + aComponentSubNode = aComponentSubNode->next; + } + + + aComponentNode = aComponentNode->next; + } + } + + + aCurNode = aCurNode->next; } - - //tag test_inParameter_list - if((qName.compare(test_inParameter_list)==0)) - { - if(MYDEBUG) SCRUTE(_inParamList.size()); - _aService.inParameters = _inParamList; - _inParamList.resize(0); - return true; - } - - //tag test_inDataStreamParameter_list - if((qName.compare(test_inDataStreamParameter_list)==0)) - { - if(MYDEBUG) SCRUTE(_inDataStreamParamList.size()); - _aService.inDataStreamParameters = _inDataStreamParamList; - _inDataStreamParamList.resize(0); - } - //tag test_outDataStreamParameter_list - if((qName.compare(test_outDataStreamParameter_list)==0)) - { - if(MYDEBUG) SCRUTE(_outDataStreamParamList.size()); - _aService.outDataStreamParameters = _outDataStreamParamList; - _outDataStreamParamList.resize(0); - return true; - } - - - - // Parameter out - if(MYDEBUG) SCRUTE(qName); - - // tag test_outParameter_type - if ((qName.compare(test_outParameter_type)==0)) { - if (grandparent.compare(test_outDataStreamParameter_list) == 0) - _outDataStreamParam.type = content ; - else - _outParam.type = content ; - return true; - } - - // tag test_outDataStreamParameter_type - if ((qName.compare(test_outDataStreamParameter_type)==0)) { - if (grandparent.compare(test_outDataStreamParameter_list) == 0) - _outDataStreamParam.type = content ; - else - _outParam.type = content ; - return true; - } - - //tag test_outParameter_name - if ((qName.compare(test_outParameter_name)==0)) { - if (grandparent.compare(test_outDataStreamParameter_list) == 0) - _outDataStreamParam.name = content ; - else - _outParam.name = content ; - return true; - } - - //tag test_outDataStreamParameter_name - if ((qName.compare(test_outDataStreamParameter_name)==0)) { - if(MYDEBUG) SCRUTE(grandparent); - if(MYDEBUG) SCRUTE(test_outDataStreamParameter_list); - if (grandparent.compare(test_outDataStreamParameter_list) == 0) - _outDataStreamParam.name = content ; - else - _outParam.name = content ; - return true; - } - - //tag test_outParameter_dependency - if ((qName.compare(test_outDataStreamParameter_dependency)==0)) { - _outDataStreamParam.dependency = content ; - return true; - } - - //tag test_outParameter - if ((qName.compare(test_outParameter)==0)) - { - if (parent.compare(test_outParameter_list)==0) { - - if(MYDEBUG) MESSAGE("add outParameter : " << _outParam.name); - _outParamList.push_back(_outParam) ; - - // Empty temporary structures - _outParam.type = ""; - _outParam.name = ""; - } - else if ((qName.compare(test_outDataStreamParameter)==0)) { - - if(MYDEBUG) MESSAGE("add outDataStreamParameter : " << _outDataStreamParam.name); - _outDataStreamParamList.push_back(_outDataStreamParam) ; - - // Empty temporary structures - _outDataStreamParam.type = ""; - _outDataStreamParam.name = ""; - _outDataStreamParam.dependency = ""; - } - return true; - } - - //tag test_outParameter_list - if((qName.compare(test_outParameter_list)==0)) - { - if(MYDEBUG) SCRUTE(_outParamList.size()); - _aService.outParameters = _outParamList; - _outParamList.resize(0); - return true; - } - - // tag test_service - if((qName.compare(test_service)==0)) - { - _serviceList.push_back(_aService); - - // Empty temporary structures - _aService.name = ""; - _aService.typeOfNode = 1; - _aService.inParameters.resize(0); - _aService.outParameters.resize(0); - _aService.inDataStreamParameters.resize(0); - _aService.outDataStreamParameters.resize(0); - } - - // tag test_service_list - if((qName.compare(test_service_list)==0)) - { - _aInterface.services = _serviceList ; - - // Empty temporary structures - _serviceList.resize(0); - _interfaceList.push_back(_aInterface); - _aInterface.name =""; - _aInterface.services.resize(0); - - } - - //tag test_interface_list - if((qName.compare(test_interface_list)==0)) - { - _aModule.interfaces = _interfaceList ; - _interfaceList.resize(0); - } - - //tag test_constraint - if((qName.compare(test_constraint)==0)) - _aModule.constraint = content ; - - // tag test_component - if((qName.compare(test_component)==0)) - { - _moduleList.push_back(_aModule) ; - - // Empty temporary structures - _aModule.name = ""; - _aModule.constraint = ""; - _aModule.icon=""; - _aModule.interfaces.resize(0); - } - - return true; -} - -//---------------------------------------------------------------------- -// Function : characters -// Purpose : overload handler function -//---------------------------------------------------------------------- -bool SALOME_ModuleCatalog_Handler::characters(const QString& chars) -{ - content = (const char*)chars ; - return true; -} - -//---------------------------------------------------------------------- -// Function : endDocument -// Purpose : overload handler function -// Print all informations find in the catalog -// (only in DEBUG mode!!) -//---------------------------------------------------------------------- -#include -bool SALOME_ModuleCatalog_Handler::endDocument() -{ -// ofstream f("/tmp/logs/xxx.log", std::ofstream::app); -// f << "---------------------------------------------------------" << std::endl; - if(MYDEBUG) BEGIN_OF("endDocument"); - //_pathlist - for (unsigned int ind = 0; ind < _pathList.size(); ind++) - { - if(MYDEBUG) MESSAGE("Path :"<<_pathList[ind].path); - for (unsigned int i = 0; i < _pathList[ind].listOfComputer.size(); i++) - if(MYDEBUG) MESSAGE("Computer name :" << _pathList[ind].listOfComputer[i]); - } - - // _moduleList -// if(MYDEBUG) SCRUTE(_moduleList.size()); -// for (unsigned int ind = 0; ind < _moduleList.size(); ind++) -// { -// f << _moduleList[ind] << std::endl; -// } - - if(MYDEBUG) MESSAGE("Document parsed"); - if(MYDEBUG) END_OF("endDocument"); - return true; -} - -//---------------------------------------------------------------------- -// Function : errorProtocol -// Purpose : overload handler function -//---------------------------------------------------------------------- -QString SALOME_ModuleCatalog_Handler::errorProtocol() -{ - return errorProt ; -} - - -//---------------------------------------------------------------------- -// Function : fatalError -// Purpose : overload handler function -//---------------------------------------------------------------------- -bool SALOME_ModuleCatalog_Handler::fatalError(const QXmlParseException& exception) -{ - errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) - .arg( exception.message() ) - .arg( exception.lineNumber() ) - .arg( exception.columnNumber() ); - - return QXmlDefaultHandler::fatalError( exception ); } diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx index 01870cf85..d8c27c5a8 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx @@ -32,12 +32,14 @@ #include #include "SALOME_ModuleCatalog_Parser.hxx" -#include + #include #include #include -class MODULECATALOG_EXPORT SALOME_ModuleCatalog_Handler : public QXmlDefaultHandler +#include + +class MODULECATALOG_EXPORT SALOME_ModuleCatalog_Handler { public: //! standard constructor @@ -46,140 +48,84 @@ public: //! standard destructor virtual ~SALOME_ModuleCatalog_Handler(); - - //! method to overload handler function startDocument - /*! Is called before a xml file is parsed - \return true if no error was detected - */ - virtual bool startDocument(); - - - //! method to overload handler function startElement - /*! - \param QString argument by value - \param QString argument by value - \param QString argument by value - \param QXmlAttributes argument by value - \return true if no error was detected - */ - virtual bool startElement(const QString&, const QString &, - const QString& qName, const QXmlAttributes& atts); - - //! method to overload handler function endElement - /*! - \param QString argument by value - \param QString argument by value - \param QString argument by value - \return true if no error was detected - \sa _Find - */ - virtual bool endElement(const QString&, const QString &, - const QString& qName); - - - //! method to overload handler function characters - /*! - \param QString argument by value - \return true if no error was detected - */ - virtual bool characters(const QString& chars); - - //! method to overload handler function endDocument - /*! Is called at the end of the parsing - \return true if no error was detected - */ - virtual bool endDocument(); - - //! method to overload handler function errorProtocol - /*! - \return the error message - */ - virtual QString errorProtocol(); - - //! method to overload handler function fatalError - /*! - \param QXmlParseExecption argument by value - \return true if no error was detected - */ - virtual bool fatalError(const QXmlParseException& exception); + void ProcessXmlDocument(xmlDocPtr theDoc); private: - QString errorProt ; - - std::string content; - QString test_path_prefix_name ; - QString test_computer_name ; - QString test_path_prefix ; - - QString test_component_name; - QString test_component_username; - QString test_component_type ; - QString test_component_multistudy ; - QString test_component_icon ; - QString test_component_impltype; - QString test_component_version; - QString test_component_comment; - - QString test_interface_name; - - QString test_service_name; - QString test_defaultservice; - QString test_typeofnode; - - QString test_inParameter_type; - QString test_inParameter_name; - QString test_inParameter; - QString test_inParameter_list; - - QString test_outParameter_type; - QString test_outParameter_name; - QString test_outParameter; - QString test_outParameter_list; - - QString test_inDataStreamParameter_type; - QString test_inDataStreamParameter_name; - QString test_inDataStreamParameter_dependency; - QString test_inDataStreamParameter; - QString test_inDataStreamParameter_list; - - QString test_outDataStreamParameter_type; - QString test_outDataStreamParameter_name; - QString test_outDataStreamParameter_dependency; - QString test_outDataStreamParameter; - QString test_outDataStreamParameter_list; - - QString test_service; - QString test_service_list; - QString test_interface_list; - QString test_constraint; + const char *test_path_prefix_name ; + const char *test_computer_name ; + const char *test_computer_list ; + const char *test_path_prefix ; + const char *test_path_prefix_list; + + const char *test_component_name; + const char *test_component_username; + const char *test_component_type ; + const char *test_component_multistudy ; + const char *test_component_icon ; + const char *test_component_impltype; + const char *test_component_version; + const char *test_component_comment; + + const char *test_interface_name; + + const char *test_service_name; + const char *test_defaultservice; + const char *test_typeofnode; + + const char *test_inParameter_type; + const char *test_inParameter_name; + const char *test_inParameter; + const char *test_inParameter_list; + + const char *test_outParameter_type; + const char *test_outParameter_name; + const char *test_outParameter; + const char *test_outParameter_list; + + const char *test_inDataStreamParameter_type; + const char *test_inDataStreamParameter_name; + const char *test_inDataStreamParameter_dependency; + const char *test_inDataStreamParameter; + const char *test_inDataStreamParameter_list; + + const char *test_outDataStreamParameter_type; + const char *test_outDataStreamParameter_name; + const char *test_outDataStreamParameter_dependency; + const char *test_outDataStreamParameter; + const char *test_outDataStreamParameter_list; + + const char *test_service; + const char *test_service_list; + const char *test_interface_list; + const char *test_constraint; + + const char *test_component_list; + const char *test_component; - QString test_component; - ParserPathPrefix _pathPrefix; - + ParserComponent _aModule; - - + + ParserInterfaces _interfaceList; ParserInterface _aInterface; - + ParserServices _serviceList; ParserService _aService; ParserParameters _inParamList; ParserParameter _inParam; - + ParserParameters _outParamList; ParserParameter _outParam; - + ParserDataStreamParameters _inDataStreamParamList; ParserDataStreamParameter _inDataStreamParam; - + ParserDataStreamParameters _outDataStreamParamList; ParserDataStreamParameter _outDataStreamParam; - std::stack _xml_pile; }; #endif // SALOME_CATALOG_HANDLER_H diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index 55dd3cede..b4d7edbd1 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -31,8 +31,6 @@ #include #include -#include -#include using namespace std; #include "utilities.h" @@ -46,6 +44,26 @@ static int MYDEBUG = 1; static const char* SEPARATOR = "::"; static const char* OLD_SEPARATOR = ":"; + +list& splitStringToList(string theString, string theSeparator) +{ + list aList; + + int sepLen = theSeparator.length(); + + int startPos = 0, sepPos = theString.find(theSeparator, startPos); + + for ( ; (startPos < theString.size()) && (sepPos != string::npos); sepPos = theString.find(theSeparator, startPos)) + { + string anItem = theString.substr(startPos, sepPos - startPos); + if (anItem.length() > 0) + aList.push_back(anItem); + startPos = sepPos + sepLen; + } + + return aList; +} + //---------------------------------------------------------------------- // Function : SALOME_ModuleCatalogImpl // Purpose : Constructor @@ -111,31 +129,35 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA: // Affect the _general_module_list and _general_path_list members // with the common catalog - QStringList dirList; + list dirList; + #ifdef WNT - dirList = QStringList::split( SEPARATOR, _general_path, - false ); // skip empty entries + dirList = splitStringToList(_general_path, SEPARATOR); #else //check for new format - int isNew = QString( _general_path ).contains(SEPARATOR); - if ( isNew > 0 ) { + bool isNew = (std::string( _general_path ).find(SEPARATOR) != string::npos); + if ( isNew ) { //using new format - dirList = QStringList::split( SEPARATOR, _general_path, - false ); // skip empty entries + dirList = splitStringToList(_general_path, SEPARATOR); } else { //support old format - dirList = QStringList::split( OLD_SEPARATOR, _general_path, - false ); // skip empty entries + dirList =splitStringToList(_general_path, OLD_SEPARATOR); } #endif - for ( int i = 0; i < dirList.count(); i++ ) { - //QFileInfo fileInfo( dirList[ i ] ); - QFileInfo fileInfo( dirList[ i ].replace( '\"', "" ) ); //remove inverted commas from filename - if ( fileInfo.isFile() && fileInfo.exists() ) { - _parse_xml_file(fileInfo.filePath(), + for(list::iterator iter=dirList.begin();iter!=dirList.end();iter++){ + string aPath = (*iter); + //remove inverted commas from filename + while(aPath.find('\"') != string::npos) + aPath.erase(aPath.find('\"'), 1); + + FILE* aFile = fopen(aPath.c_str(), "r"); + if (aFile != NULL) { + _parse_xml_file(aPath.c_str(), _general_module_list, _general_path_list); + + fclose(aFile); } } @@ -575,16 +597,26 @@ SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file, if(MYDEBUG) SCRUTE(file); SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler(); - QFile xmlFile(file); - - QXmlInputSource source(xmlFile); - QXmlSimpleReader reader; - reader.setContentHandler( handler ); - reader.setErrorHandler( handler ); - reader.parse( source ); - xmlFile.close(); + FILE* aFile = fopen(file, "r"); + if (aFile != NULL) + { + xmlDocPtr aDoc = xmlReadFile(file, NULL, 0); + if (aDoc != NULL) + handler->ProcessXmlDocument(aDoc); + else + INFOS("ModuleCatalog: could not parse file "< #include -#include #include "utilities.h" using namespace std; +#ifdef _DEBUG_ +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif + //============================================================================= /*! * Constructor @@ -86,331 +91,219 @@ SALOME_ResourcesCatalog_Handler::~SALOME_ResourcesCatalog_Handler() const MapOfParserResourcesType& SALOME_ResourcesCatalog_Handler::GetResourcesAfterParsing() const - { - return _resources_list; - } - -//============================================================================= -/*! - * Overload handler function startDocument. - * Called before an xml file is parsed. - * Clears the list of resources. - * \return true (if no error detected...) - */ -//============================================================================= - -bool SALOME_ResourcesCatalog_Handler::startDocument() { - // MESSAGE("Begin parse document"); - - // --- Empty private elements - - _resources_list.clear(); - return true; + return _resources_list; } //============================================================================= /*! - * Overload handler function startElement. - * \param QString argument by reference (not used here ?) - * \param QString argument by reference (not used here ?) - * \param name (not used here ?) - * \param atts - * \return true if no error was detected + * Processes XML document and fills the list of resources */ //============================================================================= -bool -SALOME_ResourcesCatalog_Handler:: -startElement( const QString&, - const QString&, - const QString& name, - const QXmlAttributes& attrs ) +void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) { - for (int i = 0;i < attrs.count();i++) - { - QString qName(attrs.localName(i)); - std::string content(attrs.value(i).latin1()); + if (MYDEBUG) MESSAGE("Begin parse document"); - if ((qName.compare(QString(test_hostname)) == 0)) - _resource.DataForSort._hostName = content; - - if ((qName.compare(QString(test_alias)) == 0)) - _resource.Alias = content; - - if ((qName.compare(QString(test_protocol)) == 0)) - { - switch (content[0]) - { - - case 'r': - _resource.Protocol = rsh; - break; + // Empty private elements + _resources_list.clear(); - case 's': - _resource.Protocol = ssh; - break; + // Get the document root node + xmlNodePtr aCurNode = xmlDocGetRootElement(theDoc); - default: - // If it'not in all theses cases, the protocol is affected to rsh - _resource.Protocol = rsh; - break; - } - } - - if ((qName.compare(QString(test_mode)) == 0)) - { - switch (content[0]) + aCurNode = aCurNode->xmlChildrenNode; + + // Processing the document nodes + while(aCurNode != NULL) + { + if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_machine) ) + { + if (xmlHasProp(aCurNode, (const xmlChar*)test_hostname)) + _resource.DataForSort._hostName = (const char*)xmlGetProp(aCurNode, (const xmlChar*)test_hostname); + else + break; + + if (xmlHasProp(aCurNode, (const xmlChar*)test_alias)) + _resource.Alias = (const char*)xmlGetProp(aCurNode, (const xmlChar*)test_alias); + else + _resource.Alias = ""; + + switch ( ((const char*)xmlGetProp(aCurNode, (const xmlChar*)test_protocol))[0] ) + { + case 'r': + _resource.Protocol = rsh; + break; + case 's': + _resource.Protocol = ssh; + break; + default: + // If it'not in all theses cases, the protocol is affected to rsh + _resource.Protocol = rsh; + break; + } + + switch ( ((const char*)xmlGetProp(aCurNode, (const xmlChar*)test_mode))[0] ) { - case 'i': _resource.Mode = interactive; break; - - case 'b': + case 'b': _resource.Mode = batch; break; - default: // If it'not in all theses cases, the mode is affected to interactive _resource.Mode = interactive; break; } - } - - if ((qName.compare(QString(test_user_name)) == 0)) - _resource.UserName = content; - - if ((qName.compare(QString(test_appli_path)) == 0)) - _resource.AppliPath = content; - - if ((qName.compare(QString(test_module_name)) == 0)) - previous_module_name = content; - - if ((qName.compare(QString(test_module_path)) == 0)) - previous_module_path = content; - if ((qName.compare(QString(test_pre_req_file_path)) == 0)) - _resource.PreReqFilePath = content; - - if ((qName.compare(QString(test_os)) == 0)) - _resource.OS = content; - - if ((qName.compare(QString(test_mem_in_mb)) == 0)) - _resource.DataForSort._memInMB = atoi(content.c_str()); - - if ((qName.compare(QString(test_cpu_freq_mhz)) == 0)) - _resource.DataForSort._CPUFreqMHz = atoi(content.c_str()); - - if ((qName.compare(QString(test_nb_of_nodes)) == 0)) - _resource.DataForSort._nbOfNodes = atoi(content.c_str()); - - if ((qName.compare(QString(test_nb_of_proc_per_node)) == 0)) - _resource.DataForSort._nbOfProcPerNode = atoi(content.c_str()); + if (xmlHasProp(aCurNode, (const xmlChar*)test_user_name)) + _resource.UserName = (const char*)xmlGetProp(aCurNode, (const xmlChar*)test_user_name); + + if (xmlHasProp(aCurNode, (const xmlChar*)test_appli_path)) + _resource.AppliPath = (const char*)xmlGetProp(aCurNode, (const xmlChar*)test_appli_path); + + if (xmlHasProp(aCurNode, (const xmlChar*)test_pre_req_file_path)) + _resource.PreReqFilePath = (const char*)xmlGetProp(aCurNode, (const xmlChar*)test_pre_req_file_path); + + if (xmlHasProp(aCurNode, (const xmlChar*)test_os)) + _resource.OS = (const char*)xmlGetProp(aCurNode, (const xmlChar*)test_os); + + if (xmlHasProp(aCurNode, (const xmlChar*)test_mem_in_mb)) + _resource.DataForSort._memInMB = atoi((const char*)xmlGetProp(aCurNode, (const xmlChar*)test_mem_in_mb)); + + if (xmlHasProp(aCurNode, (const xmlChar*)test_cpu_freq_mhz)) + _resource.DataForSort._CPUFreqMHz = atoi((const char*)xmlGetProp(aCurNode, (const xmlChar*)test_cpu_freq_mhz)); + + if (xmlHasProp(aCurNode, (const xmlChar*)test_nb_of_nodes)) + _resource.DataForSort._nbOfNodes = atoi((const char*)xmlGetProp(aCurNode, (const xmlChar*)test_nb_of_nodes)); + + if (xmlHasProp(aCurNode, (const xmlChar*)test_nb_of_proc_per_node)) + _resource.DataForSort._nbOfProcPerNode = atoi((const char*)xmlGetProp(aCurNode, (const xmlChar*)test_nb_of_proc_per_node)); + + // Process modules + xmlNodePtr aCurSubNode = aCurNode->xmlChildrenNode; + while(aCurSubNode != NULL) + { + if ( !xmlStrcmp(aCurSubNode->name, (const xmlChar*)test_modules) ) + { + if (xmlHasProp(aCurSubNode, (const xmlChar*)test_module_name) && + xmlHasProp(aCurSubNode, (const xmlChar*)test_module_path)) + { + std::string aModuleName = (const char*)xmlGetProp(aCurSubNode, (const xmlChar*)test_module_name); + std::string aModulePath = (const char*)xmlGetProp(aCurSubNode, (const xmlChar*)test_module_path); + _resource.ModulesPath[aModuleName] = aModulePath; + } + } + aCurSubNode = aCurSubNode->next; + } + + int aNbNodes = _resource.DataForSort._nbOfNodes; + if( aNbNodes > 1 ){ + string clusterNode = _resource.DataForSort._hostName ; + for( int i=0; i < aNbNodes; i++ ){ + char inode[64]; + inode[0] = '\0' ; + sprintf(inode,"%s%d",clusterNode.c_str(),i+1); + std::string nodeName(inode); + _resource.DataForSort._hostName = nodeName ; + _resources_list[nodeName] = _resource; + } + } + else + _resources_list[_resource.DataForSort._hostName] = _resource; + } + + aCurNode = aCurNode->next; } - return true; -} - -//============================================================================= -/*! - * Overload handler function endElement. - * \param QString argument by reference (not used here ?) - * \param QString argument by reference (not used here ?) - * \param qName - * \return true (if no error detected ...) - */ -//============================================================================= - -bool SALOME_ResourcesCatalog_Handler:: -endElement(const QString&, - const QString&, - const QString& qName) -{ - if ((qName.compare(QString(test_modules)) == 0)) - _resource.ModulesPath[previous_module_name] = previous_module_path; - - if ((qName.compare(QString(test_machine)) == 0)){ - int nbnodes = _resource.DataForSort._nbOfNodes; - if( nbnodes > 1 ){ - string clusterNode = _resource.DataForSort._hostName ; - for(int i=0;i::const_iterator iter = + _resources_list.begin(); + iter != _resources_list.end(); + iter++) + { + SCRUTE((*iter).second.Alias); + SCRUTE((*iter).second.UserName); + SCRUTE((*iter).second.AppliPath); + SCRUTE((*iter).second.PreReqFilePath); + SCRUTE((*iter).second.OS); + SCRUTE((*iter).second.Protocol); + SCRUTE((*iter).second.Mode); + } + + MESSAGE("This is the end of document"); } - else - _resources_list[_resource.DataForSort._hostName] = _resource; - } - - return true; -} - -//============================================================================= -/*! - * Overload handler function characters. - * fills the private attribute string 'content'. - * \param chars - * \return true (if no error detected ...) - */ -//============================================================================= - -bool SALOME_ResourcesCatalog_Handler::characters(const QString& chars) -{ - content = (const char *)chars ; - return true; -} - -//============================================================================= -/*! - * Overload handler function endDocument. - * Called after the document has been parsed. - * \return true (if no error detected ...) - */ -//============================================================================= - -bool SALOME_ResourcesCatalog_Handler::endDocument() -{ -// for (map::const_iterator iter = -// _resources_list.begin(); -// iter != _resources_list.end(); -// iter++) -// { -// SCRUTE((*iter).second.Alias); -// SCRUTE((*iter).second.UserName); -// SCRUTE((*iter).second.AppliPath); -// SCRUTE((*iter).second.PreReqFilePath); -// SCRUTE((*iter).second.OS); -// SCRUTE((*iter).second.Protocol); -// SCRUTE((*iter).second.Mode); -// } - -// MESSAGE("This is the end of document"); - return true; -} - -//============================================================================= -/*! - * Overload handler function errorProtocol. - * \return the error message. - */ -//============================================================================= - -QString SALOME_ResourcesCatalog_Handler::errorProtocol() -{ - INFOS(" ------------- error protocol !"); - return errorProt; } -//============================================================================= -/*! - * Overload handler function fatalError. - * Fills the private string errorProt with details on error. - * \param exception from parser - * \return boolean (meaning ?) - */ -//============================================================================= - -bool -SALOME_ResourcesCatalog_Handler::fatalError -(const QXmlParseException& exception) -{ - INFOS(" ------------- fatal error !"); - errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) - .arg( exception.message() ) - .arg( exception.lineNumber() ) - .arg( exception.columnNumber() ); - INFOS("parser error: " << errorProt.latin1()); - - return QXmlDefaultHandler::fatalError( exception ); -} //============================================================================= /*! * Fill the document tree in xml file, used to write in an xml file. - * \param doc document to fill. + * \param theDoc document to fill. */ //============================================================================= -void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(QDomDocument& doc) +void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(xmlDocPtr theDoc) { - QDomElement root = doc.createElement("resources"); - doc.appendChild(root); + // Node pointers + xmlNodePtr root_node = NULL, node = NULL, node1 = NULL; + char string_buf[80]; + root_node = xmlNewNode(NULL, BAD_CAST "resources"); + xmlDocSetRootElement(theDoc, root_node); + for (map::iterator iter = _resources_list.begin(); iter != _resources_list.end(); iter++) { - QDomElement eltRoot = doc.createElement(test_machine); - root.appendChild( eltRoot ); - eltRoot.setAttribute((char *)test_hostname, (*iter).first.c_str()); - eltRoot.setAttribute((char *)test_alias, (*iter).second.Alias.c_str()); - + node = xmlNewChild(root_node, NULL, BAD_CAST test_machine, NULL); + xmlNewProp(node, BAD_CAST test_hostname, BAD_CAST (*iter).first.c_str()); + xmlNewProp(node, BAD_CAST test_alias, BAD_CAST (*iter).second.Alias.c_str()); + switch ((*iter).second.Protocol) { - case rsh: - eltRoot.setAttribute((char *)test_protocol, "rsh"); + xmlNewProp(node, BAD_CAST test_protocol, BAD_CAST "rsh"); break; - case ssh: - eltRoot.setAttribute((char *)test_protocol, "ssh"); - break; - + xmlNewProp(node, BAD_CAST test_protocol, BAD_CAST "ssh"); + break; default: - eltRoot.setAttribute((char *)test_protocol, "rsh"); - } + xmlNewProp(node, BAD_CAST test_protocol, BAD_CAST "rsh"); + } switch ((*iter).second.Mode) { - - case interactive: - eltRoot.setAttribute((char *)test_mode, "interactive"); + case interactive: + xmlNewProp(node, BAD_CAST test_mode, BAD_CAST "interactive"); break; - case batch: - eltRoot.setAttribute((char *)test_mode, "batch"); + xmlNewProp(node, BAD_CAST test_mode, BAD_CAST "batch"); break; - default: - eltRoot.setAttribute((char *)test_mode, "interactive"); + xmlNewProp(node, BAD_CAST test_mode, BAD_CAST "interactive"); } - eltRoot.setAttribute((char *)test_user_name, - (*iter).second.UserName.c_str()); + xmlNewProp(node, BAD_CAST test_user_name, BAD_CAST (*iter).second.UserName.c_str()); for (map::const_iterator iter2 = (*iter).second.ModulesPath.begin(); iter2 != (*iter).second.ModulesPath.end(); iter2++) { - QDomElement rootForModulesPaths = doc.createElement(test_modules); - rootForModulesPaths.setAttribute(test_module_name, - (*iter2).first.c_str()); - rootForModulesPaths.setAttribute(test_module_path, - (*iter2).second.c_str()); - eltRoot.appendChild(rootForModulesPaths); + node1 = xmlNewChild(node, NULL, BAD_CAST test_modules, NULL); + xmlNewProp(node1, BAD_CAST test_module_name, BAD_CAST (*iter2).first.c_str()); + xmlNewProp(node1, BAD_CAST test_module_path, BAD_CAST (*iter2).second.c_str()); } - eltRoot.setAttribute(test_pre_req_file_path, - (*iter).second.PreReqFilePath.c_str()); - eltRoot.setAttribute(test_os, (*iter).second.OS.c_str()); - eltRoot.setAttribute(test_mem_in_mb, - (*iter).second.DataForSort._memInMB); - eltRoot.setAttribute(test_cpu_freq_mhz, - (*iter).second.DataForSort._CPUFreqMHz); - eltRoot.setAttribute(test_nb_of_nodes, - (*iter).second.DataForSort._nbOfNodes); - eltRoot.setAttribute(test_nb_of_proc_per_node, - (*iter).second.DataForSort._nbOfProcPerNode); + xmlNewProp(node, BAD_CAST test_pre_req_file_path, BAD_CAST (*iter).second.PreReqFilePath.c_str()); + xmlNewProp(node, BAD_CAST test_os, BAD_CAST (*iter).second.OS.c_str()); + xmlNewProp(node, BAD_CAST test_mem_in_mb, BAD_CAST sprintf(string_buf, "%u", (*iter).second.DataForSort._memInMB)); + xmlNewProp(node, BAD_CAST test_cpu_freq_mhz, BAD_CAST sprintf(string_buf, "%u", (*iter).second.DataForSort._CPUFreqMHz)); + xmlNewProp(node, BAD_CAST test_nb_of_nodes, BAD_CAST sprintf(string_buf, "%u", (*iter).second.DataForSort._nbOfNodes)); + xmlNewProp(node, BAD_CAST test_nb_of_proc_per_node, BAD_CAST sprintf(string_buf, "%u", (*iter).second.DataForSort._nbOfProcPerNode)); } } diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx index 497f0dddf..560659ece 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx @@ -31,17 +31,14 @@ #include "SALOME_ResourcesCatalog_Parser.hxx" -#include #include #include -class QDomElement; - -class QDomDocument; - -class SALOME_ResourcesCatalog_Handler : public QXmlDefaultHandler - { +#include +class SALOME_ResourcesCatalog_Handler +{ + public : SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& listOfResources); @@ -49,27 +46,11 @@ class SALOME_ResourcesCatalog_Handler : public QXmlDefaultHandler virtual ~SALOME_ResourcesCatalog_Handler(); - virtual bool startDocument(); - - virtual bool startElement(const QString& , const QString& , - const QString& name, - const QXmlAttributes& attrs); - - virtual bool endElement(const QString&, const QString&, - const QString& qName); - - virtual bool characters(const QString& chars); - - virtual bool endDocument(); - - virtual QString errorProtocol(); - virtual bool fatalError(const QXmlParseException& exception); - - void PrepareDocToXmlFile(QDomDocument& doc); + void ProcessXmlDocument(xmlDocPtr theDoc); + + void PrepareDocToXmlFile(xmlDocPtr theDoc); private : - QString errorProt; - std::string content; std::string previous_module_name; std::string previous_module_path; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index 01bf2756b..4c002f91b 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -22,8 +22,6 @@ #include "Utils_ExceptHandlers.hxx" #include "OpUtil.hxx" -#include - #include #ifndef WNT #include @@ -282,23 +280,37 @@ void SALOME_ResourcesManager::DeleteResourceInCatalog(const char *hostname) void SALOME_ResourcesManager::WriteInXmlFile() { - QDomDocument doc("ResourcesCatalog"); + const char* aFilePath = _path_resources.c_str(); + + FILE* aFile = fopen(aFilePath, "w"); + + if (aFile == NULL) + { + INFOS("Error opening file !"); + return; + } + + xmlDocPtr aDoc = xmlNewDoc(BAD_CAST "1.0"); + xmlNewDocComment(aDoc, BAD_CAST "ResourcesCatalog"); + SALOME_ResourcesCatalog_Handler* handler = new SALOME_ResourcesCatalog_Handler(_resourcesList); - handler->PrepareDocToXmlFile(doc); + handler->PrepareDocToXmlFile(aDoc); delete handler; - QFile file( _path_resources ); - - if ( !file.open( IO_WriteOnly ) ) - INFOS("WRITING ERROR !"); - - QTextStream ts( &file ); - - ts << doc.toString(); - - file.close(); - + int isOk = xmlSaveFile(aFilePath, aDoc); + + if (!isOk) + INFOS("Error while XML file saving."); + + // Free the document + xmlFreeDoc(aDoc); + + // Free the global variables that may have been allocated by the parser + xmlCleanupParser(); + + fclose(aFile); + MESSAGE("WRITING DONE!"); } @@ -312,16 +324,31 @@ const MapOfParserResourcesType& SALOME_ResourcesManager::ParseXmlFile() { SALOME_ResourcesCatalog_Handler* handler = new SALOME_ResourcesCatalog_Handler(_resourcesList); - QFile xmlFile(_path_resources); - QXmlInputSource source(xmlFile); - - QXmlSimpleReader reader; - reader.setContentHandler( handler ); - reader.setErrorHandler( handler ); - reader.parse( source ); - xmlFile.close(); + const char* aFilePath = _path_resources.c_str(); + FILE* aFile = fopen(aFilePath, "r"); + + if (aFile != NULL) + { + xmlDocPtr aDoc = xmlReadFile(aFilePath, NULL, 0); + + if (aDoc != NULL) + handler->ProcessXmlDocument(aDoc); + else + INFOS("ResourcesManager: could not parse file "<