1 // Copyright (C) 2007-2011 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
23 // SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl)
24 // File : SALOME_Laucher_Handler.cxx
25 // Author : Bernard Secher
29 #include "SALOME_Launcher_Handler.hxx"
33 //=============================================================================
36 * \param listOfResources: map of ParserResourcesType to fill when parsing
38 //=============================================================================
40 SALOME_Launcher_Handler::SALOME_Launcher_Handler(ParserLauncherType& launch):
43 //XML tags initialisation
44 test_machine_list = "machine-list";
47 test_machine = "machine";
48 test_env_file = "env-file";
49 test_work_directory = "work-directory";
50 test_ref_directory = "ref-directory";
51 test_nb_processes = "nb-processes";
52 test_input_file = "input-file";
53 test_output_file = "output-file";
54 test_command = "command";
58 //=============================================================================
62 //=============================================================================
64 SALOME_Launcher_Handler::~SALOME_Launcher_Handler()
66 // cout << "SALOME_Launcher_Handler destruction") << endl;
69 //=============================================================================
71 * Retrieves DS after the file parse.
73 //=============================================================================
75 const ParserLauncherType&
76 SALOME_Launcher_Handler::GetLauncherAfterParsing() const
81 //=============================================================================
83 * Processes XML document and fills the list of resources
85 //=============================================================================
87 void SALOME_Launcher_Handler::ProcessXmlDocument(xmlDocPtr theDoc)
89 // if (MYDEBUG) cout << "Begin parse document" << endl;
91 // Empty private elements
94 // Get the document root node
95 xmlNodePtr aCurNode = xmlDocGetRootElement(theDoc);
97 aCurNode = aCurNode->xmlChildrenNode;
99 // Processing the document nodes
100 while(aCurNode != NULL){
101 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_machine_list) ){
102 xmlNodePtr aCurNode2 = aCurNode->xmlChildrenNode;
103 while(aCurNode2 != NULL){
104 if ( !xmlStrcmp(aCurNode2->name,(const xmlChar*)test_machine) ){
106 xmlChar* name = xmlNodeGetContent(aCurNode2);
107 std::string clusterName = (const char*)name;
110 if (xmlHasProp(aCurNode2, (const xmlChar*)test_env_file)){
111 xmlChar* envfile = xmlGetProp(aCurNode2, (const xmlChar*)test_env_file);
112 _machp.EnvFile = (const char*)envfile;
116 if (xmlHasProp(aCurNode2, (const xmlChar*)test_work_directory)){
117 xmlChar* workdirectory = xmlGetProp(aCurNode2, (const xmlChar*)test_work_directory);
118 _machp.WorkDirectory = (const char*)workdirectory;
119 xmlFree(workdirectory);
121 _launch.MachinesList[clusterName]=_machp ;
123 aCurNode2 = aCurNode2->next;
127 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_ref_directory) ){
128 xmlChar* refdirectory = xmlNodeGetContent(aCurNode);
129 _launch.RefDirectory = (const char*)refdirectory;
130 xmlFree(refdirectory);
133 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_nb_processes) ){
134 xmlChar* nbofprocesses = xmlNodeGetContent(aCurNode);
135 _launch.NbOfProcesses = atoi((const char*)nbofprocesses);
136 xmlFree(nbofprocesses);
139 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_input_file) ){
140 xmlChar* inputfile = xmlNodeGetContent(aCurNode);
141 _launch.InputFile.push_back((const char*)inputfile);
145 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_output_file) ){
146 xmlChar* outputfile = xmlNodeGetContent(aCurNode);
147 _launch.OutputFile.push_back((const char*)outputfile);
151 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_command) ){
152 xmlChar* command = xmlNodeGetContent(aCurNode);
153 _launch.Command = (const char*)command;
157 aCurNode = aCurNode->next;