Salome HOME
Moved test configuration from CMake variables to a configuration file
[tools/libbatch.git] / src / Core / Batch_BatchManager.cxx
1 //  Copyright (C) 2007-2008  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  * BatchManager.cxx :
24  *
25  * Auteur : Ivan DUTKA-MALEN - EDF R&D
26  * Date   : Septembre 2003
27  * Projet : SALOME 2
28  *
29  */
30
31 #include <iostream>
32 #include <sstream>
33 #include <string>
34 #ifdef WIN32
35 # include<winsock2.h>
36 #else
37 # include <netdb.h>
38 #endif
39
40 //#include "MEDMEM_STRING.hxx"
41 #include "Batch_Job.hxx"
42 #include "Batch_JobId.hxx"
43 #include "Batch_JobInfo.hxx"
44 #include "Batch_InvalidArgumentException.hxx"
45 #include "Batch_FactBatchManager.hxx"
46 #include "Batch_BatchManager.hxx"
47 using namespace std;
48
49 namespace Batch {
50
51   // Constructeur
52 //   BatchManager::BatchManager(string host) throw(InvalidArgumentException) : _hostname(host), jobid_map()
53 //   {
54 //     // On verifie que le hostname est correct
55 //     if (!gethostbyname(_hostname.c_str())) { // hostname unknown from network
56 //       string msg = "hostname \"";
57 //       msg += _hostname;
58 //       msg += "\" unknown from the network";
59 //       throw InvalidArgumentException(msg.c_str());
60 //     }
61 //   }
62   BatchManager::BatchManager(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException) : _hostname(host), jobid_map(), _parent(parent)
63   {
64 #ifdef WIN32
65     WSADATA wsaData;
66     WSAStartup(MAKEWORD(2, 2), &wsaData);  // Initialize Winsock
67 #endif
68
69     // On verifie que le hostname est correct
70     struct hostent* res = gethostbyname(_hostname.c_str());
71
72 #ifdef WIN32
73     WSACleanup();  // Finalize Winsock
74 #endif
75
76     if (!res) { // hostname unknown from network
77       string msg = "hostname \"";
78       msg += _hostname;
79       msg += "\" unknown from the network";
80       throw InvalidArgumentException(msg.c_str());
81     }
82   }
83
84   // Destructeur
85   BatchManager::~BatchManager()
86   {
87     // Nothing to do
88   }
89
90   string BatchManager::__repr__() const
91   {
92     ostringstream oss;
93     oss << "<BatchManager of type '" << (_parent ? _parent->getType() : "unknown (no factory)") << "' connected to server '" << _hostname << "'>";
94     return oss.str();
95   }
96
97   // Recupere le l'identifiant d'un job deja soumis au BatchManager
98 //   const JobId BatchManager::getJobIdByReference(const string & ref)
99 //   {
100 //     return JobId(this, ref);
101 //   }
102   const JobId BatchManager::getJobIdByReference(const char * ref)
103   {
104     return JobId(this, ref);
105   }
106
107 //   // Methode pour le controle des jobs : soumet un job au gestionnaire
108 //   const JobId BatchManager::submitJob(const Job & job)
109 //   {
110 //     static int idx = 0;
111 //     //MEDMEM::STRING sst;
112 //     ostringstream sst;
113 //     sst << "Jobid_" << idx++;
114 //     JobId id(this, sst.str());
115 //     return id;
116 //   }
117
118 //   // Methode pour le controle des jobs : retire un job du gestionnaire
119 //   void BatchManager::deleteJob(const JobId & jobid)
120 //   {
121 //     // Nothing to do
122 //   }
123
124 //   // Methode pour le controle des jobs : suspend un job en file d'attente
125 //   void BatchManager::holdJob(const JobId & jobid)
126 //   {
127 //     // Nothing to do
128 //   }
129
130 //   // Methode pour le controle des jobs : relache un job suspendu
131 //   void BatchManager::releaseJob(const JobId & jobid)
132 //   {
133 //     // Nothing to do
134 //   }
135
136 //   // Methode pour le controle des jobs : modifie un job en file d'attente
137 //   void BatchManager::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env)
138 //   {
139 //     // Nothing to do
140 //   }
141
142 //   // Methode pour le controle des jobs : modifie un job en file d'attente
143 //   void BatchManager::alterJob(const JobId & jobid, const Parametre & param)
144 //   {
145 //     // Nothing to do
146 //   }
147
148 //   // Methode pour le controle des jobs : modifie un job en file d'attente
149 //   void BatchManager::alterJob(const JobId & jobid, const Environnement & env)
150 //   {
151 //     // Nothing to do
152 //   }
153
154 //   // Methode pour le controle des jobs : renvoie l'etat du job
155 //   JobInfo BatchManager::queryJob(const JobId & jobid)
156 //   {
157 //     return JobInfo();
158 //   }
159
160 }