1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl)
23 // File : SALOME_Laucher_Handler.cxx
24 // Author : Bernard Secher
28 #include "SALOME_Launcher_Handler.hxx"
35 static int MYDEBUG = 1;
37 static int MYDEBUG = 0;
40 //=============================================================================
43 * \param listOfResources: map of ParserResourcesType to fill when parsing
45 //=============================================================================
47 SALOME_Launcher_Handler::SALOME_Launcher_Handler(ParserLauncherType& launch):
50 //XML tags initialisation
51 test_machine_list = "machine-list";
54 test_machine = "machine";
55 test_env_file = "env-file";
56 test_work_directory = "work-directory";
57 test_ref_directory = "ref-directory";
58 test_nb_processes = "nb-processes";
59 test_input_file = "input-file";
60 test_output_file = "output-file";
61 test_command = "command";
65 //=============================================================================
69 //=============================================================================
71 SALOME_Launcher_Handler::~SALOME_Launcher_Handler()
73 // cout << "SALOME_Launcher_Handler destruction") << endl;
76 //=============================================================================
78 * Retrieves DS after the file parse.
80 //=============================================================================
82 const ParserLauncherType&
83 SALOME_Launcher_Handler::GetLauncherAfterParsing() const
88 //=============================================================================
90 * Processes XML document and fills the list of resources
92 //=============================================================================
94 void SALOME_Launcher_Handler::ProcessXmlDocument(xmlDocPtr theDoc)
96 // if (MYDEBUG) cout << "Begin parse document" << endl;
98 // Empty private elements
101 // Get the document root node
102 xmlNodePtr aCurNode = xmlDocGetRootElement(theDoc);
104 aCurNode = aCurNode->xmlChildrenNode;
106 // Processing the document nodes
107 while(aCurNode != NULL){
108 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_machine_list) ){
109 xmlNodePtr aCurNode2 = aCurNode->xmlChildrenNode;
110 while(aCurNode2 != NULL){
111 if ( !xmlStrcmp(aCurNode2->name,(const xmlChar*)test_machine) ){
113 xmlChar* name = xmlNodeGetContent(aCurNode2);
114 string clusterName = (const char*)name;
117 if (xmlHasProp(aCurNode2, (const xmlChar*)test_env_file)){
118 xmlChar* envfile = xmlGetProp(aCurNode2, (const xmlChar*)test_env_file);
119 _machp.EnvFile = (const char*)envfile;
123 if (xmlHasProp(aCurNode2, (const xmlChar*)test_work_directory)){
124 xmlChar* workdirectory = xmlGetProp(aCurNode2, (const xmlChar*)test_work_directory);
125 _machp.WorkDirectory = (const char*)workdirectory;
126 xmlFree(workdirectory);
128 _launch.MachinesList[clusterName]=_machp ;
130 aCurNode2 = aCurNode2->next;
134 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_ref_directory) ){
135 xmlChar* refdirectory = xmlNodeGetContent(aCurNode);
136 _launch.RefDirectory = (const char*)refdirectory;
137 xmlFree(refdirectory);
140 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_nb_processes) ){
141 xmlChar* nbofprocesses = xmlNodeGetContent(aCurNode);
142 _launch.NbOfProcesses = atoi((const char*)nbofprocesses);
143 xmlFree(nbofprocesses);
146 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_input_file) ){
147 xmlChar* inputfile = xmlNodeGetContent(aCurNode);
148 _launch.InputFile.push_back((const char*)inputfile);
152 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_output_file) ){
153 xmlChar* outputfile = xmlNodeGetContent(aCurNode);
154 _launch.OutputFile.push_back((const char*)outputfile);
158 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_command) ){
159 xmlChar* command = xmlNodeGetContent(aCurNode);
160 _launch.Command = (const char*)command;
164 aCurNode = aCurNode->next;