Salome HOME
Copyright update 2021
[tools/libbatch.git] / src / Core / JobId.cxx
1 // Copyright (C) 2007-2021  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, or (at your option) any later version.
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  * JobId.cxx : 
24  *
25  * Auteur : Ivan DUTKA-MALEN - EDF R&D
26  * Date   : Septembre 2003
27  * Projet : SALOME 2
28  *
29  */
30
31 #include "JobId.hxx"
32 #include "BatchManager.hxx"
33 #include <sstream>
34 #include <assert.h>
35 //#include "MEDMEM_STRING.hxx"
36 using namespace std;
37
38 namespace Batch {
39
40   // Constructeur standard
41   JobId::JobId() : _p_batchmanager(), _reference("undefined")
42   {
43     // Nothing to do
44   }
45
46   // Constructeur avec le pointeur sur le BatchManager associe et avec une reference
47   JobId::JobId(BatchManager * _p_bm, const string & ref) : _p_batchmanager(_p_bm), _reference(ref)
48   {
49     // Nothing to do
50   }
51
52   // Destructeur
53   JobId::~JobId()
54   {
55     // Nothing to do
56   }
57
58   // Operateur d'affectation entre objets
59   JobId & JobId::operator =(const JobId & jobid)
60   {
61     _p_batchmanager = jobid._p_batchmanager;
62     _reference      = jobid._reference;
63
64     return *this;
65   }
66
67   // Constructeur par recopie
68   JobId::JobId(const JobId & jobid) : _p_batchmanager(jobid._p_batchmanager), _reference(jobid._reference)
69   {
70     // Nothing to do
71   }
72
73   // Accesseur pour la reference interne
74   string JobId::getReference() const
75   {
76     return _reference;
77   }
78
79   // Permet de recharger un job depuis un fichier
80   void JobId::setReference(const std::string & new_reference)
81   {
82     _reference = new_reference;
83   }
84
85   // Methode pour le controle du job : retire le job du gestionnaire
86   void JobId::deleteJob() const
87   {
88     assert(_p_batchmanager != 0);
89     _p_batchmanager->deleteJob(*this);
90   }
91    
92   // Methode pour le controle du job : suspend le job en file d'attente
93   void JobId::holdJob() const
94   {
95     assert(_p_batchmanager != 0);
96     _p_batchmanager->holdJob(*this);
97   }
98
99   // Methode pour le controle du job : relache le job suspendu
100   void JobId::releaseJob() const
101   {
102     assert(_p_batchmanager != 0);
103     _p_batchmanager->releaseJob(*this);
104   }
105
106   // Methode pour le controle du job : modifie le job en file d'attente
107   void JobId::alterJob(const Parametre & param, const Environnement & env) const
108   {
109     assert(_p_batchmanager != 0);
110     _p_batchmanager->alterJob(*this, param, env);
111   }
112
113   // Methode pour le controle du job : modifie le job en file d'attente
114   void JobId::alterJob(const Parametre & param) const
115   {
116     assert(_p_batchmanager != 0);
117     _p_batchmanager->alterJob(*this, param);
118   }
119
120   // Methode pour le controle du job : modifie le job en file d'attente
121   void JobId::alterJob(const Environnement & env) const
122   {
123     assert(_p_batchmanager != 0);
124     _p_batchmanager->alterJob(*this, env);
125   }
126
127   // Methode pour le controle du job : renvoie l'etat du job
128   JobInfo JobId::queryJob() const
129   {
130     assert(_p_batchmanager != 0);
131     return _p_batchmanager->queryJob(*this);
132   }
133
134
135   // Methode pour l'interfacage avec Python (SWIG) : affichage en Python
136   string JobId::__str__() const {
137     //MEDMEM::STRING str;
138     ostringstream str;
139     str << "<JobId (" << this << ") : referenced '" << _reference << "'>";
140     return str.str();
141   }
142
143 }