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
25 * Auteur : Ivan DUTKA-MALEN - EDF R&D
26 * Mail : mailto:ivan.dutka-malen@der.edf.fr
27 * Date : Fri Nov 14 11:00:39 2003
37 #include "Batch_Job_Local.hxx"
44 Job_Local::Job_Local(const Job & job) :
45 _command(), _param(job.getParametre()), _env(job.getEnvironnement())
47 // On positionne le nom du EXECUTIONHOST a "localhost" s'il n'est pas precise
48 if ( _param.find(EXECUTIONHOST) == _param.end() ) {
49 _param[EXECUTIONHOST] = "localhost";
52 // On convertit les objets Parametre et Environnement en liste chainee d'attributs + operateur
53 addEnvironnement( _env );
54 addParametre ( _param );
60 Job_Local::~Job_Local()
65 void Job_Local::addParametre(const Parametre & P)
67 // En dernier, on ajoute le chemin complet de la commande
68 _command += P[EXECUTABLE].str();
72 void Job_Local::addEnvironnement(const Environnement & E)
74 for(Environnement::const_iterator it=E.begin(); it != E.end(); it++) {
75 string variable = (*it).first;
76 string value = (*it).second;
78 // On remplace toutes les occurences de single-quote par backslash-single-quote
79 for(int pos=0; pos < value.size(); pos++) {
80 pos = value.find("'", pos);
81 if ( (pos < 0) || (pos > value.size()) ) break;
82 value.replace(pos, 1, "\'");
84 _command += variable + "='" + value + "' ";
88 string Job_Local::getCommand(void) const {
93 // Retourne l'objet Parametre
94 Parametre Job_Local::getParametre() const
99 // Retourne l'objet Environnement
100 Environnement Job_Local::getEnvironnement() const