Salome HOME
Win32 Porting.
authorabd <abd@opencascade.com>
Fri, 3 Oct 2008 09:06:57 +0000 (09:06 +0000)
committerabd <abd@opencascade.com>
Fri, 3 Oct 2008 09:06:57 +0000 (09:06 +0000)
Correction of Export/Import defines for Win32 platform

69 files changed:
src/Batch/Batch_APIInternalFailureException.hxx
src/Batch/Batch_BatchManager.cxx
src/Batch/Batch_BatchManager.hxx
src/Batch/Batch_BatchManagerCatalog.hxx
src/Batch/Batch_BatchManager_LSF.hxx
src/Batch/Batch_BatchManager_Local.cxx
src/Batch/Batch_BatchManager_Local.hxx
src/Batch/Batch_BatchManager_Local_RSH.cxx
src/Batch/Batch_BatchManager_Local_RSH.hxx
src/Batch/Batch_BatchManager_Local_SH.cxx
src/Batch/Batch_BatchManager_Local_SH.hxx
src/Batch/Batch_BatchManager_Local_SSH.cxx
src/Batch/Batch_BatchManager_Local_SSH.hxx
src/Batch/Batch_BatchManager_PBS.hxx
src/Batch/Batch_BatchManager_eClient.cxx
src/Batch/Batch_BatchManager_eClient.hxx
src/Batch/Batch_BatchManager_eLSF.cxx
src/Batch/Batch_BatchManager_eLSF.hxx
src/Batch/Batch_BatchManager_ePBS.cxx
src/Batch/Batch_BatchManager_ePBS.hxx
src/Batch/Batch_BoolType.hxx
src/Batch/Batch_CharType.hxx
src/Batch/Batch_ConnexionFailureException.hxx
src/Batch/Batch_Couple.hxx
src/Batch/Batch_CoupleType.hxx
src/Batch/Batch_Date.hxx
src/Batch/Batch_DateType.hxx
src/Batch/Batch_Defines.hxx [new file with mode: 0755]
src/Batch/Batch_Environnement.hxx
src/Batch/Batch_FactBatchManager.cxx
src/Batch/Batch_FactBatchManager.hxx
src/Batch/Batch_FactBatchManager_LSF.hxx
src/Batch/Batch_FactBatchManager_Local.hxx
src/Batch/Batch_FactBatchManager_Local_RSH.cxx
src/Batch/Batch_FactBatchManager_Local_RSH.hxx
src/Batch/Batch_FactBatchManager_Local_SH.hxx
src/Batch/Batch_FactBatchManager_Local_SSH.hxx
src/Batch/Batch_FactBatchManager_eLSF.cxx
src/Batch/Batch_FactBatchManager_eLSF.hxx
src/Batch/Batch_FactBatchManager_ePBS.cxx
src/Batch/Batch_FactBatchManager_ePBS.hxx
src/Batch/Batch_GenericException.hxx
src/Batch/Batch_GenericType.hxx
src/Batch/Batch_IntType.hxx
src/Batch/Batch_InvalidArgumentException.hxx
src/Batch/Batch_InvalidKeyException.hxx
src/Batch/Batch_Job.hxx
src/Batch/Batch_JobId.hxx
src/Batch/Batch_JobInfo.cxx
src/Batch/Batch_JobInfo.hxx
src/Batch/Batch_JobInfo_eLSF.cxx
src/Batch/Batch_JobInfo_eLSF.hxx
src/Batch/Batch_JobInfo_ePBS.cxx
src/Batch/Batch_JobInfo_ePBS.hxx
src/Batch/Batch_Job_Local.cxx
src/Batch/Batch_ListIsFullException.hxx
src/Batch/Batch_LongType.hxx
src/Batch/Batch_MapKey.hxx
src/Batch/Batch_NotYetImplementedException.hxx
src/Batch/Batch_Parametre.cxx
src/Batch/Batch_Parametre.hxx
src/Batch/Batch_PyVersatile.cxx
src/Batch/Batch_PyVersatile.hxx
src/Batch/Batch_RunTimeException.hxx
src/Batch/Batch_StringType.hxx
src/Batch/Batch_TypeMismatchException.hxx
src/Batch/Batch_Versatile.hxx
src/Batch/Makefile.am
src/Batch/MpiImpl.hxx

index 4e5d57457abc2619691249882142370806f739f3..cb8bb1be8075b29da2bade22b895cb073b060cb8 100644 (file)
 #ifndef _APIINTERNALFAILUREEXCEPTION_H_
 #define _APIINTERNALFAILUREEXCEPTION_H_
 
+#include "Batch_Defines.hxx"
 
 #include "Batch_GenericException.hxx"
 #include "Batch_GenericException.hxx"
 
 namespace Batch {
 
-  class APIInternalFailureException : public GenericException
+  class BATCH_EXPORT APIInternalFailureException : public GenericException
   {
   public:
                // Constructeur
index 8d3965274094a5741b96dc52dc83727e22da0c00..650642008fa86364c10e5af9ff33579c0558477d 100644 (file)
 #include <iostream>
 #include <sstream>
 #include <string>
-#include <netdb.h>
+#ifdef WIN32
+# include<winsock2.h>
+#else
+# include <netdb.h>
+#endif
+
 //#include "MEDMEM_STRING.hxx"
 #include "Batch_Job.hxx"
 #include "Batch_JobId.hxx"
index 92a81a73255138f5cfafde8b5f8e3a21bac36a0b..c00f70c0d966abb9b6719ff21a2e53b62198e830 100644 (file)
@@ -29,6 +29,8 @@
 #ifndef _BATCHMANAGER_H_
 #define _BATCHMANAGER_H_
 
+#include "Batch_Defines.hxx"
+
 #include <string>
 #include <map>
 #include "Batch_Job.hxx"
@@ -43,7 +45,7 @@ namespace Batch {
   class JobInfo;
   class FactBatchManager;
 
-  class BatchManager
+  class BATCH_EXPORT BatchManager
   {
   public:
     // Constructeur et destructeur
index 81ab713ec7c303309518dcb4645118d7281deafd..d19ae24e3508efeae5f294c8292665166f06270f 100644 (file)
@@ -29,6 +29,8 @@
 #ifndef _CATALOG_H_
 #define _CATALOG_H_
 
+#include "Batch_Defines.hxx"
+
 #include <string>
 #include <map>
 #include <pthread.h>
@@ -37,7 +39,7 @@ namespace Batch {
 
   class FactBatchManager;
   
-  class BatchManagerCatalog
+  class BATCH_EXPORT BatchManagerCatalog
   {
   public:
     // Constructeur
index 170dbd79151b63bd1f3e501ce523038b484e3b2c..e81f2df9d111d569f94e5171cad1eef99afee456 100644 (file)
@@ -30,6 +30,7 @@
 #ifndef _BATCHMANAGER_LSF_H_
 #define _BATCHMANAGER_LSF_H_
 
+#include "Batch_Defines.hxx"
 
 #include "Batch_Job.hxx"
 #include "Batch_Job.hxx"
@@ -50,7 +51,7 @@ namespace Batch {
   class JobInfo;
   class FactBatchManager;
 
-  class BatchManager_LSF : public BatchManager
+  class BATCH_EXPORT BatchManager_LSF : public BatchManager
   {
   public:
     // Constructeur et destructeur
index 5359c3d1cc1c8d04d3de7942c5892e15ddb80876..049e2afce2db5daeaec8bafde09d471121eee11a 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 // 
 /*
- * BatchManager_Local.cxx : 
- *
- * Auteur : Ivan DUTKA-MALEN - EDF R&D
- * Mail   : mailto:ivan.dutka-malen@der.edf.fr
- * Date   : Thu Nov  6 10:17:22 2003
- * Projet : Salome 2
- *
- */
+* BatchManager_Local.cxx : 
+*
+* Auteur : Ivan DUTKA-MALEN - EDF R&D
+* Mail   : mailto:ivan.dutka-malen@der.edf.fr
+* Date   : Thu Nov  6 10:17:22 2003
+* Projet : Salome 2
+*
+*/
 
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <cstdlib>
 #include <sys/types.h>
-#include <sys/wait.h>
+#ifdef WIN32
+# include <direct.h>
+#else
+# include <sys/wait.h>
+# include <unistd.h>
+#endif
 #include <ctime>
-#include <unistd.h>
 #include <pthread.h>
 #include <signal.h>
 #include <errno.h>
 #include "Batch_IOMutex.hxx"
 #include "Batch_BatchManager_Local.hxx"
 
+using namespace std;
+
 namespace Batch {
 
 
   // Constructeur
-  BatchManager_Local::BatchManager_Local(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(parent, host), _connect(0), _threads_mutex(), _threads(), _thread_id_id_association_mutex(), _thread_id_id_association_cond(), _thread_id_id_association()
+  BatchManager_Local::BatchManager_Local(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(parent, host), _connect(0), _threads_mutex(), _threads(), _thread_id_id_association_mutex(), _thread_id_id_association_cond()
+#ifndef WIN32 //TODO: porting of following functionality
+    ,_thread_id_id_association()
+#endif
   {
     pthread_mutex_init(&_threads_mutex, NULL);
     pthread_mutex_init(&_thread_id_id_association_mutex, NULL);
@@ -95,7 +104,7 @@ namespace Batch {
 
     cancel(thread_id);
   }
-   
+
   // Methode pour le controle des jobs : suspend un job en file d'attente
   void BatchManager_Local::holdJob(const JobId & jobid)
   {
@@ -129,8 +138,8 @@ namespace Batch {
     if (_threads.find(id) != _threads.end()) 
       _threads[id].command_queue.push(RELEASE);
     pthread_mutex_unlock(&_threads_mutex);
-     // @@@ --------> SECTION CRITIQUE <-------- @@@
- }
+    // @@@ --------> SECTION CRITIQUE <-------- @@@
 }
 
 
   // Methode pour le controle des jobs : modifie un job en file d'attente
@@ -202,7 +211,12 @@ namespace Batch {
   pthread_t BatchManager_Local::submit(const Job_Local & job)
   {
     // L'id du thread a creer
-    pthread_t thread_id = 0;
+    pthread_t thread_id = 
+#ifdef WIN32
+    {0,0};
+#else
+      0;
+#endif
 
     // Les attributs du thread a sa creation
     pthread_attr_t thread_attr;
@@ -213,9 +227,9 @@ namespace Batch {
 
     // Creation du thread qui va executer la commande systeme qu'on lui passe
     int rc = pthread_create(&thread_id, 
-                           &thread_attr, 
-                           &ThreadAdapter::run, 
-                           static_cast<void *>(p_ta));
+      &thread_attr, 
+      &ThreadAdapter::run, 
+      static_cast<void *>(p_ta));
     if (rc) {
     }
 
@@ -253,12 +267,14 @@ namespace Batch {
 
     // @@@ --------> SECTION CRITIQUE <-------- @@@
     pthread_mutex_lock(&_thread_id_id_association_mutex);
+#ifndef WIN32 //TODO: porting of following functionality
     while (_thread_id_id_association.find(thread_id) == _thread_id_id_association.end()) 
       pthread_cond_wait(&_thread_id_id_association_cond, &_thread_id_id_association_mutex);
 
     id = _thread_id_id_association[thread_id];
     _thread_id_id_association.erase(thread_id);
-    
+#endif
+
     pthread_mutex_unlock(&_thread_id_id_association_mutex);
     // @@@ --------> SECTION CRITIQUE <-------- @@@
 
@@ -274,6 +290,7 @@ namespace Batch {
 
     // @@@ --------> SECTION CRITIQUE <-------- @@@
     pthread_mutex_lock(&_thread_id_id_association_mutex);
+#ifndef WIN32 //TODO: porting of following functionality
     if (_thread_id_id_association.find(thread_id) == _thread_id_id_association.end()) {
       id = _thread_id_id_association[thread_id] = nextId();
       pthread_cond_signal(&_thread_id_id_association_cond);
@@ -281,6 +298,7 @@ namespace Batch {
     } else {
       UNDER_LOCK( cerr << "ERROR : Pthread Inconstency. Two threads own the same thread_id." << endl );
     }
+#endif
     pthread_mutex_unlock(&_thread_id_id_association_mutex);
     // @@@ --------> SECTION CRITIQUE <-------- @@@
 
@@ -291,7 +309,7 @@ namespace Batch {
 
   // Constructeur de la classe ThreadAdapter
   BatchManager_Local::ThreadAdapter::ThreadAdapter(BatchManager_Local & bm, const Job_Local & job) :
-    _bm(bm), _job(job)
+  _bm(bm), _job(job)
   {
     // Nothing to do
   }
@@ -301,12 +319,12 @@ namespace Batch {
   // Methode d'execution du thread
   void * BatchManager_Local::ThreadAdapter::run(void * arg)
   {
+#ifndef WIN32 //TODO: porting of following functionality
     // On bloque tous les signaux pour ce thread
     sigset_t setmask;
     sigfillset(&setmask);
     pthread_sigmask(SIG_BLOCK, &setmask, NULL);
 
-    
     // On autorise la terminaison differee du thread
     // (ces valeurs sont les valeurs par defaut mais on les force par precaution)
     pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,  NULL);
@@ -338,8 +356,13 @@ namespace Batch {
     Parametre::const_iterator it;
 
     // On initialise la variable workdir a la valeur du Current Working Directory
-    char * cwd = new char [PATH_MAX];
+    char * cwd = 
+#ifdef WIN32
+      _getcwd(NULL, 0);
+#else
+      new char [PATH_MAX];
     getcwd(cwd, PATH_MAX);
+#endif
     string workdir = cwd;
     delete [] cwd;
 
@@ -354,21 +377,21 @@ namespace Batch {
       Versatile::iterator Vit;
 
       for(Vit=V.begin(); Vit!=V.end(); Vit++) {
-       CoupleType cpt  = *static_cast< CoupleType * >(*Vit);
-       Couple cp       = cpt;
-       string local    = cp.getLocal();
-       string remote   = cp.getRemote();
-
-       string copy_cmd = p_ta->getBatchManager().copy_command("", local, executionhost, workdir + "/" + remote);
-       UNDER_LOCK( cout << "Copying : " << copy_cmd << endl );
-
-       if (system(copy_cmd.c_str()) ) {
-         // Echec de la copie
-         rc |= 1;
-       } else {
-         // On enregistre le fichier comme etant a detruire
-         files_to_delete.push_back(workdir + "/" + remote);
-       }
+        CoupleType cpt  = *static_cast< CoupleType * >(*Vit);
+        Couple cp       = cpt;
+        string local    = cp.getLocal();
+        string remote   = cp.getRemote();
+
+        string copy_cmd = p_ta->getBatchManager().copy_command("", local, executionhost, workdir + "/" + remote);
+        UNDER_LOCK( cout << "Copying : " << copy_cmd << endl );
+
+        if (system(copy_cmd.c_str()) ) {
+          // Echec de la copie
+          rc |= 1;
+        } else {
+          // On enregistre le fichier comme etant a detruire
+          files_to_delete.push_back(workdir + "/" + remote);
+        }
 
       }
     }
@@ -376,7 +399,10 @@ namespace Batch {
 
 
 
-
+#ifdef WIN32
+    //TODO
+    //Using CreateThread instead fork() POSIX function
+#else
     // On forke/exec un nouveau process pour pouvoir controler le fils
     // (plus finement qu'avec un appel system)
     // int rc = system(commande.c_str());
@@ -390,7 +416,7 @@ namespace Batch {
     } else { // fils
       p_ta->fils();
     }
-
+#endif
 
 
 
@@ -400,21 +426,21 @@ namespace Batch {
       Versatile::iterator Vit;
 
       for(Vit=V.begin(); Vit!=V.end(); Vit++) {
-       CoupleType cpt  = *static_cast< CoupleType * >(*Vit);
-       Couple cp       = cpt;
-       string local    = cp.getLocal();
-       string remote   = cp.getRemote();
-
-       string copy_cmd = p_ta->getBatchManager().copy_command(executionhost, workdir + "/" + remote, "", local);
-       UNDER_LOCK( cout << "Copying : " << copy_cmd << endl );
-
-       if (system(copy_cmd.c_str()) ) {
-         // Echec de la copie
-         rc |= 1;
-       } else {
-         // On enregistre le fichier comme etant a detruire
-         files_to_delete.push_back(workdir + "/" + remote);
-       }
+        CoupleType cpt  = *static_cast< CoupleType * >(*Vit);
+        Couple cp       = cpt;
+        string local    = cp.getLocal();
+        string remote   = cp.getRemote();
+
+        string copy_cmd = p_ta->getBatchManager().copy_command(executionhost, workdir + "/" + remote, "", local);
+        UNDER_LOCK( cout << "Copying : " << copy_cmd << endl );
+
+        if (system(copy_cmd.c_str()) ) {
+          // Echec de la copie
+          rc |= 1;
+        } else {
+          // On enregistre le fichier comme etant a detruire
+          files_to_delete.push_back(workdir + "/" + remote);
+        }
 
       }
     }
@@ -427,9 +453,9 @@ namespace Batch {
     if ( (rc == 0) || (child < 0) ) {
       std::vector<string>::const_iterator it;
       for(it=files_to_delete.begin(); it!=files_to_delete.end(); it++) {
-       string remove_cmd = p_ta->getBatchManager().remove_command(executionhost, *it);
-       UNDER_LOCK( cout << "Removing : " << remove_cmd << endl );
-       system(remove_cmd.c_str());
+        string remove_cmd = p_ta->getBatchManager().remove_command(executionhost, *it);
+        UNDER_LOCK( cout << "Removing : " << remove_cmd << endl );
+        system(remove_cmd.c_str());
       }
     }
 
@@ -448,7 +474,7 @@ namespace Batch {
 
     UNDER_LOCK( cout << "Father is leaving" << endl );
     pthread_exit(NULL);
-
+#endif
     return NULL;
   }
 
@@ -457,6 +483,7 @@ namespace Batch {
 
   void BatchManager_Local::ThreadAdapter::pere(pid_t child)
   {
+#ifndef WIN32 //TODO: porting of following functionality
     time_t child_starttime = time(NULL);
 
     // On enregistre le fils dans la table des threads
@@ -492,44 +519,44 @@ namespace Batch {
       int child_rc = 0;
       pid_t child_wait_rc = waitpid(child, &child_rc, WNOHANG /* | WUNTRACED */);
       if (child_wait_rc > 0) {
-       if (WIFSTOPPED(child_rc)) {
-         // NOTA : pour rentrer dans cette section, il faut que le flag WUNTRACED 
-         // soit positionne dans l'appel a waitpid ci-dessus. Ce flag est couramment 
-         // desactive car s'il est possible de detecter l'arret d'un process, il est 
-         // plus difficile de detecter sa reprise.
-
-         // Le fils est simplement stoppe
-         // @@@ --------> SECTION CRITIQUE <-------- @@@
-         pthread_mutex_lock(&_bm._threads_mutex);
-         _bm._threads[id].status       = STOPPED;
-         _bm._threads[id].param[STATE] = "Stopped";
-         pthread_mutex_unlock(&_bm._threads_mutex);
-         // @@@ --------> SECTION CRITIQUE <-------- @@@
-         UNDER_LOCK( cout << "Father sees his child is STOPPED : " << child_wait_rc << endl );
-
-       } 
-       else {
-         // Le fils est termine, on sort de la boucle et du if englobant
-         // @@@ --------> SECTION CRITIQUE <-------- @@@
-         pthread_mutex_lock(&_bm._threads_mutex);
-         _bm._threads[id].status       = DONE;
-         _bm._threads[id].param[STATE] = "Done";
-         pthread_mutex_unlock(&_bm._threads_mutex);
-         // @@@ --------> SECTION CRITIQUE <-------- @@@
-         UNDER_LOCK( cout << "Father sees his child is DONE : " << child_wait_rc << " (child_rc=" << (WIFEXITED(child_rc) ? WEXITSTATUS(child_rc) : -1) << ")" << endl );
-         break;
-       }
+        if (WIFSTOPPED(child_rc)) {
+          // NOTA : pour rentrer dans cette section, il faut que le flag WUNTRACED 
+          // soit positionne dans l'appel a waitpid ci-dessus. Ce flag est couramment 
+          // desactive car s'il est possible de detecter l'arret d'un process, il est 
+          // plus difficile de detecter sa reprise.
+
+          // Le fils est simplement stoppe
+          // @@@ --------> SECTION CRITIQUE <-------- @@@
+          pthread_mutex_lock(&_bm._threads_mutex);
+          _bm._threads[id].status       = STOPPED;
+          _bm._threads[id].param[STATE] = "Stopped";
+          pthread_mutex_unlock(&_bm._threads_mutex);
+          // @@@ --------> SECTION CRITIQUE <-------- @@@
+          UNDER_LOCK( cout << "Father sees his child is STOPPED : " << child_wait_rc << endl );
+
+        
+        else {
+          // Le fils est termine, on sort de la boucle et du if englobant
+          // @@@ --------> SECTION CRITIQUE <-------- @@@
+          pthread_mutex_lock(&_bm._threads_mutex);
+          _bm._threads[id].status       = DONE;
+          _bm._threads[id].param[STATE] = "Done";
+          pthread_mutex_unlock(&_bm._threads_mutex);
+          // @@@ --------> SECTION CRITIQUE <-------- @@@
+          UNDER_LOCK( cout << "Father sees his child is DONE : " << child_wait_rc << " (child_rc=" << (WIFEXITED(child_rc) ? WEXITSTATUS(child_rc) : -1) << ")" << endl );
+          break;
+        }
       }
       else if (child_wait_rc == -1) {
-       // Le fils a disparu ...
-       // @@@ --------> SECTION CRITIQUE <-------- @@@
-       pthread_mutex_lock(&_bm._threads_mutex);
-       _bm._threads[id].status       = DEAD;
-       _bm._threads[id].param[STATE] = "Dead";
-       pthread_mutex_unlock(&_bm._threads_mutex);
-       // @@@ --------> SECTION CRITIQUE <-------- @@@
-       UNDER_LOCK( cout << "Father sees his child is DEAD : " << child_wait_rc << " (Reason : " << strerror(errno) << ")" << endl );
-       break;
+        // Le fils a disparu ...
+        // @@@ --------> SECTION CRITIQUE <-------- @@@
+        pthread_mutex_lock(&_bm._threads_mutex);
+        _bm._threads[id].status       = DEAD;
+        _bm._threads[id].param[STATE] = "Dead";
+        pthread_mutex_unlock(&_bm._threads_mutex);
+        // @@@ --------> SECTION CRITIQUE <-------- @@@
+        UNDER_LOCK( cout << "Father sees his child is DEAD : " << child_wait_rc << " (Reason : " << strerror(errno) << ")" << endl );
+        break;
       }
 
 
@@ -543,33 +570,33 @@ namespace Batch {
       time_t child_currenttime = time(NULL);
       time_t child_elapsedtime = child_currenttime - child_starttime;
       if (param.find(MAXWALLTIME) != param.end()) {
-       int maxwalltime = param[MAXWALLTIME];
-       //        cout << "child_starttime          = " << child_starttime        << endl
-       //             << "child_currenttime        = " << child_currenttime      << endl
-       //             << "child_elapsedtime        = " << child_elapsedtime      << endl
-       //             << "maxwalltime              = " << maxwalltime            << endl
-       //             << "int(maxwalltime * 1.1)   = " << int(maxwalltime * 1.1) << endl;
-       if (child_elapsedtime > int(maxwalltime * 1.1) ) { // On se donne 10% de marge avant le KILL
-         UNDER_LOCK( cout << "Father is sending KILL command to the thread " << id << endl );
-         // On introduit une commande dans la queue du thread
-         // @@@ --------> SECTION CRITIQUE <-------- @@@
-         pthread_mutex_lock(&_bm._threads_mutex);
-         if (_bm._threads.find(id) != _bm._threads.end()) 
-           _bm._threads[id].command_queue.push(KILL);
-         pthread_mutex_unlock(&_bm._threads_mutex);
-         // @@@ --------> SECTION CRITIQUE <-------- @@@
-
-
-       } else if (child_elapsedtime > maxwalltime ) {
-         UNDER_LOCK( cout << "Father is sending TERM command to the thread " << id << endl );
-         // On introduit une commande dans la queue du thread
-         // @@@ --------> SECTION CRITIQUE <-------- @@@
-         pthread_mutex_lock(&_bm._threads_mutex);
-         if (_bm._threads.find(id) != _bm._threads.end()) 
-           _bm._threads[id].command_queue.push(TERM);
-         pthread_mutex_unlock(&_bm._threads_mutex);
-         // @@@ --------> SECTION CRITIQUE <-------- @@@
-       }
+        int maxwalltime = param[MAXWALLTIME];
+        //       cout << "child_starttime          = " << child_starttime        << endl
+        //            << "child_currenttime        = " << child_currenttime      << endl
+        //            << "child_elapsedtime        = " << child_elapsedtime      << endl
+        //            << "maxwalltime              = " << maxwalltime            << endl
+        //            << "int(maxwalltime * 1.1)   = " << int(maxwalltime * 1.1) << endl;
+        if (child_elapsedtime > int(maxwalltime * 1.1) ) { // On se donne 10% de marge avant le KILL
+          UNDER_LOCK( cout << "Father is sending KILL command to the thread " << id << endl );
+          // On introduit une commande dans la queue du thread
+          // @@@ --------> SECTION CRITIQUE <-------- @@@
+          pthread_mutex_lock(&_bm._threads_mutex);
+          if (_bm._threads.find(id) != _bm._threads.end()) 
+            _bm._threads[id].command_queue.push(KILL);
+          pthread_mutex_unlock(&_bm._threads_mutex);
+          // @@@ --------> SECTION CRITIQUE <-------- @@@
+
+
+        } else if (child_elapsedtime > maxwalltime ) {
+          UNDER_LOCK( cout << "Father is sending TERM command to the thread " << id << endl );
+          // On introduit une commande dans la queue du thread
+          // @@@ --------> SECTION CRITIQUE <-------- @@@
+          pthread_mutex_lock(&_bm._threads_mutex);
+          if (_bm._threads.find(id) != _bm._threads.end()) 
+            _bm._threads[id].command_queue.push(TERM);
+          pthread_mutex_unlock(&_bm._threads_mutex);
+          // @@@ --------> SECTION CRITIQUE <-------- @@@
+        }
       }
 
 
@@ -578,51 +605,52 @@ namespace Batch {
       // @@@ --------> SECTION CRITIQUE <-------- @@@
       pthread_mutex_lock(&_bm._threads_mutex);
       if (_bm._threads.find(id) != _bm._threads.end()) {
-       while (_bm._threads[id].command_queue.size() > 0) {
-         Commande cmd = _bm._threads[id].command_queue.front();
-         _bm._threads[id].command_queue.pop();
-
-         switch (cmd) {
-         case NOP:
-           UNDER_LOCK( cout << "Father does nothing to his child" << endl );
-           break;
-
-         case HOLD:
-           UNDER_LOCK( cout << "Father is sending SIGSTOP signal to his child" << endl );
-           kill(child, SIGSTOP);
-           break;
-
-         case RELEASE:
-           UNDER_LOCK( cout << "Father is sending SIGCONT signal to his child" << endl );
-           kill(child, SIGCONT);
-           break;
-
-         case TERM:
-           UNDER_LOCK( cout << "Father is sending SIGTERM signal to his child" << endl );
-           kill(child, SIGTERM);
-           break;
-
-         case KILL:
-           UNDER_LOCK( cout << "Father is sending SIGKILL signal to his child" << endl );
-           kill(child, SIGKILL);
-           break;
-
-         case ALTER:
-           break;
-
-         default:
-           break;
-         }
-       }
-         
+        while (_bm._threads[id].command_queue.size() > 0) {
+          Commande cmd = _bm._threads[id].command_queue.front();
+          _bm._threads[id].command_queue.pop();
+
+          switch (cmd) {
+    case NOP:
+      UNDER_LOCK( cout << "Father does nothing to his child" << endl );
+      break;
+
+    case HOLD:
+      UNDER_LOCK( cout << "Father is sending SIGSTOP signal to his child" << endl );
+      kill(child, SIGSTOP);
+      break;
+
+    case RELEASE:
+      UNDER_LOCK( cout << "Father is sending SIGCONT signal to his child" << endl );
+      kill(child, SIGCONT);
+      break;
+
+    case TERM:
+      UNDER_LOCK( cout << "Father is sending SIGTERM signal to his child" << endl );
+      kill(child, SIGTERM);
+      break;
+
+    case KILL:
+      UNDER_LOCK( cout << "Father is sending SIGKILL signal to his child" << endl );
+      kill(child, SIGKILL);
+      break;
+
+    case ALTER:
+      break;
+
+    default:
+      break;
+          }
+        }
+
       }
       pthread_mutex_unlock(&_bm._threads_mutex);
       // @@@ --------> SECTION CRITIQUE <-------- @@@
 
       // On fait une petite pause pour ne pas surcharger inutilement le processeur
       sleep(1);
-       
+
     }
+#endif
 
 
   }
@@ -632,139 +660,140 @@ namespace Batch {
 
   void BatchManager_Local::ThreadAdapter::fils()
   {
+#ifndef WIN32 //TODO: porting of following functionality
     Parametre param = _job.getParametre();
     Parametre::iterator it;
 
     try {
 
-    // On se place dans le repertoire de travail
-    if ( (it = param.find(WORKDIR)) != param.end() ) {
-      string workdir = static_cast<string>( (*it).second );
-      chdir(workdir.c_str());
-    }
+      // On se place dans le repertoire de travail
+      if ( (it = param.find(WORKDIR)) != param.end() ) {
+        string workdir = static_cast<string>( (*it).second );
+        chdir(workdir.c_str());
+      }
 
 
 
 
-    // EXECUTABLE is MANDATORY, if missing, we exit with failure notification
-    char * execpath = NULL;
-    if (param.find(EXECUTABLE) != param.end()) {
-      string executable = _bm.exec_command(param);
-      execpath          = new char [executable.size() + 1];
-      strncpy(execpath, executable.c_str(), executable.size() + 1);
-    } else exit(1); 
+      // EXECUTABLE is MANDATORY, if missing, we exit with failure notification
+      char * execpath = NULL;
+      if (param.find(EXECUTABLE) != param.end()) {
+        string executable = _bm.exec_command(param);
+        execpath          = new char [executable.size() + 1];
+        strncpy(execpath, executable.c_str(), executable.size() + 1);
+      } else exit(1); 
 
-    string debug_command = execpath;
+      string debug_command = execpath;
 
-    string name = (param.find(NAME) != param.end()) ? param[NAME] : param[EXECUTABLE];
+      string name = (param.find(NAME) != param.end()) ? param[NAME] : param[EXECUTABLE];
 
-    char **  argv = NULL;
-    if (param.find(ARGUMENTS) != param.end()) {
-      Versatile V = param[ARGUMENTS];
+      char **  argv = NULL;
+      if (param.find(ARGUMENTS) != param.end()) {
+        Versatile V = param[ARGUMENTS];
 
-      argv = new char * [V.size() + 2]; // 1 pour name et 1 pour le NULL terminal
+        argv = new char * [V.size() + 2]; // 1 pour name et 1 pour le NULL terminal
 
-      argv[0] = new char [name.size() + 1];
-      strncpy(argv[0], name.c_str(), name.size() + 1);
+        argv[0] = new char [name.size() + 1];
+        strncpy(argv[0], name.c_str(), name.size() + 1);
 
-      debug_command  += string(" # ") + argv[0];
+        debug_command  += string(" # ") + argv[0];
 
-      int i = 1;
-      for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++, i++) {
-       StringType argt = * static_cast<StringType *>(*it);
-       string     arg  = argt;
-       argv[i]         = new char [arg.size() + 1];
-       strncpy(argv[i], arg.c_str(), arg.size() + 1);
-       debug_command  += string(" # ") + argv[i];
+        int i = 1;
+        for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++, i++) {
+          StringType argt = * static_cast<StringType *>(*it);
+          string     arg  = argt;
+          argv[i]         = new char [arg.size() + 1];
+          strncpy(argv[i], arg.c_str(), arg.size() + 1);
+          debug_command  += string(" # ") + argv[i];
+        }
+
+        // assert (i == V.size() + 1)
+        argv[i] = NULL;
       }
 
-      // assert (i == V.size() + 1)
-      argv[i] = NULL;
-    }
 
+      UNDER_LOCK( cout << "*** debug_command = " << debug_command << endl );
 
-    UNDER_LOCK( cout << "*** debug_command = " << debug_command << endl );
 
 
+      Environnement env = _job.getEnvironnement();
 
-    Environnement env = _job.getEnvironnement();
 
+      char ** envp = NULL;
+      if(env.size() > 0) {
+        envp = new char * [env.size() + 1]; // 1 pour le NULL terminal
+        int i = 0;
+        for(Environnement::const_iterator it=env.begin(); it!=env.end(); it++, i++) {
+          const string  & key   = (*it).first;
+          const string  & value = (*it).second;
+          ostringstream oss;
+          oss << key << "=" << value;
+          envp[i]         = new char [oss.str().size() + 1];
+          strncpy(envp[i], oss.str().c_str(), oss.str().size() + 1);
+        }
 
-    char ** envp = NULL;
-    if(env.size() > 0) {
-      envp = new char * [env.size() + 1]; // 1 pour le NULL terminal
-      int i = 0;
-      for(Environnement::const_iterator it=env.begin(); it!=env.end(); it++, i++) {
-       const string  & key   = (*it).first;
-       const string  & value = (*it).second;
-       ostringstream oss;
-       oss << key << "=" << value;
-       envp[i]         = new char [oss.str().size() + 1];
-       strncpy(envp[i], oss.str().c_str(), oss.str().size() + 1);
+        // assert (i == env.size())
+        envp[i] = NULL;
       }
 
-      // assert (i == env.size())
-      envp[i] = NULL;
-    }
 
 
 
+      // On positionne les limites systeme imposees au fils
+      if (param.find(MAXCPUTIME) != param.end()) {
+        int maxcputime = param[MAXCPUTIME];
+        struct rlimit limit;
+        limit.rlim_cur = maxcputime;
+        limit.rlim_max = int(maxcputime * 1.1);
+        setrlimit(RLIMIT_CPU, &limit);
+      }
 
-    // On positionne les limites systeme imposees au fils
-    if (param.find(MAXCPUTIME) != param.end()) {
-      int maxcputime = param[MAXCPUTIME];
-      struct rlimit limit;
-      limit.rlim_cur = maxcputime;
-      limit.rlim_max = int(maxcputime * 1.1);
-      setrlimit(RLIMIT_CPU, &limit);
-    }
+      if (param.find(MAXDISKSIZE) != param.end()) {
+        int maxdisksize = param[MAXDISKSIZE];
+        struct rlimit limit;
+        limit.rlim_cur = maxdisksize * 1024;
+        limit.rlim_max = int(maxdisksize * 1.1) * 1024;
+        setrlimit(RLIMIT_FSIZE, &limit);
+      }
 
-    if (param.find(MAXDISKSIZE) != param.end()) {
-      int maxdisksize = param[MAXDISKSIZE];
-      struct rlimit limit;
-      limit.rlim_cur = maxdisksize * 1024;
-      limit.rlim_max = int(maxdisksize * 1.1) * 1024;
-      setrlimit(RLIMIT_FSIZE, &limit);
-    }
+      if (param.find(MAXRAMSIZE) != param.end()) {
+        int maxramsize = param[MAXRAMSIZE];
+        struct rlimit limit;
+        limit.rlim_cur = maxramsize * 1024;
+        limit.rlim_max = int(maxramsize * 1.1) * 1024;
+        setrlimit(RLIMIT_AS, &limit);
+      }
 
-    if (param.find(MAXRAMSIZE) != param.end()) {
-      int maxramsize = param[MAXRAMSIZE];
-      struct rlimit limit;
-      limit.rlim_cur = maxramsize * 1024;
-      limit.rlim_max = int(maxramsize * 1.1) * 1024;
-      setrlimit(RLIMIT_AS, &limit);
-    }
 
 
+      // On cree une session pour le fils de facon a ce qu'il ne soit pas
+      // detruit lorsque le shell se termine (le shell ouvre une session et
+      // tue tous les process appartenant a la session en quittant)
+      setsid();
 
-    // On cree une session pour le fils de facon a ce qu'il ne soit pas
-    // detruit lorsque le shell se termine (le shell ouvre une session et
-    // tue tous les process appartenant a la session en quittant)
-    setsid();
 
+      // On ferme les descripteurs de fichiers standards
+      //close(STDIN_FILENO);
+      //close(STDOUT_FILENO);
+      //close(STDERR_FILENO);
 
-    // On ferme les descripteurs de fichiers standards
-    //close(STDIN_FILENO);
-    //close(STDOUT_FILENO);
-    //close(STDERR_FILENO);
 
+      // On execute la commande du fils
+      execve(execpath, argv, envp);
 
-    // On execute la commande du fils
-    execve(execpath, argv, envp);
+      // No need to deallocate since nothing happens after a successful exec
 
-    // No need to deallocate since nothing happens after a successful exec
+      // Normalement on ne devrait jamais arriver ici    
+      ofstream file_err("error.log");
+      UNDER_LOCK( file_err << "Echec de l'appel a execve" << endl );
 
-    // Normalement on ne devrait jamais arriver ici    
-    ofstream file_err("error.log");
-    UNDER_LOCK( file_err << "Echec de l'appel a execve" << endl );
-    
     } catch (GenericException & e) {
-      
+
       std::cerr << "Caught exception : " << e.type << " : " << e.message << std::endl;
     }
 
     exit(99);
-
+#endif
   }
 
 
@@ -772,6 +801,8 @@ namespace Batch {
 
   void BatchManager_Local::kill_child_on_exit(void * p_pid)
   {
+#ifndef WIN32 
+    //TODO: porting of following functionality
     pid_t child = * static_cast<pid_t *>(p_pid);
 
     // On tue le fils
@@ -780,7 +811,7 @@ namespace Batch {
     // Nota : on pourrait aussi faire a la suite un kill(child, SIGKILL)
     // mais cette option n'est pas implementee pour le moment, car il est 
     // preferable de laisser le process fils se terminer normalement et seul.
-
+#endif
   }
 
   void BatchManager_Local::delete_on_exit(void * arg)
index 53091cab25e92e1871698f965a8bc9cc92b6dc16..d797aaf289c358198e55cf7972b296f67ac4cb1e 100644 (file)
 #ifndef _BATCHMANAGER_LOCAL_H_
 #define _BATCHMANAGER_LOCAL_H_
 
+#include "Batch_Defines.hxx"
 
 #include <vector>
 #include <map>
 #include <queue>
-#include <deque>
 #include <pthread.h>
 #include "Batch_Job.hxx"
 #include "Batch_JobId.hxx"
@@ -50,7 +50,7 @@ namespace Batch {
 
   class FactBatchManager;
 
-  class BatchManager_Local : public BatchManager
+  class BATCH_EXPORT BatchManager_Local : public BatchManager
   {
   private:
     friend class ThreadAdapter;
@@ -91,7 +91,7 @@ namespace Batch {
 
     struct Child {
       pthread_t thread_id;
-      queue<Commande, deque<Commande> > command_queue;
+      std::queue<Commande, std::deque<Commande> > command_queue;
       pid_t pid;
       int exit_code;
       Status status;
@@ -127,16 +127,20 @@ namespace Batch {
   protected:
     int _connect; // Local connect id
     pthread_mutex_t _threads_mutex;
-    map<Id, Child > _threads;
+    std::map<Id, Child > _threads;
 
     // Methode abstraite qui renvoie la commande de copie du fichier source en destination
-    virtual string copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const = 0;
+    virtual std::string copy_command( const std::string & host_source,
+                                     const std::string & source,
+                                     const std::string & host_destination,
+                                     const std::string & destination) const = 0;
 
     // Methode abstraite qui renvoie la commande a executer
-    virtual string exec_command(Parametre & param) const = 0;
+    virtual std::string exec_command(Parametre & param) const = 0;
 
     // Methode abstraite qui renvoie la commande d'effacement du fichier
-    virtual string remove_command(const string & host_destination, const string & destination) const = 0;
+    virtual std::string remove_command( const std::string & host_destination,
+                                       const std::string & destination) const = 0;
 
   private:
     virtual pthread_t submit(const Job_Local & job);
@@ -148,7 +152,10 @@ namespace Batch {
     Id registerThread_id(pthread_t thread_id);
     pthread_mutex_t _thread_id_id_association_mutex;
     pthread_cond_t  _thread_id_id_association_cond;
-    map<pthread_t, Id> _thread_id_id_association;
+#ifndef WIN32 //TODO: porting of following functionality
+    //reason: pthread_t on win32 is a struct of pointer and int members
+    std::map<pthread_t, Id> _thread_id_id_association;
+#endif
 
 #ifdef SWIG
   public:
index e93ede663daafc953f97ff221230e3f6070ae1c2..a99a9cdcd2d6bee26a602751af7284ac0bd36c6f 100644 (file)
 #include <sstream>
 #include <cstdlib>
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/wait.h>
-#include <ctime>
 #include <unistd.h>
+#endif
+#include <ctime>
 #include <pthread.h>
 #include <signal.h>
 #include <errno.h>
@@ -57,6 +59,8 @@
 #error "RSH undefined. You must set RSH to a valid path to a rsh-like command."
 #endif
 
+using namespace std;
+
 namespace Batch {
 
 
index be7a4a04bd06ce92dbf88e632497c9344ec7b8ab..0580a4aad7cf64bef1bc1ae3b3cdcd423ad4a75f 100644 (file)
@@ -29,6 +29,7 @@
 #ifndef _BATCHMANAGER_LOCAL_RSH_H_
 #define _BATCHMANAGER_LOCAL_RSH_H_
 
+#include "Batch_Defines.hxx"
 
 #include <vector>
 #include <map>
@@ -50,7 +51,7 @@ namespace Batch {
 
   class FactBatchManager;
 
-  class BatchManager_Local_RSH : public BatchManager_Local
+  class BATCH_EXPORT BatchManager_Local_RSH : public BatchManager_Local
   {
   public:
     // Constructeur et destructeur
@@ -59,13 +60,17 @@ namespace Batch {
 
   protected:
     // Methode abstraite qui renvoie la commande de copie du fichier source en destination
-    virtual string copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const;
+    virtual std::string copy_command( const std::string & host_source,
+                                     const std::string & source,
+                                     const std::string & host_destination,
+                                     const std::string & destination) const;
 
     // Methode abstraite qui renvoie la commande a executer
-    virtual string exec_command(Parametre & param) const;
+    virtual std::string exec_command(Parametre & param) const;
 
     // Methode qui renvoie la commande d'effacement du fichier
-    virtual string remove_command(const string & host_destination, const string & destination) const;
+    virtual std::string remove_command( const std::string & host_destination,
+                                       const std::string & destination) const;
 
   };
 
index be9b990ea4964d300e4233e4c4ed6c4cc482cd1c..beead5209dfc81c9e7b480dd1bd422e4d10b94cd 100644 (file)
@@ -35,7 +35,9 @@
 #include <sstream>
 #include <cstdlib>
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/wait.h>
+#endif
 #include <ctime>
 #include <unistd.h>
 #include <pthread.h>
@@ -57,6 +59,8 @@
 #error "SH undefined. You must set SH to a valid path to a sh-like command."
 #endif
 
+using namespace std;
+
 namespace Batch {
 
 
index c3de1af7ab1d1847f287eaecc8b43562a8c8490b..31f79b2aa32e683c24125087db0bee65dec20112 100644 (file)
@@ -29,6 +29,7 @@
 #ifndef _BATCHMANAGER_LOCAL_SH_H_
 #define _BATCHMANAGER_LOCAL_SH_H_
 
+#include "Batch_Defines.hxx"
 
 #include <vector>
 #include <map>
@@ -50,7 +51,7 @@ namespace Batch {
 
   class FactBatchManager;
 
-  class BatchManager_Local_SH : public BatchManager_Local
+  class BATCH_EXPORT BatchManager_Local_SH : public BatchManager_Local
   {
   public:
     // Constructeur et destructeur
@@ -59,13 +60,17 @@ namespace Batch {
 
   protected:
     // Methode qui renvoie la commande de copie du fichier source en destination
-    virtual string copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const;
+    virtual std::string copy_command( const std::string & host_source,
+                                     const std::string & source,
+                                     const std::string & host_destination,
+                                     const std::string & destination) const;
 
     // Methode qui renvoie la commande a executer
-    virtual string exec_command(Parametre & param) const;
+    virtual std::string exec_command(Parametre & param) const;
 
     // Methode qui renvoie la commande d'effacement du fichier
-    virtual string remove_command(const string & host_destination, const string & destination) const;
+    virtual std::string remove_command( const std::string & host_destination,
+                                       const std::string & destination) const;
 
   };
 
index 696d7473eb6e5fdb88f921b031a9cbddee24fef5..697c9ea2f52c7a6beffcb003634255e6898727ec 100644 (file)
 #include <sstream>
 #include <cstdlib>
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/wait.h>
-#include <ctime>
 #include <unistd.h>
+#endif
+#include <ctime>
+
 #include <pthread.h>
 #include <signal.h>
 #include <errno.h>
@@ -57,6 +60,8 @@
 #error "SSH undefined. You must set SSH to a valid path to a ssh-like command."
 #endif
 
+using namespace std;
+
 namespace Batch {
 
 
index b45314f3cc5ced5a26b6669dc92bad8bff16d68e..33ecda42d26281849ab05b0b9ab721a43a3ea874 100644 (file)
@@ -29,6 +29,7 @@
 #ifndef _BATCHMANAGER_LOCAL_SSH_H_
 #define _BATCHMANAGER_LOCAL_SSH_H_
 
+#include "Batch_Defines.hxx"
 
 #include <vector>
 #include <map>
@@ -50,7 +51,7 @@ namespace Batch {
 
   class FactBatchManager;
 
-  class BatchManager_Local_SSH : public BatchManager_Local
+  class BATCH_EXPORT BatchManager_Local_SSH : public BatchManager_Local
   {
   public:
     // Constructeur et destructeur
@@ -59,13 +60,17 @@ namespace Batch {
 
   protected:
     // Methode abstraite qui renvoie la commande de copie du fichier source en destination
-    virtual string copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const;
+    virtual std::string copy_command( const std::string & host_source,
+                                     const std::string & source,
+                                     const std::string & host_destination,
+                                     const std::string & destination) const;
 
     // Methode abstraite qui renvoie la commande a executer
-    virtual string exec_command(Parametre & param) const;
+    virtual std::string exec_command(Parametre & param) const;
 
     // Methode qui renvoie la commande d'effacement du fichier
-    virtual string remove_command(const string & host_destination, const string & destination) const;
+    virtual std::string remove_command( const std::string & host_destination,
+                                       const std::string & destination) const;
 
   };
 
index 53e8a2798b019fa8cc315436e0efe99cf7e72eda..9e995b5404d5e220e3dbd41a3958fd6afcee856a 100644 (file)
@@ -30,6 +30,7 @@
 #ifndef _BATCHMANAGER_PBS_H_
 #define _BATCHMANAGER_PBS_H_
 
+#include "Batch_Defines.hxx"
 
 #include "Batch_Job.hxx"
 #include "Batch_Job.hxx"
@@ -50,7 +51,7 @@ namespace Batch {
   class JobInfo;
   class FactBatchManager;
 
-  class BatchManager_PBS : public BatchManager
+  class BATCH_EXPORT BatchManager_PBS : public BatchManager
   {
   public:
     // Constructeur et destructeur
index 41ce47c2e687c2aa7b7722e1e72e8685c5cad464..a005cec9c25eb32974de0b9f790957eb00838fd3 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 /*
- * BatchManager_eLSF.cxx : emulation of LSF client
- *
- * Auteur : Bernard SECHER - CEA DEN
- * Mail   : mailto:bernard.secher@cea.fr
- * Date   : Thu Apr 24 10:17:22 2008
- * Projet : PAL Salome 
- *
- */
+* BatchManager_eLSF.cxx : emulation of LSF client
+*
+* Auteur : Bernard SECHER - CEA DEN
+* Mail   : mailto:bernard.secher@cea.fr
+* Date   : Thu Apr 24 10:17:22 2008
+* Projet : PAL Salome 
+*
+*/
+
+#include "Batch_BatchManager_eClient.hxx"
+#include "Basics_DirUtils.hxx"
 
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <sys/stat.h>
-#include "Batch_BatchManager_eClient.hxx"
+
+using namespace std;
+
 
 namespace Batch {
 
@@ -65,7 +70,7 @@ namespace Batch {
       copy_command = "scp ";
     else
       throw EmulationException("Unknown protocol : only rsh and ssh are known !");
-    
+
     // First step : creating batch tmp files directory
     command = _protocol;
     command += " ";
@@ -108,7 +113,7 @@ namespace Batch {
       ex_mess += oss.str();
       throw EmulationException(ex_mess.c_str());
     }
-    
+
     // Third step : copy filesToExportList into
     // batch tmp files directory
     for(Vit=V.begin(); Vit!=V.end(); Vit++) {
@@ -118,8 +123,8 @@ namespace Batch {
       command += inputFile.getLocal();
       command += " ";
       if(_username != ""){
-       command += _username;
-       command += "@";
+        command += _username;
+        command += "@";
       }
       command += _hostname;
       command += ":";
@@ -127,11 +132,11 @@ namespace Batch {
       cerr << command.c_str() << endl;
       status = system(command.c_str());
       if(status) {
-       std::ostringstream oss;
-       oss << status;
-       std::string ex_mess("Error of connection on remote host ! status = ");
-       ex_mess += oss.str();
-       throw EmulationException(ex_mess.c_str());
+        std::ostringstream oss;
+        oss << status;
+        std::string ex_mess("Error of connection on remote host ! status = ");
+        ex_mess += oss.str();
+        throw EmulationException(ex_mess.c_str());
       }
     }
 
@@ -145,20 +150,20 @@ namespace Batch {
     Parametre params = job.getParametre();
     Versatile V = params[OUTFILE];
     Versatile::iterator Vit;
+
     for(Vit=V.begin(); Vit!=V.end(); Vit++) {
       CoupleType cpt  = *static_cast< CoupleType * >(*Vit);
       Couple outputFile = cpt;
       if( _protocol == "rsh" )
-       command = "rcp ";
+        command = "rcp ";
       else if( _protocol == "ssh" )
-       command = "scp ";
+        command = "scp ";
       else
-       throw EmulationException("Unknown protocol");
+        throw EmulationException("Unknown protocol");
 
       if (_username != ""){
-       command += _username;
-       command += "@";
+        command += _username;
+        command += "@";
       }
       command += _hostname;
       command += ":";
@@ -169,13 +174,13 @@ namespace Batch {
       status = system(command.c_str());
       if(status) 
       {
-       // Try to get what we can (logs files)
-       // throw BatchException("Error of connection on remote host");    
-       std::string mess("Copy command failed ! status is :");
-       ostringstream status_str;
-       status_str << status;
-       mess += status_str.str();
-       cerr << mess << endl;
+        // Try to get what we can (logs files)
+        // throw BatchException("Error of connection on remote host");    
+        std::string mess("Copy command failed ! status is :");
+        ostringstream status_str;
+        status_str << status;
+        mess += status_str.str();
+        cerr << mess << endl;
       }
     }
 
@@ -203,26 +208,22 @@ namespace Batch {
   string BatchManager_eClient::BuildTemporaryFileName() const
   {
     //build more complex file name to support multiple salome session
-    char *temp = new char[19];
-    strcpy(temp, "/tmp/command");
-    strcat(temp, "XXXXXX");
-#ifndef WNT
-    mkstemp(temp);
+    string aFileName = Kernel_Utils::GetTmpFileName();
+#ifndef WIN32
+    aFileName += ".sh";
 #else
-    char aPID[80];
-    itoa(getpid(), aPID, 10);
-    strcat(temp, aPID);
+    aFileName += ".bat";
 #endif
-
-    string command(temp);
-    delete [] temp;
-    command += ".sh";
-    return command;
+    return aFileName;
   }
 
   void BatchManager_eClient::RmTmpFile(std::string & TemporaryFileName)
   {
+#ifdef WIN32
+    string command = "del /F ";
+#else
     string command = "rm ";
+#endif
     command += TemporaryFileName;
     char *temp = strdup(command.c_str());
     int lgthTemp = strlen(temp);
@@ -231,5 +232,4 @@ namespace Batch {
     system(temp);
     free(temp);
   }
-
 }
index 717eae6a35fb1083e1d0974bd44477dfa2104940..f3d27c406f5cfd320ae9b4764f7a613d6be77b9b 100644 (file)
 #ifndef _BATCHMANAGER_eClient_H_
 #define _BATCHMANAGER_eClient_H_
 
+#include "Batch_Defines.hxx"
 
 #include "MpiImpl.hxx"
 #include "Batch_BatchManager.hxx"
 
+#include <string>
+
 namespace Batch {
 
   class Job;
 
-  class EmulationException
+  class BATCH_EXPORT EmulationException
   {
   public:
     const std::string msg;
@@ -46,7 +49,7 @@ namespace Batch {
     EmulationException(const std::string m) : msg(m) {}
   };
 
-  class BatchManager_eClient : public BatchManager
+  class BATCH_EXPORT BatchManager_eClient : public BatchManager
   {
   public:
     // Constructeur et destructeur
@@ -61,7 +64,7 @@ namespace Batch {
 
     std::string BuildTemporaryFileName() const;
     void RmTmpFile(std::string & TemporaryFileName);
-    MpiImpl* FactoryMpiImpl(string mpiImpl) throw(EmulationException);
+    MpiImpl* FactoryMpiImpl(std::string mpiImpl) throw(EmulationException);
     void exportInputFiles(const Job & job) throw(EmulationException);
 
   private:
index d1c44e60d66ca237ef311cd8b2d1fcfa3131b054..2533a31862cdbae67504de25fcd46453df3f9826 100644 (file)
 #include <sstream>
 #include <sys/stat.h>
 #include "Batch_BatchManager_eLSF.hxx"
+#ifdef WIN32
+# include <time.h>
+# include <io.h>
+#endif
+
+using namespace std;
 
 namespace Batch {
 
@@ -228,6 +234,7 @@ namespace Batch {
 
   void BatchManager_eLSF::buildBatchScript(const Job & job) throw(EmulationException)
   {
+#ifndef WIN32 //TODO: need for porting on Windows
     int status;
     Parametre params = job.getParametre();
     const int nbproc = params[NBPROC];
@@ -263,7 +270,12 @@ namespace Batch {
     tempOutputFile << _mpiImpl->halt();
     tempOutputFile.flush();
     tempOutputFile.close();
-    chmod(TmpFileName.c_str(), 0x1ED);
+#ifdef WIN32
+    _chmod(
+#else
+    chmod(
+#endif
+      TmpFileName.c_str(), 0x1ED);
     cerr << TmpFileName.c_str() << endl;
 
     string command;
@@ -291,6 +303,7 @@ namespace Batch {
       throw EmulationException("Error of connection on remote host");    
 
     RmTmpFile(TmpFileName);
+#endif
     
   }
 
index 00d79a4faea45370d7fcf434b848494566bd8ca9..9673d1a1ebfe7ee9959080fa1ba4318a9819ff84 100644 (file)
@@ -30,6 +30,7 @@
 #ifndef _BATCHMANAGER_eLSF_H_
 #define _BATCHMANAGER_eLSF_H_
 
+#include "Batch_Defines.hxx"
 
 #include "Batch_JobId.hxx"
 #include "Batch_JobInfo.hxx"
@@ -48,7 +49,7 @@ namespace Batch {
   class JobInfo;
   class FactBatchManager;
 
-  class BatchManager_eLSF : public BatchManager_eClient
+  class BATCH_EXPORT BatchManager_eLSF : public BatchManager_eClient
   {
   public:
     // Constructeur et destructeur
index 999025cfbb23d35e9bdbd1c661cb7b7762716265..fa612adda414e8a0c204b06f1a036713f3116e9b 100644 (file)
 #include <sstream>
 #include <sys/stat.h>
 #include "Batch_BatchManager_ePBS.hxx"
+#ifdef WIN32
+# include <time.h>
+# include <io.h>
+#endif
+
+using namespace std;
 
 namespace Batch {
 
@@ -227,6 +233,7 @@ namespace Batch {
 
   void BatchManager_ePBS::buildBatchScript(const Job & job) throw(EmulationException)
   {
+#ifndef WIN32 //TODO: need for porting on Windows
     int status;
     Parametre params = job.getParametre();
     const long nbproc = params[NBPROC];
@@ -262,7 +269,12 @@ namespace Batch {
     tempOutputFile << _mpiImpl->halt();
     tempOutputFile.flush();
     tempOutputFile.close();
-    chmod(TmpFileName.c_str(), 0x1ED);
+#ifdef WIN32
+    _chmod(
+#else
+    chmod(
+#endif
+      TmpFileName.c_str(), 0x1ED);
     cerr << TmpFileName.c_str() << endl;
 
     string command;
@@ -290,7 +302,7 @@ namespace Batch {
       throw EmulationException("Error of connection on remote host");    
 
     RmTmpFile(TmpFileName);
-    
+#endif    
   }
 
 }
index 42f4b1b69d7c2c29d54026c8cef74a487f33c61b..2bfa60a1a866fb6ecbd71607143a324fe850159c 100644 (file)
@@ -30,6 +30,8 @@
 #ifndef _BATCHMANAGER_eLSF_H_
 #define _BATCHMANAGER_eLSF_H_
 
+#include "Batch_Defines.hxx"
+
 #include "Batch_JobId.hxx"
 #include "Batch_JobInfo.hxx"
 #include "Batch_JobInfo_ePBS.hxx"
@@ -47,7 +49,7 @@ namespace Batch {
   class JobInfo;
   class FactBatchManager;
 
-  class BatchManager_ePBS : public BatchManager_eClient
+  class BATCH_EXPORT BatchManager_ePBS : public BatchManager_eClient
   {
   public:
     // Constructeur et destructeur
index b367b3a028750ec4d4c84ac189c2e355c4b95c92..f25c24c5f30dc373c8021ae72cfae36b87a12bb4 100644 (file)
 #ifndef _BOOLTYPE_H_
 #define _BOOLTYPE_H_
 
+#include "Batch_Defines.hxx"
+
 #include <string>
 #include "Batch_GenericType.hxx"
 
 namespace Batch {
 
-  class BoolType : public GenericType
+  class BATCH_EXPORT BoolType : public GenericType
   {
   public:
                // Constructeur
index f4894f5d06545e2967024dc953185e801fcdaf53..abac3be3adf718fd150caec85efe8a5f1dde8a44 100644 (file)
 #ifndef _CHARTYPE_H_
 #define _CHARTYPE_H_
 
+#include "Batch_Defines.hxx"
+
 #include <string>
 #include "Batch_GenericType.hxx"
 
 namespace Batch {
 
-  class CharType : public GenericType
+  class BATCH_EXPORT CharType : public GenericType
   {
   public:
                // Constructeur
index 9ae672885338c2369da4adb83f0a3ec340a8fcbb..0d3a47e86df2a997dfc963f3b2aa08eecf052fef 100644 (file)
 #ifndef _CONNEXIONFAILUREEXCEPTION_H_
 #define _CONNEXIONFAILUREEXCEPTION_H_
 
+#include "Batch_Defines.hxx"
+
 
 #include "Batch_GenericException.hxx"
 
 namespace Batch {
 
-  class ConnexionFailureException : public GenericException
+  class BATCH_EXPORT ConnexionFailureException : public GenericException
   {
   public:
                // Constructeur
index 717a1c2282153c845d9c33286d966ae926f2936a..9c0deed454aa5985d1be2d912bbd5f8e26e21dfa 100644 (file)
 #ifndef _COUPLE_H_
 #define _COUPLE_H_
 
+#include "Batch_Defines.hxx"
+
 #include <string>
 
 namespace Batch {
 
-  class Couple
+  class BATCH_EXPORT Couple
   {
   public:
     // Constructeur standard
index 6d2500f1c9cb7df3dc072d9b91fb46fda11c29e2..b7d323331a8d3d0cce858939d8be651d39e5b439 100644 (file)
 #ifndef _COUPLETYPE_H_
 #define _COUPLETYPE_H_
 
+#include "Batch_Defines.hxx"
+
 #include <string>
 #include "Batch_GenericType.hxx"
 #include "Batch_Couple.hxx"
 
 namespace Batch {
 
-  class CoupleType : public GenericType
+  class BATCH_EXPORT CoupleType : public GenericType
   {
   public:
                // Constructeur
index 06ebd5dd17b953aa99819e51e504025d81b9d3ae..ff7d37a6f9129ebc4d2ca3dc7db90489bb64c246 100644 (file)
 #ifndef _DATE_H_
 #define _DATE_H_
 
+#include "Batch_Defines.hxx"
+
 #include <string>
 
 namespace Batch {
 
-  class Date
+  class BATCH_EXPORT Date
   {
   public:
     Date(const long l=0);
index 40a47702ed784ebdc8d1457e904e224c4df8e868..c7fef39a5535842d085674ac11b412948e4c0317 100644 (file)
 #ifndef _DATETYPE_H_
 #define _DATETYPE_H_
 
+#include "Batch_Defines.hxx"
+
 #include <string>
 #include "Batch_GenericType.hxx"
 #include "Batch_Date.hxx"
 
 namespace Batch {
 
-  class DateType : public GenericType
+  class BATCH_EXPORT DateType : public GenericType
   {
   public:
                // Constructeur
diff --git a/src/Batch/Batch_Defines.hxx b/src/Batch/Batch_Defines.hxx
new file mode 100755 (executable)
index 0000000..15c5f7c
--- /dev/null
@@ -0,0 +1,42 @@
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   : Batch_Defines.hxx
+//  Author : Alexander A. BORODIN
+//  Module : SALOME
+
+#ifndef _BATCH_Defines_HXX_
+#define _BATCH_Defines_HXX_
+
+#ifdef WIN32
+# ifdef BATCH_EXPORTS
+#  define BATCH_EXPORT __declspec( dllexport )
+# else
+#  define BATCH_EXPORT __declspec( dllimport )
+# endif
+# define RM  "rm"
+# define RCP "rpc"
+# define RSH "rsh"
+#else
+# define BATCH_EXPORT
+#endif
+
+#endif
index 2fb9c73a046556c646d3f3265ca5fbc6639f4411..e1e16f6546f3452f83d487b260e9e6e67083176b 100644 (file)
@@ -30,6 +30,8 @@
 #ifndef _ENVIRONNEMENT_H_
 #define _ENVIRONNEMENT_H_
 
+#include "Batch_Defines.hxx"
+
 
 #include <string>
 #include <map>
index 61d18fbd0ef5ebd8dc26825c7ec52712adb58a0a..27b7f1c1f2719ad59ec0ee16c25f148b5365cacf 100644 (file)
@@ -39,9 +39,16 @@ namespace Batch {
   FactBatchManager::FactBatchManager(const string & _t) : type(_t)
   {
     BatchManagerCatalog::addFactBatchManager(type.c_str(), this);
+    /*
+    #ifndef WIN32
+    Win32 limitation: it's impossible to create new thread of LocalTraceCollector
+    during initialization of static objects of DLL
+    Be careful with static objects of types inherited from FactBatchManager class
+    */
     ostringstream msg;
     msg << "FactBatchManager of type '" << type << "' inserted into catalog";
     MESSAGE(msg.str().c_str());
+    //#endif
   }
 
   // Destructeur
index 71d739ef0a0ab40d6f0f2c7fc9809c5d4dfad183..3a229be3004011c128b19d26c82a6139fbfe9fc5 100644 (file)
@@ -29,6 +29,8 @@
 #ifndef _FACTBATCHMANAGER_H_
 #define _FACTBATCHMANAGER_H_
 
+#include "Batch_Defines.hxx"
+
 #include <string>
 #include <map>
 
@@ -36,7 +38,7 @@ namespace Batch {
   
   class BatchManager;
 
-  class FactBatchManager
+  class BATCH_EXPORT FactBatchManager
   {
   public:
     // Constructeur et destructeur
index 718a068fce2621ae889f78f1d29b0aeb8d9865e6..239b8edfdd7890883d0256a3770b3bbd8892271e 100644 (file)
@@ -29,9 +29,6 @@
 #ifndef _FACTBATCHMANAGER_LSF_H_
 #define _FACTBATCHMANAGER_LSF_H_
 
-using namespace std;
-#include <string>
-#include <map>
 #include "Batch_FactBatchManager.hxx"
 
 namespace Batch {
index 77b5d11b3d38b85a74808b54ec8e384d77e9472d..f9b0d20df42d05de7da7a46cedecd0b56aab86f6 100644 (file)
@@ -28,9 +28,6 @@
 #ifndef _FACTBATCHMANAGER_LOCAL_H_
 #define _FACTBATCHMANAGER_LOCAL_H_
 
-using namespace std;
-#include <string>
-#include <map>
 #include "Batch_FactBatchManager.hxx"
 
 namespace Batch {
index 985146e5840877868d70bea21f5ea5386a0723a9..456c09e453b98af9e8faf4b22055183474ec44a9 100644 (file)
 //#include "utilities.h"
 
 namespace Batch {
+  
+  static FactBatchManager_Local_RSH* instanceOfFBM_eLSF()
+  {
+    static FactBatchManager_Local_RSH* sFBM_Local_RSH = 0;
+    if ( !sFBM_Local_RSH )
+      sFBM_Local_RSH = new FactBatchManager_Local_RSH();
 
-  static FactBatchManager_Local_RSH sFBM_Local_RSH;
+    return sFBM_Local_RSH;
+  }
 
   // Constructeur
   FactBatchManager_Local_RSH::FactBatchManager_Local_RSH() : FactBatchManager("RSH")
index bf10abd14b900682844d0c157304156ab6780f6d..1f68befd17d971621d4c1d3e6dde7f066e7c1cff 100644 (file)
@@ -28,9 +28,6 @@
 #ifndef _FACTBATCHMANAGER_LOCAL_RSH_H_
 #define _FACTBATCHMANAGER_LOCAL_RSH_H_
 
-using namespace std;
-#include <string>
-#include <map>
 #include "Batch_FactBatchManager.hxx"
 
 namespace Batch {
index 8ac703a7464cf44e91fb47150bb266aceb74d148..29ff50d0789b04da0140ba22477388557e9e70ed 100644 (file)
@@ -28,9 +28,6 @@
 #ifndef _FACTBATCHMANAGER_LOCAL_SH_H_
 #define _FACTBATCHMANAGER_LOCAL_SH_H_
 
-using namespace std;
-#include <string>
-#include <map>
 #include "Batch_FactBatchManager.hxx"
 
 namespace Batch {
index 2c3c14e03c4c0dec6302fd6660caa3ea2f52af28..4d97642473c54dea0ccd83865bf0a2f3bdfd2be9 100644 (file)
@@ -28,9 +28,6 @@
 #ifndef _FACTBATCHMANAGER_LOCAL_SSH_H_
 #define _FACTBATCHMANAGER_LOCAL_SSH_H_
 
-using namespace std;
-#include <string>
-#include <map>
 #include "Batch_FactBatchManager.hxx"
 
 namespace Batch {
index 227bffa3277a3e669c27eb2ac5121768d8c06938..d77c4c71b678b1dc6b5f11d375d77f21e95b74aa 100644 (file)
 
 namespace Batch {
 
-  static FactBatchManager_eLSF sFBM_eLSF;
+static FactBatchManager_eLSF* instanceOfFBM_eLSF()
+{
+  static FactBatchManager_eLSF* sFBM_eLSF = 0;
+  if ( !sFBM_eLSF )
+    sFBM_eLSF = new FactBatchManager_eLSF();
+
+  return sFBM_eLSF;
+}
+  
 
   // Constructeur
   FactBatchManager_eLSF::FactBatchManager_eLSF() : FactBatchManager_eClient("eLSF")
index e1660aaaa2730e6f394737f260400838a4cb4c54..558ee007e67f33b9cf4afea1a0a5b5292c0d2c35 100644 (file)
@@ -29,7 +29,8 @@
 #ifndef _FACTBATCHMANAGER_eLSF_H_
 #define _FACTBATCHMANAGER_eLSF_H_
 
-using namespace std;
+#include "Batch_Defines.hxx"
+
 #include <string>
 #include <map>
 #include "Batch_BatchManager_eClient.hxx"
@@ -39,7 +40,7 @@ namespace Batch {
   
   class BatchManager_eLSF;
 
-  class FactBatchManager_eLSF : public FactBatchManager_eClient
+  class BATCH_EXPORT FactBatchManager_eLSF : public FactBatchManager_eClient
   {
   public:
     // Constructeur et destructeur
index 3bcbda530efb2e1213a38993f398d19748b4838a..3611a05ea613c9a619554594a3feddbbd343b0fb 100644 (file)
 
 namespace Batch {
 
-  static FactBatchManager_ePBS sFBM_ePBS;
+  static FactBatchManager_ePBS* instanceOfFBM_eLSF()
+  {
+    static FactBatchManager_ePBS* sFBM_ePBS = 0;
+    if ( !sFBM_ePBS )
+      sFBM_ePBS = new FactBatchManager_ePBS();
+
+    return sFBM_ePBS;
+  }
 
   // Constructeur
   FactBatchManager_ePBS::FactBatchManager_ePBS() : FactBatchManager_eClient("ePBS")
index 69fdf322a4979adfc10798c1e6f8a1394bba1e55..b78e76144f35541c9b7def431a9273f38b72d1de 100644 (file)
@@ -29,7 +29,8 @@
 #ifndef _FACTBATCHMANAGER_ePBS_H_
 #define _FACTBATCHMANAGER_ePBS_H_
 
-using namespace std;
+#include "Batch_Defines.hxx"
+
 #include <string>
 #include <map>
 #include "Batch_BatchManager_eClient.hxx"
@@ -39,7 +40,7 @@ namespace Batch {
   
   class BatchManager_ePBS;
 
-  class FactBatchManager_ePBS : public FactBatchManager_eClient
+  class BATCH_EXPORT FactBatchManager_ePBS : public FactBatchManager_eClient
   {
   public:
     // Constructeur et destructeur
index f62b6a2b900812f940121b98fabeacf191a3449e..89f79f49abdc4a40d25c1113b93e452270e9f968 100644 (file)
 #ifndef _GENERICEXCEPTION_H_
 #define _GENERICEXCEPTION_H_
 
+#include "Batch_Defines.hxx"
+
 
 #include <string>
 
 namespace Batch {
 
-  class GenericException
+  class BATCH_EXPORT GenericException
   {
   public:
     const std::string type;    // la nature de l'exception
index 674b843ad96ccd3ea9df409577278807c419b505..c5d7faf836e018077809cb8d204a55badd3980c0 100644 (file)
 #ifndef _GENERICTYPE_H_
 #define _GENERICTYPE_H_
 
+#include "Batch_Defines.hxx"
+
 
 #include <iostream>
 #include <string>
 
 namespace Batch {
 
-  class GenericType
+  class BATCH_EXPORT GenericType
   {
   public:
                // Constructeur et destructeur
index 82ca73a10e1913a49fb6c9473b18c12ed8f859b5..3808c9514b0a1a17f40165940f64af98600cb1a0 100644 (file)
 #ifndef _INTTYPE_H_
 #define _INTTYPE_H_
 
+#include "Batch_Defines.hxx"
+
 #include <string>
 #include "Batch_GenericType.hxx"
 
 namespace Batch {
 
-  class IntType : public GenericType
+  class BATCH_EXPORT IntType : public GenericType
   {
   public:
                // Constructeur
index 68b417ddad1b2dc547277ef009da7d79c812d39c..8ca04c190629f08b21db4f86e629372ba8958aae 100644 (file)
 #define _INVALIDARGUMENTEXCEPTION_H_
 
 
+#include "Batch_Defines.hxx"
+
 #include "Batch_GenericException.hxx"
 #include "Batch_GenericException.hxx"
 
 namespace Batch {
 
-  class InvalidArgumentException : public GenericException
+  class BATCH_EXPORT InvalidArgumentException : public GenericException
   {
   public:
                // Constructeur
index e07b876ee6ba748229d41c8031f7a554af6b6e39..7c9c7022a33f11e8fcc53d653030337699a686f7 100644 (file)
 #ifndef _INVALIDKEYEXCEPTION_H_
 #define _INVALIDKEYEXCEPTION_H_
 
+#include "Batch_Defines.hxx"
+
 
 #include "Batch_GenericException.hxx"
 #include "Batch_GenericException.hxx"
 
 namespace Batch {
 
-  class InvalidKeyException : public GenericException
+  class BATCH_EXPORT InvalidKeyException : public GenericException
   {
   public:
                // Constructeur
index d6ad5442b4f48a3b8efed01ed8482cea70ff497b..fabecde27ce2f61e2c88298a6ec222a4b65be0d8 100644 (file)
 #ifndef _JOB_H_
 #define _JOB_H_
 
+#include "Batch_Defines.hxx"
+
 
 #include "Batch_Parametre.hxx"
 #include "Batch_Environnement.hxx"
 
 namespace Batch {
 
-  class Job
+  class BATCH_EXPORT Job
   {
   public:
     // Constructeurs et destructeur
index 5046d6a310d0e132aa866ebc650d8be3051e1aca..9ae57d183f62b887b58a12de74e5223e6dcb1bf1 100644 (file)
@@ -30,6 +30,8 @@
 #define _JOBID_H_
 
 
+#include "Batch_Defines.hxx"
+
 #include "Batch_JobInfo.hxx"
 #include "Batch_BatchManager.hxx"
 
@@ -37,7 +39,7 @@ namespace Batch {
 
   class BatchManager;
 
-  class JobId
+  class BATCH_EXPORT JobId
   {
     friend class BatchManager;
 
index 6e985fdb2ab3aee70577b54afe10aa89de31e750..71fe3113b72b0c6608399f698d4b4de95f31ae73 100644 (file)
@@ -33,6 +33,8 @@
 //#include "MEDMEM_STRING.hxx"
 #include "Batch_JobInfo.hxx"
 
+using namespace std;
+
 namespace Batch {
 
   // Destructeur
index fbb4e35b16a7fa452af2ecd862acaca4a62c83d9..7ec3a5764dafe93254bfacb2e1e520cb008498fa 100644 (file)
@@ -30,7 +30,8 @@
 #ifndef _JOBINFO_H_
 #define _JOBINFO_H_
 
-using namespace std;
+#include "Batch_Defines.hxx"
+
 #include <iostream>
 #include <string>
 #include "Batch_Parametre.hxx"
@@ -38,7 +39,7 @@ using namespace std;
 
 namespace Batch {
 
-  class JobInfo
+  class BATCH_EXPORT JobInfo
   {
   public:
     // Constructeur standard et destructeur
@@ -49,7 +50,7 @@ namespace Batch {
     JobInfo(const JobInfo & jinfo) : _param(jinfo._param), _env(jinfo._env) {};
 
     // Operateur pour l'affichage sur un stream
-    friend ostream & operator <<(ostream & os, const JobInfo & ji);
+    friend std::ostream & operator <<(std::ostream & os, const JobInfo & ji);
 
     // Accesseurs
     // _CS_gbo Ajout explicite du namespace pour les besoins de swig (mauvaise gestion
@@ -59,8 +60,8 @@ namespace Batch {
 
     // Methodes pour l'interfacage avec Python (SWIG)
     // TODO : supprimer ces methodes et transferer leur definitions dans SWIG
-    string  __str__() const; // SWIG : affichage en Python
-    string  __repr__() const { return __str__(); }; // SWIG : affichage en Python
+    std::string  __str__() const; // SWIG : affichage en Python
+    std::string  __repr__() const { return __str__(); }; // SWIG : affichage en Python
 
   protected:
     Parametre _param; // parametres du job
index 177f2eb06332341a5eb4971bbc8d6ddada935a3c..5edeb0a5b6b437438f8bff6b1754dd84e9be9c47 100644 (file)
@@ -37,6 +37,8 @@
 #include "Batch_APIInternalFailureException.hxx"
 #include "Batch_JobInfo_eLSF.hxx"
 
+using namespace std;
+
 namespace Batch {
 
 
index 51d3f6fd37a8be8cd5ff07b4b2e087e6b708fb30..52b7282cfd38cd95fd6009e866536c8ea7a9324a 100644 (file)
 #ifndef _JOBINFO_LSF_H_
 #define _JOBINFO_LSF_H_
 
-#include <string>
 #include "Batch_RunTimeException.hxx"
 #include "Batch_JobInfo.hxx"
 
+#include <string>
+
 namespace Batch {
 
   class JobInfo_eLSF : public JobInfo
@@ -52,15 +53,15 @@ namespace Batch {
 
     // Methodes pour l'interfacage avec Python (SWIG)
     // TODO : supprimer ces methodes et transferer leur definitions dans SWIG
-    string  __str__() const; // SWIG : affichage en Python
-    string  __repr__() const { return __str__(); }; // SWIG : affichage en Python
+    std::string  __str__() const; // SWIG : affichage en Python
+    std::string  __repr__() const { return __str__(); }; // SWIG : affichage en Python
 
   protected:
     bool _running; // etat du job en machine
 
   private:
     // Convertit une date HH:MM:SS en secondes
-    long HMStoLong(const string &);
+    long HMStoLong(const std::string &);
 
   };
 
index 6d9807a0c68c3e2af65326edbeda2eede71e4743..8a1c9750640725873a6c33b84310c017539791ab 100644 (file)
@@ -37,6 +37,8 @@
 #include "Batch_APIInternalFailureException.hxx"
 #include "Batch_JobInfo_ePBS.hxx"
 
+using namespace std;
+
 namespace Batch {
 
 
index 79fb0b782f19867382a959333d05bd49ff5071e3..03a8601aa82c4ad332c7d80f9b54da3e5c19aa29 100644 (file)
@@ -52,15 +52,15 @@ namespace Batch {
 
     // Methodes pour l'interfacage avec Python (SWIG)
     // TODO : supprimer ces methodes et transferer leur definitions dans SWIG
-    string  __str__() const; // SWIG : affichage en Python
-    string  __repr__() const { return __str__(); }; // SWIG : affichage en Python
+    std::string  __str__() const; // SWIG : affichage en Python
+    std::string  __repr__() const { return __str__(); }; // SWIG : affichage en Python
 
   protected:
     bool _running; // etat du job en machine
 
   private:
     // Convertit une date HH:MM:SS en secondes
-    long HMStoLong(const string &);
+    long HMStoLong(const std::string &);
 
   };
 
index bc276f819f9e3367c3387c546b77b5adf7932ee3..896532c96156b31a7cdbeca672862c1d5a864a5b 100644 (file)
 
 #include <stdio.h>
 #include <stdlib.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include "Batch_Job_Local.hxx"
 
+using namespace std;
+
 namespace Batch {
 
   // Constructeur
index 241defeb8941c102c55ddc25f5a1b62ef4c0ddba..0525ba44916cacdc0c6b72edba56dc4be70ddcaf 100644 (file)
 #ifndef _LISTISFULLEXCEPTION_H_
 #define _LISTISFULLEXCEPTION_H_
 
+#include "Batch_Defines.hxx"
+
 #include "Batch_GenericException.hxx"
 
 namespace Batch {
 
-  class ListIsFullException : public GenericException
+  class BATCH_EXPORT ListIsFullException : public GenericException
   {
   public:
                // Constructeur
index f43e8615e2f930ab3b0af3b98f971cd9fe19a0ac..3970ae0e784a723060f434b6c16cc53301d8ff39 100644 (file)
 #ifndef _LONGTYPE_H_
 #define _LONGTYPE_H_
 
+#include "Batch_Defines.hxx"
+
 #include <string>
 #include "Batch_GenericType.hxx"
 
 namespace Batch {
 
-  class LongType : public GenericType
+  class BATCH_EXPORT LongType : public GenericType
   {
   public:
                // Constructeur
index 93f219842620b135d97871dcbaa73a7173ca55f4..43e943f8b4576ca55c97d42236b9c51a1fcf206d 100644 (file)
@@ -30,6 +30,8 @@
 #ifndef _MAPKEY_H_
 #define _MAPKEY_H_
 
+#include "Batch_Defines.hxx"
+
 
 #include <string>
 
@@ -37,7 +39,7 @@ namespace Batch {
 
   // une classe privee pour les differents types
   // ces types ne peuvent pas etre redefinis
-  class MapKey : public std::string
+  class BATCH_EXPORT MapKey : public std::string
   {
   private:
     friend class Parametre; // seule la classe Parametre peut creer des MapKey
index 54f4f6205819fc743de59e8021372b7c8fd120a8..509aceaca45d3e2f612ab99fd1a71136de6cd4cf 100644 (file)
 #ifndef _NOTYETIMPLEMENTEDEXCEPTION_H_
 #define _NOTYETIMPLEMENTEDEXCEPTION_H_
 
-
+#include "Batch_Defines.hxx"
 #include "Batch_GenericException.hxx"
-using namespace std;
+
+#include <string>
 
 namespace Batch {
 
-  class NotYetImplementedException : public GenericException
+  class BATCH_EXPORT NotYetImplementedException : public GenericException
   {
   public:
                // Constructeur
-    NotYetImplementedException(string ch = "undefined") : GenericException("NotYetImplementedException", ch) {}
+    NotYetImplementedException(std::string ch = "undefined") : GenericException("NotYetImplementedException", ch) {}
   };
 
 }
index b218cc44377b0c6aef4ad1d6c6cc9a5a6fb33f70..1facc62874dd50638a50eeaa08e606122f1bcad4 100644 (file)
  *
  */
 
-#include <map>
 #include "Batch_Versatile.hxx"
 #include "Batch_InvalidKeyException.hxx"
 #include "Batch_Parametre.hxx"
 
+using namespace std;
+
 // Definition des membres constants statiques
 // Definition des noms globaux pour les clefs en tant que references
 // TODO : supprimer les declarations statiques des clefs de la map
index ce88da4f931208afd5c3376fd0cda5c20fcf6b4b..e6feedf9c125e9dd7dbe4ddf8437c6d5322ee197 100644 (file)
 #ifndef _PARAMETRE_H_
 #define _PARAMETRE_H_
 
-using namespace std;
+#include "Batch_Defines.hxx"
+
 #include <map>
 #include <string>
 #include "Batch_InvalidKeyException.hxx"
 #include "Batch_Versatile.hxx"
 
-
 // Ces macros permettent de simplifier l'ajout de nouvelles
 // clefs dans la map Parametre
 // TODO : remplacer ce mecanisme statique par la lecture
 // TODO : d'une descrption dans un fichier exterieur (genre XML)
 
-#define def_extern_MapKey(mk) extern const string & mk;
-#define def_static_MapKey(mk) const string Batch::Parametre::mk(#mk);  \
-  const string & mk = Batch::Parametre::mk;
+#define def_extern_MapKey(mk) extern BATCH_EXPORT const std::string & mk;
+#define def_static_MapKey(mk) const std::string Batch::Parametre::mk(#mk);     \
+  const std::string & mk = Batch::Parametre::mk;
 
 namespace Batch {
 
-  class Parametre : public map< string, Versatile >
+  class BATCH_EXPORT Parametre : public std::map< std::string, Versatile >
   {
   public:
     // Constructeur standard
@@ -57,56 +57,56 @@ namespace Batch {
     Parametre(const Parametre & PM);
 
     // Operateur de recherche dans la map
-    Versatile & operator [] (const string &);
-    const Versatile & operator [] (const string &) const;
+    Versatile & operator [] (const std::string &);
+    const Versatile & operator [] (const std::string &) const;
 
     // Operateur d'affectation
     Parametre & operator =(const Parametre & PM);
 
     // Declarations statique des clefs de la map
     // TODO : supprimer les declarations statiques des clefs de la map
-    static const string ACCOUNT;
-    static const string ARGUMENTS;
-    static const string CHECKPOINT;
-    static const string CKPTINTERVAL;
-    static const string CREATIONTIME;
-    static const string EGROUP;
-    static const string ELIGIBLETIME;
-    static const string ENDTIME;
-    static const string EUSER;
-    static const string EXECUTABLE;
-    static const string EXECUTIONHOST;
-    static const string EXITCODE;
-    static const string HOLD;
-    static const string ID;
-    static const string INFILE;
-    static const string MAIL;
-    static const string MAXCPUTIME;
-    static const string MAXDISKSIZE;
-    static const string MAXRAMSIZE;
-    static const string MAXWALLTIME;
-    static const string MODIFICATIONTIME;
-    static const string NAME;
-    static const string NBPROC;
-    static const string OUTFILE;
-    static const string PID;
-    static const string QUEUE;
-    static const string QUEUEDTIME;
-    static const string SERVER;
-    static const string STARTTIME;
-    static const string STATE;
-    static const string TEXT;
-    static const string TMPDIR;
-    static const string USEDCPUTIME;
-    static const string USEDDISKSIZE;
-    static const string USEDRAMSIZE;
-    static const string USEDWALLTIME;
-    static const string USER;
-    static const string WORKDIR;
-    static const string HOMEDIR;
+    static const std::string ACCOUNT;
+    static const std::string ARGUMENTS;
+    static const std::string CHECKPOINT;
+    static const std::string CKPTINTERVAL;
+    static const std::string CREATIONTIME;
+    static const std::string EGROUP;
+    static const std::string ELIGIBLETIME;
+    static const std::string ENDTIME;
+    static const std::string EUSER;
+    static const std::string EXECUTABLE;
+    static const std::string EXECUTIONHOST;
+    static const std::string EXITCODE;
+    static const std::string HOLD;
+    static const std::string ID;
+    static const std::string INFILE;
+    static const std::string MAIL;
+    static const std::string MAXCPUTIME;
+    static const std::string MAXDISKSIZE;
+    static const std::string MAXRAMSIZE;
+    static const std::string MAXWALLTIME;
+    static const std::string MODIFICATIONTIME;
+    static const std::string NAME;
+    static const std::string NBPROC;
+    static const std::string OUTFILE;
+    static const std::string PID;
+    static const std::string QUEUE;
+    static const std::string QUEUEDTIME;
+    static const std::string SERVER;
+    static const std::string STARTTIME;
+    static const std::string STATE;
+    static const std::string TEXT;
+    static const std::string TMPDIR;
+    static const std::string USEDCPUTIME;
+    static const std::string USEDDISKSIZE;
+    static const std::string USEDRAMSIZE;
+    static const std::string USEDWALLTIME;
+    static const std::string USER;
+    static const std::string WORKDIR;
+    static const std::string HOMEDIR;
 
   protected:
-    map< string, TypeParam > TypeMap; // map interne servant a controler le type de la valeur associee a chaque clef
+    std::map< std::string, TypeParam > TypeMap; // map interne servant a controler le type de la valeur associee a chaque clef
 
   private:
 
index f38132ca25e1e5ccddb598f0503365b1f2d4ea53..10541cb186d8ab4ef55972971715d133a3281109 100644 (file)
@@ -34,6 +34,8 @@
 #include "Batch_PyVersatile.hxx"
 #include <string>
 
+using namespace std;
+
 namespace Batch {
 
   // Constructeur a partir d'un objet Versatile
index e111bac43e363d9ca945ca5902785b27f3865562..3bc37f2c5f0e3a82e384e9bae858831a0d87bbda 100644 (file)
 #define _PYVERSATILE_H_
 
 
+#include "Batch_Defines.hxx"
+
 #include <Python.h>
 #include "Batch_Versatile.hxx"
 #include "Batch_TypeMismatchException.hxx"
 #include "Batch_ListIsFullException.hxx"
 #include "Batch_InvalidArgumentException.hxx"
-using namespace std;
 
 namespace Batch {
 
-  class PyVersatile : public Versatile
+  class BATCH_EXPORT PyVersatile : public Versatile
   {
   public:
                // Constructeur a partir d'un objet Versatile
index 3df53a5ca5d2fb40fbaf33a4ad38a3ce4efe4bb1..fe1e168d4adfbb27b8150b8d64d6ba68ba291a15 100644 (file)
 #ifndef _RUNTIMEEXCEPTION_H_
 #define _RUNTIMEEXCEPTION_H_
 
+#include "Batch_Defines.hxx"
+
 
 #include "Batch_GenericException.hxx"
 
 namespace Batch {
 
-  class RunTimeException : public GenericException
+  class BATCH_EXPORT RunTimeException : public GenericException
   {
   public:
                // Constructeur
index a72173c7e04281e53bbd3c321d8fe1c1ef6f71f5..510924e9bbaa326ca53ab1afa480a3cbd40ac47c 100644 (file)
 #ifndef _STRINGTYPE_H_
 #define _STRINGTYPE_H_
 
+#include "Batch_Defines.hxx"
+
 #include <string>
 #include "Batch_GenericType.hxx"
 
 namespace Batch {
 
-  class StringType : public GenericType
+  class BATCH_EXPORT StringType : public GenericType
   {
   public:
                // Constructeur
index d235ec20e068b1982f3414ee24266b92d707bc1b..b231060dcc20203fb2b618e6b761286e2997b650 100644 (file)
 #ifndef _TYPEMISMATCHEXCEPTION_H_
 #define _TYPEMISMATCHEXCEPTION_H_
 
+#include "Batch_Defines.hxx"
+
 
 #include "Batch_GenericException.hxx"
 
 namespace Batch {
 
-  class TypeMismatchException : public GenericException
+  class BATCH_EXPORT TypeMismatchException : public GenericException
   {
   public:
                // Constructeur
index cf97bbb30873caa50ecc4403bd8c0359f09e842c..c7b6f3bf6421f935b27c67840ac190a6a4f934ec 100644 (file)
@@ -29,6 +29,8 @@
 #ifndef _VERSATILE_H_
 #define _VERSATILE_H_
 
+#include "Batch_Defines.hxx"
+
 #include <iostream>
 #include <list>
 #include <string>
@@ -53,7 +55,7 @@ namespace Batch {
     int maxelem; // le nombre d'elements autorises
   } TypeParam;
 
-  class Versatile : public std::list< GenericType * >
+  class BATCH_EXPORT Versatile : public std::list< GenericType * >
   {
   public:
                // Constructeur standard et destructeur
index c6c2cbf86fc70f9cd6e54a3d756733395f98ba04..aaaa33e2b866b6ae9d0e9795832c370567951892 100644 (file)
@@ -68,7 +68,8 @@ LIB_INCLUDES = \
        Batch_BatchManager_ePBS.hxx \
        Batch_FactBatchManager_ePBS.hxx \
        Batch_JobInfo_ePBS.hxx \
-       MpiImpl.hxx
+       MpiImpl.hxx \
+       Batch_Defines.hxx
 
 
 LIB_SRC = \
@@ -116,7 +117,7 @@ LIB_CPPFLAGS = \
        ${PYTHON_INCLUDES} \
        -I$(srcdir)/../Basics \
        -I$(srcdir)/../SALOMELocalTrace \
-  -I$(top_builddir)/salome_adm/unix
+       -I$(top_builddir)/salome_adm/unix
 
 LIB_LIBADD   = \
        ../SALOMELocalTrace/libSALOMELocalTrace.la \
index 07f306bdfa79a1b6c58acc14978f251931a9d8e2..1056c25815c812ef6df96220c830751f8fa64de6 100644 (file)
 #ifndef _BL_MPIIMPL_H_
 #define _BL_MPIIMPL_H_
 
+#include "Batch_Defines.hxx"
 #include <string>
 
-class MpiImplException
+class BATCH_EXPORT MpiImplException
 {
 public:
   const std::string msg;
@@ -39,7 +40,7 @@ public:
   MpiImplException(const std::string m) : msg(m) {}
 };
 
-class MpiImpl
+class BATCH_EXPORT MpiImpl
 {
 public:
   // Constructeur et destructeur
@@ -58,7 +59,7 @@ private:
 
 };
 
-class MpiImpl_LAM : public MpiImpl
+class BATCH_EXPORT MpiImpl_LAM : public MpiImpl
 {
 public:
   // Constructeur et destructeur
@@ -77,7 +78,7 @@ private:
 
 };
 
-class MpiImpl_MPICH1 : public MpiImpl
+class BATCH_EXPORT MpiImpl_MPICH1 : public MpiImpl
 {
 public:
   // Constructeur et destructeur
@@ -96,7 +97,7 @@ private:
 
 };
 
-class MpiImpl_MPICH2 : public MpiImpl
+class BATCH_EXPORT MpiImpl_MPICH2 : public MpiImpl
 {
 public:
   // Constructeur et destructeur
@@ -115,7 +116,7 @@ private:
 
 };
 
-class MpiImpl_OPENMPI : public MpiImpl
+class BATCH_EXPORT MpiImpl_OPENMPI : public MpiImpl
 {
 public:
   // Constructeur et destructeur
@@ -134,7 +135,7 @@ private:
 
 };
 
-class MpiImpl_SLURM : public MpiImpl
+class BATCH_EXPORT MpiImpl_SLURM : public MpiImpl
 {
 public:
   // Constructeur et destructeur