Back to index

salome-kernel  6.5.0
SALOME_Launcher_Handler.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl)
00024 //  File   : SALOME_Laucher_Handler.cxx
00025 //  Author : Bernard Secher
00026 //  Module : SALOME
00027 //  $Header: /home/server/cvs/KERNEL/KERNEL_SRC/src/Launcher/SALOME_Launcher_Handler.cxx,v 1.2.2.2.10.2.12.1 2012-04-12 14:05:16 vsr Exp $
00028 //
00029 #include "SALOME_Launcher_Handler.hxx"
00030 #include <iostream>
00031 #include <map>
00032 
00033 //=============================================================================
00038 //=============================================================================
00039 
00040 SALOME_Launcher_Handler::SALOME_Launcher_Handler(ParserLauncherType& launch):
00041     _launch(launch)
00042 {
00043   //XML tags initialisation
00044   test_machine_list = "machine-list";
00045   test_main = "main";
00046 
00047   test_machine = "machine";
00048   test_env_file = "env-file";
00049   test_work_directory = "work-directory";
00050   test_ref_directory = "ref-directory";
00051   test_nb_processes = "nb-processes";
00052   test_input_file = "input-file";
00053   test_output_file = "output-file";
00054   test_command = "command";
00055 
00056 }
00057 
00058 //=============================================================================
00062 //=============================================================================
00063 
00064 SALOME_Launcher_Handler::~SALOME_Launcher_Handler()
00065 {
00066   //  cout << "SALOME_Launcher_Handler destruction") << endl;
00067 }
00068 
00069 //=============================================================================
00073 //=============================================================================
00074 
00075 const ParserLauncherType&
00076 SALOME_Launcher_Handler::GetLauncherAfterParsing() const
00077 {
00078   return _launch;
00079 }
00080 
00081 //=============================================================================
00085 //=============================================================================
00086 
00087 void SALOME_Launcher_Handler::ProcessXmlDocument(xmlDocPtr theDoc)
00088 {
00089 //   if (MYDEBUG) cout << "Begin parse document" << endl;
00090 
00091   // Empty private elements
00092   _launch.Clear();
00093 
00094   // Get the document root node
00095   xmlNodePtr aCurNode = xmlDocGetRootElement(theDoc);
00096 
00097   aCurNode = aCurNode->xmlChildrenNode;
00098   
00099   // Processing the document nodes
00100   while(aCurNode != NULL){
00101     if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_machine_list) ){
00102       xmlNodePtr aCurNode2 = aCurNode->xmlChildrenNode;
00103       while(aCurNode2 != NULL){
00104         if ( !xmlStrcmp(aCurNode2->name,(const xmlChar*)test_machine) ){
00105           _machp.Clear();
00106           xmlChar* name = xmlNodeGetContent(aCurNode2);
00107           std::string clusterName = (const char*)name;
00108           xmlFree(name);
00109         
00110           if (xmlHasProp(aCurNode2, (const xmlChar*)test_env_file)){
00111             xmlChar* envfile = xmlGetProp(aCurNode2, (const xmlChar*)test_env_file);
00112             _machp.EnvFile = (const char*)envfile;
00113             xmlFree(envfile);
00114           }
00115 
00116           if (xmlHasProp(aCurNode2, (const xmlChar*)test_work_directory)){
00117             xmlChar* workdirectory = xmlGetProp(aCurNode2, (const xmlChar*)test_work_directory);
00118             _machp.WorkDirectory = (const char*)workdirectory;
00119             xmlFree(workdirectory);
00120           }
00121           _launch.MachinesList[clusterName]=_machp ;
00122         }
00123         aCurNode2 = aCurNode2->next;
00124       }
00125     }
00126 
00127     if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_ref_directory) ){
00128       xmlChar* refdirectory = xmlNodeGetContent(aCurNode);
00129       _launch.RefDirectory = (const char*)refdirectory;
00130       xmlFree(refdirectory);
00131     }
00132           
00133     if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_nb_processes) ){
00134       xmlChar* nbofprocesses = xmlNodeGetContent(aCurNode);
00135       _launch.NbOfProcesses = atoi((const char*)nbofprocesses);
00136       xmlFree(nbofprocesses);
00137     }
00138           
00139     if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_input_file) ){
00140       xmlChar* inputfile = xmlNodeGetContent(aCurNode);
00141       _launch.InputFile.push_back((const char*)inputfile);
00142       xmlFree(inputfile);
00143     }
00144           
00145     if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_output_file) ){
00146       xmlChar* outputfile = xmlNodeGetContent(aCurNode);
00147       _launch.OutputFile.push_back((const char*)outputfile);
00148       xmlFree(outputfile);
00149     }
00150           
00151     if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_command) ){
00152       xmlChar* command = xmlNodeGetContent(aCurNode);
00153       _launch.Command = (const char*)command;
00154       xmlFree(command);
00155     }
00156           
00157     aCurNode = aCurNode->next;
00158   }
00159 
00160 }