Salome HOME
Merge from V6_3_BR 06/06/2011
[modules/kernel.git] / src / Launcher / Launcher.hxx
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef __LAUNCHER_HXX__
24 #define __LAUNCHER_HXX__
25
26 #include "Launcher_Utils.hxx"
27 #include "Launcher_Job.hxx"
28
29 #include "ResourcesManager.hxx"
30 #include <SALOME_ResourcesCatalog_Parser.hxx>
31
32 #include "SALOME_Launcher_Parser.hxx"
33
34 #include <string>
35 #include <vector>
36
37 #include <pthread.h>
38
39 class MpiImpl;
40
41 namespace Batch{
42   class BatchManager_eClient;
43   class Job;
44 }
45
46 struct batchParams{
47   std::string batch_directory;
48   std::string expected_during_time;
49   std::string mem;
50   unsigned long nb_proc;
51 };
52
53 class LAUNCHER_EXPORT Launcher_cpp
54 {
55
56 public:
57   Launcher_cpp();
58   ~Launcher_cpp();
59
60   // Main interface
61   void         createJob(Launcher::Job * new_job);
62   void         launchJob(int job_id);
63   const char * getJobState(int job_id);
64   void         getJobResults(int job_id, std::string directory);
65   bool         getJobDumpState(int job_id, std::string directory);
66   void         removeJob(int job_id);
67
68   // Useful methods
69   long createJobWithFile(std::string xmlExecuteFile, std::string clusterName);
70   std::map<int, Launcher::Job *> getJobs();
71   void checkFactoryForResource(const std::string & resource_name);
72   void addJobDirectlyToMap(Launcher::Job * new_job, const std::string job_reference);
73
74   // Lib methods
75   void SetResourcesManager( ResourcesManager_cpp* rm ) {_ResManager = rm;}
76
77   // Used by SALOME_Launcher
78   ResourcesManager_cpp *_ResManager;
79 protected:
80
81   virtual void notifyObservers(const std::string & event_name, const std::string & event_data) {}
82
83   // Methods used by user interface methods
84 #ifdef WITH_LIBBATCH
85   Batch::BatchManager_eClient *FactoryBatchManager(ParserResourcesType& params);
86   std::map <std::string,Batch::BatchManager_eClient*> _batchmap;
87 #endif
88   ParserLauncherType ParseXmlFile(std::string xmlExecuteFile);
89
90   std::map <int, Launcher::Job *> _launcher_job_map;  
91   int _job_cpt; // job number counter
92   pthread_mutex_t * _job_cpt_mutex; // mutex for job counter
93 };
94
95 #endif