Salome HOME
Removed CASCatch
[modules/kernel.git] / src / Batch / Batch_JobId.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 /*
21  * JobId.cxx : 
22  *
23  * Auteur : Ivan DUTKA-MALEN - EDF R&D
24  * Date   : Septembre 2003
25  * Projet : SALOME 2
26  *
27  */
28
29 #include "Batch_JobId.hxx"
30 #include "Batch_BatchManager.hxx"
31 #include <sstream>
32 #include <assert.h>
33 //#include "MEDMEM_STRING.hxx"
34 using namespace std;
35
36 namespace Batch {
37
38   // Constructeur standard
39   JobId::JobId() : _p_batchmanager(), _reference("undefined")
40   {
41     // Nothing to do
42   }
43
44   // Constructeur avec le pointeur sur le BatchManager associe et avec une reference
45   JobId::JobId(BatchManager * _p_bm, string ref) : _p_batchmanager(_p_bm), _reference(ref)
46   {
47     // Nothing to do
48   }
49
50   // Destructeur
51   JobId::~JobId()
52   {
53     // Nothing to do
54   }
55
56   // Operateur d'affectation entre objets
57   JobId & JobId::operator =(const JobId & jobid)
58   {
59     _p_batchmanager = jobid._p_batchmanager;
60     _reference      = jobid._reference;
61
62     return *this;
63   }
64
65   // Constructeur par recopie
66   JobId::JobId(const JobId & jobid) : _p_batchmanager(jobid._p_batchmanager), _reference(jobid._reference)
67   {
68     // Nothing to do
69   }
70
71   // Accesseur pour la reference interne
72   string JobId::getReference() const
73   {
74     return _reference;
75   }
76
77   // Methode pour le controle du job : retire le job du gestionnaire
78   void JobId::deleteJob() const
79   {
80     assert(_p_batchmanager != 0);
81     _p_batchmanager->deleteJob(*this);
82   }
83    
84   // Methode pour le controle du job : suspend le job en file d'attente
85   void JobId::holdJob() const
86   {
87     assert(_p_batchmanager != 0);
88     _p_batchmanager->holdJob(*this);
89   }
90
91   // Methode pour le controle du job : relache le job suspendu
92   void JobId::releaseJob() const
93   {
94     assert(_p_batchmanager != 0);
95     _p_batchmanager->releaseJob(*this);
96   }
97
98   // Methode pour le controle du job : modifie le job en file d'attente
99   void JobId::alterJob(const Parametre & param, const Environnement & env) const
100   {
101     assert(_p_batchmanager != 0);
102     _p_batchmanager->alterJob(*this, param, env);
103   }
104
105   // Methode pour le controle du job : modifie le job en file d'attente
106   void JobId::alterJob(const Parametre & param) const
107   {
108     assert(_p_batchmanager != 0);
109     _p_batchmanager->alterJob(*this, param);
110   }
111
112   // Methode pour le controle du job : modifie le job en file d'attente
113   void JobId::alterJob(const Environnement & env) const
114   {
115     assert(_p_batchmanager != 0);
116     _p_batchmanager->alterJob(*this, env);
117   }
118
119   // Methode pour le controle du job : renvoie l'etat du job
120   JobInfo JobId::queryJob() const
121   {
122     assert(_p_batchmanager != 0);
123     return _p_batchmanager->queryJob(*this);
124   }
125
126
127   // Methode pour l'interfacage avec Python (SWIG) : affichage en Python
128   string JobId::__str__() const {
129     //MEDMEM::STRING str;
130     ostringstream str;
131     str << "<JobId (" << this << ") : referenced '" << _reference << "'>";
132     return str.str();
133   }
134
135 }