]> SALOME platform Git repositories - modules/kernel.git/blob - src/Batch/Batch_BatchManager_Local_SH.cxx
Salome HOME
Fix compilation problems on Win32 platform
[modules/kernel.git] / src / Batch / Batch_BatchManager_Local_SH.cxx
1 // Copyright (C) 2005  OPEN CASCADE, CEA, EDF R&D, LEG
2 //           PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 // 
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 // 
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 // 
19 /*
20  * BatchManager_Local_SH.cxx : 
21  *
22  * Auteur : Ivan DUTKA-MALEN - EDF R&D
23  * Mail   : mailto:ivan.dutka-malen@der.edf.fr
24  * Date   : Thu Nov  6 10:17:22 2003
25  * Projet : Salome 2
26  *
27  */
28
29 #ifdef HAVE_CONFIG_H
30 #  include <SALOMEconfig.h>
31 #endif
32
33 #include <iostream>
34 #include <fstream>
35 #include <sstream>
36 #include <cstdlib>
37 #include <sys/types.h>
38 #ifndef WIN32
39 #include <sys/wait.h>
40 #endif
41 #include <ctime>
42 #include <unistd.h>
43 #include <pthread.h>
44 #include <signal.h>
45 #include <errno.h>
46 #include <string.h>
47 #include "Batch_IOMutex.hxx"
48 #include "Batch_BatchManager_Local_SH.hxx"
49
50 #ifndef RM
51 #error "RM undefined. You must set RM to a valid path to a rm-like command."
52 #endif
53
54 #ifndef CP
55 #error "CP undefined. You must set CP to a valid path to a cp-like command."
56 #endif
57
58 #ifndef SH
59 #error "SH undefined. You must set SH to a valid path to a sh-like command."
60 #endif
61
62 namespace Batch {
63
64
65   // Constructeur
66   BatchManager_Local_SH::BatchManager_Local_SH(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager_Local(parent, host)
67   {
68   }
69
70   // Destructeur
71   BatchManager_Local_SH::~BatchManager_Local_SH()
72   {
73   }
74
75
76   // Methode qui renvoie la commande de copie du fichier source en destination
77   string BatchManager_Local_SH::copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const
78   {
79     ostringstream copy_cmd;
80     copy_cmd << CP << " " << source << " " << destination;
81     return copy_cmd.str();
82   }
83   
84   // Methode qui renvoie la commande a executer
85   string BatchManager_Local_SH::exec_command(Parametre & param) const
86   {
87     ostringstream exec_sub_cmd;
88     exec_sub_cmd << param[EXECUTABLE];
89
90     if (param.find(ARGUMENTS) != param.end()) {
91       Versatile V = param[ARGUMENTS];
92       for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++) {
93         StringType argt = * static_cast<StringType *>(*it);
94         string     arg  = argt;
95         exec_sub_cmd << " " << arg;
96       }
97     }
98
99     param[ARGUMENTS]  = "-c";
100     param[ARGUMENTS] += exec_sub_cmd.str();
101
102     return SH;
103   }
104
105   // Methode qui renvoie la commande d'effacement du fichier
106   string BatchManager_Local_SH::remove_command(const string & host_destination, const string & destination) const
107   {
108     ostringstream remove_cmd;
109     remove_cmd << RM << " " << destination;
110     return remove_cmd.str();
111   }
112   
113 }