From: abd Date: Fri, 3 Oct 2008 09:06:57 +0000 (+0000) Subject: Win32 Porting. X-Git-Tag: RELIQUAT_4x_25102008~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=04bb2ce5f5dd58c5ec83af2701017e004a06e4b7;p=modules%2Fkernel.git Win32 Porting. Correction of Export/Import defines for Win32 platform --- diff --git a/src/Batch/Batch_APIInternalFailureException.hxx b/src/Batch/Batch_APIInternalFailureException.hxx index 4e5d57457..cb8bb1be8 100644 --- a/src/Batch/Batch_APIInternalFailureException.hxx +++ b/src/Batch/Batch_APIInternalFailureException.hxx @@ -30,13 +30,14 @@ #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 diff --git a/src/Batch/Batch_BatchManager.cxx b/src/Batch/Batch_BatchManager.cxx index 8d3965274..650642008 100644 --- a/src/Batch/Batch_BatchManager.cxx +++ b/src/Batch/Batch_BatchManager.cxx @@ -29,7 +29,12 @@ #include #include #include -#include +#ifdef WIN32 +# include +#else +# include +#endif + //#include "MEDMEM_STRING.hxx" #include "Batch_Job.hxx" #include "Batch_JobId.hxx" diff --git a/src/Batch/Batch_BatchManager.hxx b/src/Batch/Batch_BatchManager.hxx index 92a81a732..c00f70c0d 100644 --- a/src/Batch/Batch_BatchManager.hxx +++ b/src/Batch/Batch_BatchManager.hxx @@ -29,6 +29,8 @@ #ifndef _BATCHMANAGER_H_ #define _BATCHMANAGER_H_ +#include "Batch_Defines.hxx" + #include #include #include "Batch_Job.hxx" @@ -43,7 +45,7 @@ namespace Batch { class JobInfo; class FactBatchManager; - class BatchManager + class BATCH_EXPORT BatchManager { public: // Constructeur et destructeur diff --git a/src/Batch/Batch_BatchManagerCatalog.hxx b/src/Batch/Batch_BatchManagerCatalog.hxx index 81ab713ec..d19ae24e3 100644 --- a/src/Batch/Batch_BatchManagerCatalog.hxx +++ b/src/Batch/Batch_BatchManagerCatalog.hxx @@ -29,6 +29,8 @@ #ifndef _CATALOG_H_ #define _CATALOG_H_ +#include "Batch_Defines.hxx" + #include #include #include @@ -37,7 +39,7 @@ namespace Batch { class FactBatchManager; - class BatchManagerCatalog + class BATCH_EXPORT BatchManagerCatalog { public: // Constructeur diff --git a/src/Batch/Batch_BatchManager_LSF.hxx b/src/Batch/Batch_BatchManager_LSF.hxx index 170dbd791..e81f2df9d 100644 --- a/src/Batch/Batch_BatchManager_LSF.hxx +++ b/src/Batch/Batch_BatchManager_LSF.hxx @@ -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 diff --git a/src/Batch/Batch_BatchManager_Local.cxx b/src/Batch/Batch_BatchManager_Local.cxx index 5359c3d1c..049e2afce 100644 --- a/src/Batch/Batch_BatchManager_Local.cxx +++ b/src/Batch/Batch_BatchManager_Local.cxx @@ -17,23 +17,27 @@ // 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 #include #include #include #include -#include +#ifdef WIN32 +# include +#else +# include +# include +#endif #include -#include #include #include #include @@ -41,11 +45,16 @@ #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(p_ta)); + &thread_attr, + &ThreadAdapter::run, + static_cast(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::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( (*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( (*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(*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(*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(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) diff --git a/src/Batch/Batch_BatchManager_Local.hxx b/src/Batch/Batch_BatchManager_Local.hxx index 53091cab2..d797aaf28 100644 --- a/src/Batch/Batch_BatchManager_Local.hxx +++ b/src/Batch/Batch_BatchManager_Local.hxx @@ -29,11 +29,11 @@ #ifndef _BATCHMANAGER_LOCAL_H_ #define _BATCHMANAGER_LOCAL_H_ +#include "Batch_Defines.hxx" #include #include #include -#include #include #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 > command_queue; + std::queue > 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 _threads; + std::map _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 _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 _thread_id_id_association; +#endif #ifdef SWIG public: diff --git a/src/Batch/Batch_BatchManager_Local_RSH.cxx b/src/Batch/Batch_BatchManager_Local_RSH.cxx index e93ede663..a99a9cdcd 100644 --- a/src/Batch/Batch_BatchManager_Local_RSH.cxx +++ b/src/Batch/Batch_BatchManager_Local_RSH.cxx @@ -35,9 +35,11 @@ #include #include #include +#ifndef WIN32 #include -#include #include +#endif +#include #include #include #include @@ -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 { diff --git a/src/Batch/Batch_BatchManager_Local_RSH.hxx b/src/Batch/Batch_BatchManager_Local_RSH.hxx index be7a4a04b..0580a4aad 100644 --- a/src/Batch/Batch_BatchManager_Local_RSH.hxx +++ b/src/Batch/Batch_BatchManager_Local_RSH.hxx @@ -29,6 +29,7 @@ #ifndef _BATCHMANAGER_LOCAL_RSH_H_ #define _BATCHMANAGER_LOCAL_RSH_H_ +#include "Batch_Defines.hxx" #include #include @@ -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; }; diff --git a/src/Batch/Batch_BatchManager_Local_SH.cxx b/src/Batch/Batch_BatchManager_Local_SH.cxx index be9b990ea..beead5209 100644 --- a/src/Batch/Batch_BatchManager_Local_SH.cxx +++ b/src/Batch/Batch_BatchManager_Local_SH.cxx @@ -35,7 +35,9 @@ #include #include #include +#ifndef WIN32 #include +#endif #include #include #include @@ -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 { diff --git a/src/Batch/Batch_BatchManager_Local_SH.hxx b/src/Batch/Batch_BatchManager_Local_SH.hxx index c3de1af7a..31f79b2aa 100644 --- a/src/Batch/Batch_BatchManager_Local_SH.hxx +++ b/src/Batch/Batch_BatchManager_Local_SH.hxx @@ -29,6 +29,7 @@ #ifndef _BATCHMANAGER_LOCAL_SH_H_ #define _BATCHMANAGER_LOCAL_SH_H_ +#include "Batch_Defines.hxx" #include #include @@ -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; }; diff --git a/src/Batch/Batch_BatchManager_Local_SSH.cxx b/src/Batch/Batch_BatchManager_Local_SSH.cxx index 696d7473e..697c9ea2f 100644 --- a/src/Batch/Batch_BatchManager_Local_SSH.cxx +++ b/src/Batch/Batch_BatchManager_Local_SSH.cxx @@ -35,9 +35,12 @@ #include #include #include +#ifndef WIN32 #include -#include #include +#endif +#include + #include #include #include @@ -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 { diff --git a/src/Batch/Batch_BatchManager_Local_SSH.hxx b/src/Batch/Batch_BatchManager_Local_SSH.hxx index b45314f3c..33ecda42d 100644 --- a/src/Batch/Batch_BatchManager_Local_SSH.hxx +++ b/src/Batch/Batch_BatchManager_Local_SSH.hxx @@ -29,6 +29,7 @@ #ifndef _BATCHMANAGER_LOCAL_SSH_H_ #define _BATCHMANAGER_LOCAL_SSH_H_ +#include "Batch_Defines.hxx" #include #include @@ -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; }; diff --git a/src/Batch/Batch_BatchManager_PBS.hxx b/src/Batch/Batch_BatchManager_PBS.hxx index 53e8a2798..9e995b540 100644 --- a/src/Batch/Batch_BatchManager_PBS.hxx +++ b/src/Batch/Batch_BatchManager_PBS.hxx @@ -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 diff --git a/src/Batch/Batch_BatchManager_eClient.cxx b/src/Batch/Batch_BatchManager_eClient.cxx index 41ce47c2e..a005cec9c 100644 --- a/src/Batch/Batch_BatchManager_eClient.cxx +++ b/src/Batch/Batch_BatchManager_eClient.cxx @@ -18,20 +18,25 @@ // 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 #include #include #include -#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); } - } diff --git a/src/Batch/Batch_BatchManager_eClient.hxx b/src/Batch/Batch_BatchManager_eClient.hxx index 717eae6a3..f3d27c406 100644 --- a/src/Batch/Batch_BatchManager_eClient.hxx +++ b/src/Batch/Batch_BatchManager_eClient.hxx @@ -30,15 +30,18 @@ #ifndef _BATCHMANAGER_eClient_H_ #define _BATCHMANAGER_eClient_H_ +#include "Batch_Defines.hxx" #include "MpiImpl.hxx" #include "Batch_BatchManager.hxx" +#include + 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: diff --git a/src/Batch/Batch_BatchManager_eLSF.cxx b/src/Batch/Batch_BatchManager_eLSF.cxx index d1c44e60d..2533a3186 100644 --- a/src/Batch/Batch_BatchManager_eLSF.cxx +++ b/src/Batch/Batch_BatchManager_eLSF.cxx @@ -32,6 +32,12 @@ #include #include #include "Batch_BatchManager_eLSF.hxx" +#ifdef WIN32 +# include +# include +#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 } diff --git a/src/Batch/Batch_BatchManager_eLSF.hxx b/src/Batch/Batch_BatchManager_eLSF.hxx index 00d79a4fa..9673d1a1e 100644 --- a/src/Batch/Batch_BatchManager_eLSF.hxx +++ b/src/Batch/Batch_BatchManager_eLSF.hxx @@ -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 diff --git a/src/Batch/Batch_BatchManager_ePBS.cxx b/src/Batch/Batch_BatchManager_ePBS.cxx index 999025cfb..fa612adda 100644 --- a/src/Batch/Batch_BatchManager_ePBS.cxx +++ b/src/Batch/Batch_BatchManager_ePBS.cxx @@ -32,6 +32,12 @@ #include #include #include "Batch_BatchManager_ePBS.hxx" +#ifdef WIN32 +# include +# include +#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 } } diff --git a/src/Batch/Batch_BatchManager_ePBS.hxx b/src/Batch/Batch_BatchManager_ePBS.hxx index 42f4b1b69..2bfa60a1a 100644 --- a/src/Batch/Batch_BatchManager_ePBS.hxx +++ b/src/Batch/Batch_BatchManager_ePBS.hxx @@ -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 diff --git a/src/Batch/Batch_BoolType.hxx b/src/Batch/Batch_BoolType.hxx index b367b3a02..f25c24c5f 100644 --- a/src/Batch/Batch_BoolType.hxx +++ b/src/Batch/Batch_BoolType.hxx @@ -29,12 +29,14 @@ #ifndef _BOOLTYPE_H_ #define _BOOLTYPE_H_ +#include "Batch_Defines.hxx" + #include #include "Batch_GenericType.hxx" namespace Batch { - class BoolType : public GenericType + class BATCH_EXPORT BoolType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_CharType.hxx b/src/Batch/Batch_CharType.hxx index f4894f5d0..abac3be3a 100644 --- a/src/Batch/Batch_CharType.hxx +++ b/src/Batch/Batch_CharType.hxx @@ -29,12 +29,14 @@ #ifndef _CHARTYPE_H_ #define _CHARTYPE_H_ +#include "Batch_Defines.hxx" + #include #include "Batch_GenericType.hxx" namespace Batch { - class CharType : public GenericType + class BATCH_EXPORT CharType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_ConnexionFailureException.hxx b/src/Batch/Batch_ConnexionFailureException.hxx index 9ae672885..0d3a47e86 100644 --- a/src/Batch/Batch_ConnexionFailureException.hxx +++ b/src/Batch/Batch_ConnexionFailureException.hxx @@ -30,12 +30,14 @@ #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 diff --git a/src/Batch/Batch_Couple.hxx b/src/Batch/Batch_Couple.hxx index 717a1c228..9c0deed45 100644 --- a/src/Batch/Batch_Couple.hxx +++ b/src/Batch/Batch_Couple.hxx @@ -30,11 +30,13 @@ #ifndef _COUPLE_H_ #define _COUPLE_H_ +#include "Batch_Defines.hxx" + #include namespace Batch { - class Couple + class BATCH_EXPORT Couple { public: // Constructeur standard diff --git a/src/Batch/Batch_CoupleType.hxx b/src/Batch/Batch_CoupleType.hxx index 6d2500f1c..b7d323331 100644 --- a/src/Batch/Batch_CoupleType.hxx +++ b/src/Batch/Batch_CoupleType.hxx @@ -30,13 +30,15 @@ #ifndef _COUPLETYPE_H_ #define _COUPLETYPE_H_ +#include "Batch_Defines.hxx" + #include #include "Batch_GenericType.hxx" #include "Batch_Couple.hxx" namespace Batch { - class CoupleType : public GenericType + class BATCH_EXPORT CoupleType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_Date.hxx b/src/Batch/Batch_Date.hxx index 06ebd5dd1..ff7d37a6f 100644 --- a/src/Batch/Batch_Date.hxx +++ b/src/Batch/Batch_Date.hxx @@ -30,11 +30,13 @@ #ifndef _DATE_H_ #define _DATE_H_ +#include "Batch_Defines.hxx" + #include namespace Batch { - class Date + class BATCH_EXPORT Date { public: Date(const long l=0); diff --git a/src/Batch/Batch_DateType.hxx b/src/Batch/Batch_DateType.hxx index 40a47702e..c7fef39a5 100644 --- a/src/Batch/Batch_DateType.hxx +++ b/src/Batch/Batch_DateType.hxx @@ -30,13 +30,15 @@ #ifndef _DATETYPE_H_ #define _DATETYPE_H_ +#include "Batch_Defines.hxx" + #include #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 index 000000000..15c5f7c86 --- /dev/null +++ b/src/Batch/Batch_Defines.hxx @@ -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 diff --git a/src/Batch/Batch_Environnement.hxx b/src/Batch/Batch_Environnement.hxx index 2fb9c73a0..e1e16f654 100644 --- a/src/Batch/Batch_Environnement.hxx +++ b/src/Batch/Batch_Environnement.hxx @@ -30,6 +30,8 @@ #ifndef _ENVIRONNEMENT_H_ #define _ENVIRONNEMENT_H_ +#include "Batch_Defines.hxx" + #include #include diff --git a/src/Batch/Batch_FactBatchManager.cxx b/src/Batch/Batch_FactBatchManager.cxx index 61d18fbd0..27b7f1c1f 100644 --- a/src/Batch/Batch_FactBatchManager.cxx +++ b/src/Batch/Batch_FactBatchManager.cxx @@ -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 diff --git a/src/Batch/Batch_FactBatchManager.hxx b/src/Batch/Batch_FactBatchManager.hxx index 71d739ef0..3a229be30 100644 --- a/src/Batch/Batch_FactBatchManager.hxx +++ b/src/Batch/Batch_FactBatchManager.hxx @@ -29,6 +29,8 @@ #ifndef _FACTBATCHMANAGER_H_ #define _FACTBATCHMANAGER_H_ +#include "Batch_Defines.hxx" + #include #include @@ -36,7 +38,7 @@ namespace Batch { class BatchManager; - class FactBatchManager + class BATCH_EXPORT FactBatchManager { public: // Constructeur et destructeur diff --git a/src/Batch/Batch_FactBatchManager_LSF.hxx b/src/Batch/Batch_FactBatchManager_LSF.hxx index 718a068fc..239b8edfd 100644 --- a/src/Batch/Batch_FactBatchManager_LSF.hxx +++ b/src/Batch/Batch_FactBatchManager_LSF.hxx @@ -29,9 +29,6 @@ #ifndef _FACTBATCHMANAGER_LSF_H_ #define _FACTBATCHMANAGER_LSF_H_ -using namespace std; -#include -#include #include "Batch_FactBatchManager.hxx" namespace Batch { diff --git a/src/Batch/Batch_FactBatchManager_Local.hxx b/src/Batch/Batch_FactBatchManager_Local.hxx index 77b5d11b3..f9b0d20df 100644 --- a/src/Batch/Batch_FactBatchManager_Local.hxx +++ b/src/Batch/Batch_FactBatchManager_Local.hxx @@ -28,9 +28,6 @@ #ifndef _FACTBATCHMANAGER_LOCAL_H_ #define _FACTBATCHMANAGER_LOCAL_H_ -using namespace std; -#include -#include #include "Batch_FactBatchManager.hxx" namespace Batch { diff --git a/src/Batch/Batch_FactBatchManager_Local_RSH.cxx b/src/Batch/Batch_FactBatchManager_Local_RSH.cxx index 985146e58..456c09e45 100644 --- a/src/Batch/Batch_FactBatchManager_Local_RSH.cxx +++ b/src/Batch/Batch_FactBatchManager_Local_RSH.cxx @@ -31,8 +31,15 @@ //#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") diff --git a/src/Batch/Batch_FactBatchManager_Local_RSH.hxx b/src/Batch/Batch_FactBatchManager_Local_RSH.hxx index bf10abd14..1f68befd1 100644 --- a/src/Batch/Batch_FactBatchManager_Local_RSH.hxx +++ b/src/Batch/Batch_FactBatchManager_Local_RSH.hxx @@ -28,9 +28,6 @@ #ifndef _FACTBATCHMANAGER_LOCAL_RSH_H_ #define _FACTBATCHMANAGER_LOCAL_RSH_H_ -using namespace std; -#include -#include #include "Batch_FactBatchManager.hxx" namespace Batch { diff --git a/src/Batch/Batch_FactBatchManager_Local_SH.hxx b/src/Batch/Batch_FactBatchManager_Local_SH.hxx index 8ac703a74..29ff50d07 100644 --- a/src/Batch/Batch_FactBatchManager_Local_SH.hxx +++ b/src/Batch/Batch_FactBatchManager_Local_SH.hxx @@ -28,9 +28,6 @@ #ifndef _FACTBATCHMANAGER_LOCAL_SH_H_ #define _FACTBATCHMANAGER_LOCAL_SH_H_ -using namespace std; -#include -#include #include "Batch_FactBatchManager.hxx" namespace Batch { diff --git a/src/Batch/Batch_FactBatchManager_Local_SSH.hxx b/src/Batch/Batch_FactBatchManager_Local_SSH.hxx index 2c3c14e03..4d9764247 100644 --- a/src/Batch/Batch_FactBatchManager_Local_SSH.hxx +++ b/src/Batch/Batch_FactBatchManager_Local_SSH.hxx @@ -28,9 +28,6 @@ #ifndef _FACTBATCHMANAGER_LOCAL_SSH_H_ #define _FACTBATCHMANAGER_LOCAL_SSH_H_ -using namespace std; -#include -#include #include "Batch_FactBatchManager.hxx" namespace Batch { diff --git a/src/Batch/Batch_FactBatchManager_eLSF.cxx b/src/Batch/Batch_FactBatchManager_eLSF.cxx index 227bffa32..d77c4c71b 100644 --- a/src/Batch/Batch_FactBatchManager_eLSF.cxx +++ b/src/Batch/Batch_FactBatchManager_eLSF.cxx @@ -33,7 +33,15 @@ 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") diff --git a/src/Batch/Batch_FactBatchManager_eLSF.hxx b/src/Batch/Batch_FactBatchManager_eLSF.hxx index e1660aaaa..558ee007e 100644 --- a/src/Batch/Batch_FactBatchManager_eLSF.hxx +++ b/src/Batch/Batch_FactBatchManager_eLSF.hxx @@ -29,7 +29,8 @@ #ifndef _FACTBATCHMANAGER_eLSF_H_ #define _FACTBATCHMANAGER_eLSF_H_ -using namespace std; +#include "Batch_Defines.hxx" + #include #include #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 diff --git a/src/Batch/Batch_FactBatchManager_ePBS.cxx b/src/Batch/Batch_FactBatchManager_ePBS.cxx index 3bcbda530..3611a05ea 100644 --- a/src/Batch/Batch_FactBatchManager_ePBS.cxx +++ b/src/Batch/Batch_FactBatchManager_ePBS.cxx @@ -33,7 +33,14 @@ 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") diff --git a/src/Batch/Batch_FactBatchManager_ePBS.hxx b/src/Batch/Batch_FactBatchManager_ePBS.hxx index 69fdf322a..b78e76144 100644 --- a/src/Batch/Batch_FactBatchManager_ePBS.hxx +++ b/src/Batch/Batch_FactBatchManager_ePBS.hxx @@ -29,7 +29,8 @@ #ifndef _FACTBATCHMANAGER_ePBS_H_ #define _FACTBATCHMANAGER_ePBS_H_ -using namespace std; +#include "Batch_Defines.hxx" + #include #include #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 diff --git a/src/Batch/Batch_GenericException.hxx b/src/Batch/Batch_GenericException.hxx index f62b6a2b9..89f79f49a 100644 --- a/src/Batch/Batch_GenericException.hxx +++ b/src/Batch/Batch_GenericException.hxx @@ -30,12 +30,14 @@ #ifndef _GENERICEXCEPTION_H_ #define _GENERICEXCEPTION_H_ +#include "Batch_Defines.hxx" + #include namespace Batch { - class GenericException + class BATCH_EXPORT GenericException { public: const std::string type; // la nature de l'exception diff --git a/src/Batch/Batch_GenericType.hxx b/src/Batch/Batch_GenericType.hxx index 674b843ad..c5d7faf83 100644 --- a/src/Batch/Batch_GenericType.hxx +++ b/src/Batch/Batch_GenericType.hxx @@ -29,13 +29,15 @@ #ifndef _GENERICTYPE_H_ #define _GENERICTYPE_H_ +#include "Batch_Defines.hxx" + #include #include namespace Batch { - class GenericType + class BATCH_EXPORT GenericType { public: // Constructeur et destructeur diff --git a/src/Batch/Batch_IntType.hxx b/src/Batch/Batch_IntType.hxx index 82ca73a10..3808c9514 100644 --- a/src/Batch/Batch_IntType.hxx +++ b/src/Batch/Batch_IntType.hxx @@ -29,12 +29,14 @@ #ifndef _INTTYPE_H_ #define _INTTYPE_H_ +#include "Batch_Defines.hxx" + #include #include "Batch_GenericType.hxx" namespace Batch { - class IntType : public GenericType + class BATCH_EXPORT IntType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_InvalidArgumentException.hxx b/src/Batch/Batch_InvalidArgumentException.hxx index 68b417dda..8ca04c190 100644 --- a/src/Batch/Batch_InvalidArgumentException.hxx +++ b/src/Batch/Batch_InvalidArgumentException.hxx @@ -31,12 +31,14 @@ #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 diff --git a/src/Batch/Batch_InvalidKeyException.hxx b/src/Batch/Batch_InvalidKeyException.hxx index e07b876ee..7c9c7022a 100644 --- a/src/Batch/Batch_InvalidKeyException.hxx +++ b/src/Batch/Batch_InvalidKeyException.hxx @@ -30,13 +30,15 @@ #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 diff --git a/src/Batch/Batch_Job.hxx b/src/Batch/Batch_Job.hxx index d6ad5442b..fabecde27 100644 --- a/src/Batch/Batch_Job.hxx +++ b/src/Batch/Batch_Job.hxx @@ -29,13 +29,15 @@ #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 diff --git a/src/Batch/Batch_JobId.hxx b/src/Batch/Batch_JobId.hxx index 5046d6a31..9ae57d183 100644 --- a/src/Batch/Batch_JobId.hxx +++ b/src/Batch/Batch_JobId.hxx @@ -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; diff --git a/src/Batch/Batch_JobInfo.cxx b/src/Batch/Batch_JobInfo.cxx index 6e985fdb2..71fe3113b 100644 --- a/src/Batch/Batch_JobInfo.cxx +++ b/src/Batch/Batch_JobInfo.cxx @@ -33,6 +33,8 @@ //#include "MEDMEM_STRING.hxx" #include "Batch_JobInfo.hxx" +using namespace std; + namespace Batch { // Destructeur diff --git a/src/Batch/Batch_JobInfo.hxx b/src/Batch/Batch_JobInfo.hxx index fbb4e35b1..7ec3a5764 100644 --- a/src/Batch/Batch_JobInfo.hxx +++ b/src/Batch/Batch_JobInfo.hxx @@ -30,7 +30,8 @@ #ifndef _JOBINFO_H_ #define _JOBINFO_H_ -using namespace std; +#include "Batch_Defines.hxx" + #include #include #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 diff --git a/src/Batch/Batch_JobInfo_eLSF.cxx b/src/Batch/Batch_JobInfo_eLSF.cxx index 177f2eb06..5edeb0a5b 100644 --- a/src/Batch/Batch_JobInfo_eLSF.cxx +++ b/src/Batch/Batch_JobInfo_eLSF.cxx @@ -37,6 +37,8 @@ #include "Batch_APIInternalFailureException.hxx" #include "Batch_JobInfo_eLSF.hxx" +using namespace std; + namespace Batch { diff --git a/src/Batch/Batch_JobInfo_eLSF.hxx b/src/Batch/Batch_JobInfo_eLSF.hxx index 51d3f6fd3..52b7282cf 100644 --- a/src/Batch/Batch_JobInfo_eLSF.hxx +++ b/src/Batch/Batch_JobInfo_eLSF.hxx @@ -30,10 +30,11 @@ #ifndef _JOBINFO_LSF_H_ #define _JOBINFO_LSF_H_ -#include #include "Batch_RunTimeException.hxx" #include "Batch_JobInfo.hxx" +#include + 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 &); }; diff --git a/src/Batch/Batch_JobInfo_ePBS.cxx b/src/Batch/Batch_JobInfo_ePBS.cxx index 6d9807a0c..8a1c97506 100644 --- a/src/Batch/Batch_JobInfo_ePBS.cxx +++ b/src/Batch/Batch_JobInfo_ePBS.cxx @@ -37,6 +37,8 @@ #include "Batch_APIInternalFailureException.hxx" #include "Batch_JobInfo_ePBS.hxx" +using namespace std; + namespace Batch { diff --git a/src/Batch/Batch_JobInfo_ePBS.hxx b/src/Batch/Batch_JobInfo_ePBS.hxx index 79fb0b782..03a8601aa 100644 --- a/src/Batch/Batch_JobInfo_ePBS.hxx +++ b/src/Batch/Batch_JobInfo_ePBS.hxx @@ -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 &); }; diff --git a/src/Batch/Batch_Job_Local.cxx b/src/Batch/Batch_Job_Local.cxx index bc276f819..896532c96 100644 --- a/src/Batch/Batch_Job_Local.cxx +++ b/src/Batch/Batch_Job_Local.cxx @@ -28,9 +28,13 @@ #include #include +#ifndef WIN32 #include +#endif #include "Batch_Job_Local.hxx" +using namespace std; + namespace Batch { // Constructeur diff --git a/src/Batch/Batch_ListIsFullException.hxx b/src/Batch/Batch_ListIsFullException.hxx index 241defeb8..0525ba449 100644 --- a/src/Batch/Batch_ListIsFullException.hxx +++ b/src/Batch/Batch_ListIsFullException.hxx @@ -29,11 +29,13 @@ #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 diff --git a/src/Batch/Batch_LongType.hxx b/src/Batch/Batch_LongType.hxx index f43e8615e..3970ae0e7 100644 --- a/src/Batch/Batch_LongType.hxx +++ b/src/Batch/Batch_LongType.hxx @@ -29,12 +29,14 @@ #ifndef _LONGTYPE_H_ #define _LONGTYPE_H_ +#include "Batch_Defines.hxx" + #include #include "Batch_GenericType.hxx" namespace Batch { - class LongType : public GenericType + class BATCH_EXPORT LongType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_MapKey.hxx b/src/Batch/Batch_MapKey.hxx index 93f219842..43e943f8b 100644 --- a/src/Batch/Batch_MapKey.hxx +++ b/src/Batch/Batch_MapKey.hxx @@ -30,6 +30,8 @@ #ifndef _MAPKEY_H_ #define _MAPKEY_H_ +#include "Batch_Defines.hxx" + #include @@ -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 diff --git a/src/Batch/Batch_NotYetImplementedException.hxx b/src/Batch/Batch_NotYetImplementedException.hxx index 54f4f6205..509aceaca 100644 --- a/src/Batch/Batch_NotYetImplementedException.hxx +++ b/src/Batch/Batch_NotYetImplementedException.hxx @@ -30,17 +30,18 @@ #ifndef _NOTYETIMPLEMENTEDEXCEPTION_H_ #define _NOTYETIMPLEMENTEDEXCEPTION_H_ - +#include "Batch_Defines.hxx" #include "Batch_GenericException.hxx" -using namespace std; + +#include 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) {} }; } diff --git a/src/Batch/Batch_Parametre.cxx b/src/Batch/Batch_Parametre.cxx index b218cc443..1facc6287 100644 --- a/src/Batch/Batch_Parametre.cxx +++ b/src/Batch/Batch_Parametre.cxx @@ -26,11 +26,12 @@ * */ -#include #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 diff --git a/src/Batch/Batch_Parametre.hxx b/src/Batch/Batch_Parametre.hxx index ce88da4f9..e6feedf9c 100644 --- a/src/Batch/Batch_Parametre.hxx +++ b/src/Batch/Batch_Parametre.hxx @@ -29,25 +29,25 @@ #ifndef _PARAMETRE_H_ #define _PARAMETRE_H_ -using namespace std; +#include "Batch_Defines.hxx" + #include #include #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: diff --git a/src/Batch/Batch_PyVersatile.cxx b/src/Batch/Batch_PyVersatile.cxx index f38132ca2..10541cb18 100644 --- a/src/Batch/Batch_PyVersatile.cxx +++ b/src/Batch/Batch_PyVersatile.cxx @@ -34,6 +34,8 @@ #include "Batch_PyVersatile.hxx" #include +using namespace std; + namespace Batch { // Constructeur a partir d'un objet Versatile diff --git a/src/Batch/Batch_PyVersatile.hxx b/src/Batch/Batch_PyVersatile.hxx index e111bac43..3bc37f2c5 100644 --- a/src/Batch/Batch_PyVersatile.hxx +++ b/src/Batch/Batch_PyVersatile.hxx @@ -31,16 +31,17 @@ #define _PYVERSATILE_H_ +#include "Batch_Defines.hxx" + #include #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 diff --git a/src/Batch/Batch_RunTimeException.hxx b/src/Batch/Batch_RunTimeException.hxx index 3df53a5ca..fe1e168d4 100644 --- a/src/Batch/Batch_RunTimeException.hxx +++ b/src/Batch/Batch_RunTimeException.hxx @@ -30,12 +30,14 @@ #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 diff --git a/src/Batch/Batch_StringType.hxx b/src/Batch/Batch_StringType.hxx index a72173c7e..510924e9b 100644 --- a/src/Batch/Batch_StringType.hxx +++ b/src/Batch/Batch_StringType.hxx @@ -29,12 +29,14 @@ #ifndef _STRINGTYPE_H_ #define _STRINGTYPE_H_ +#include "Batch_Defines.hxx" + #include #include "Batch_GenericType.hxx" namespace Batch { - class StringType : public GenericType + class BATCH_EXPORT StringType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_TypeMismatchException.hxx b/src/Batch/Batch_TypeMismatchException.hxx index d235ec20e..b231060dc 100644 --- a/src/Batch/Batch_TypeMismatchException.hxx +++ b/src/Batch/Batch_TypeMismatchException.hxx @@ -29,12 +29,14 @@ #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 diff --git a/src/Batch/Batch_Versatile.hxx b/src/Batch/Batch_Versatile.hxx index cf97bbb30..c7b6f3bf6 100644 --- a/src/Batch/Batch_Versatile.hxx +++ b/src/Batch/Batch_Versatile.hxx @@ -29,6 +29,8 @@ #ifndef _VERSATILE_H_ #define _VERSATILE_H_ +#include "Batch_Defines.hxx" + #include #include #include @@ -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 diff --git a/src/Batch/Makefile.am b/src/Batch/Makefile.am index c6c2cbf86..aaaa33e2b 100644 --- a/src/Batch/Makefile.am +++ b/src/Batch/Makefile.am @@ -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 \ diff --git a/src/Batch/MpiImpl.hxx b/src/Batch/MpiImpl.hxx index 07f306bdf..1056c2581 100644 --- a/src/Batch/MpiImpl.hxx +++ b/src/Batch/MpiImpl.hxx @@ -29,9 +29,10 @@ #ifndef _BL_MPIIMPL_H_ #define _BL_MPIIMPL_H_ +#include "Batch_Defines.hxx" #include -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