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"
34 //=============================================================================
37 * \param listOfResources: map of ParserResourcesType to fill when parsing
39 //=============================================================================
41 SALOME_Launcher_Handler::SALOME_Launcher_Handler(ParserLauncherType& launch):
44 //XML tags initialisation
45 test_machine_list = "machine-list";
48 test_machine = "machine";
49 test_env_file = "env-file";
50 test_work_directory = "work-directory";
51 test_ref_directory = "ref-directory";
52 test_nb_processes = "nb-processes";
53 test_input_file = "input-file";
54 test_output_file = "output-file";
55 test_command = "command";
59 //=============================================================================
63 //=============================================================================
65 SALOME_Launcher_Handler::~SALOME_Launcher_Handler()
67 // cout << "SALOME_Launcher_Handler destruction") << endl;
70 //=============================================================================
72 * Retrieves DS after the file parse.
74 //=============================================================================
76 const ParserLauncherType&
77 SALOME_Launcher_Handler::GetLauncherAfterParsing() const
82 //=============================================================================
84 * Processes XML document and fills the list of resources
86 //=============================================================================
88 void SALOME_Launcher_Handler::ProcessXmlDocument(xmlDocPtr theDoc)
90 // if (MYDEBUG) cout << "Begin parse document" << endl;
92 // Empty private elements
95 // Get the document root node
96 xmlNodePtr aCurNode = xmlDocGetRootElement(theDoc);
98 aCurNode = aCurNode->xmlChildrenNode;
100 // Processing the document nodes
101 while(aCurNode != NULL){
102 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_machine_list) ){
103 xmlNodePtr aCurNode2 = aCurNode->xmlChildrenNode;
104 while(aCurNode2 != NULL){
105 if ( !xmlStrcmp(aCurNode2->name,(const xmlChar*)test_machine) ){
107 xmlChar* name = xmlNodeGetContent(aCurNode2);
108 string clusterName = (const char*)name;
111 if (xmlHasProp(aCurNode2, (const xmlChar*)test_env_file)){
112 xmlChar* envfile = xmlGetProp(aCurNode2, (const xmlChar*)test_env_file);
113 _machp.EnvFile = (const char*)envfile;
117 if (xmlHasProp(aCurNode2, (const xmlChar*)test_work_directory)){
118 xmlChar* workdirectory = xmlGetProp(aCurNode2, (const xmlChar*)test_work_directory);
119 _machp.WorkDirectory = (const char*)workdirectory;
120 xmlFree(workdirectory);
122 _launch.MachinesList[clusterName]=_machp ;
124 aCurNode2 = aCurNode2->next;
128 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_ref_directory) ){
129 xmlChar* refdirectory = xmlNodeGetContent(aCurNode);
130 _launch.RefDirectory = (const char*)refdirectory;
131 xmlFree(refdirectory);
134 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_nb_processes) ){
135 xmlChar* nbofprocesses = xmlNodeGetContent(aCurNode);
136 _launch.NbOfProcesses = atoi((const char*)nbofprocesses);
137 xmlFree(nbofprocesses);
140 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_input_file) ){
141 xmlChar* inputfile = xmlNodeGetContent(aCurNode);
142 _launch.InputFile.push_back((const char*)inputfile);
146 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_output_file) ){
147 xmlChar* outputfile = xmlNodeGetContent(aCurNode);
148 _launch.OutputFile.push_back((const char*)outputfile);
152 if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_command) ){
153 xmlChar* command = xmlNodeGetContent(aCurNode);
154 _launch.Command = (const char*)command;
158 aCurNode = aCurNode->next;