1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 * Auteur : Ivan DUTKA-MALEN - EDF R&D
24 * Date : Septembre 2003
33 #include "Batch_Parametre.hxx"
34 #include "Batch_PyVersatile.hxx"
35 #include "Batch_JobId.hxx"
36 #include "Batch_FactBatchManager.hxx"
39 # // supprime toutes les definitions par defaut => sert au debug
40 # %typemap(in) SWIGTYPE ;
43 # // construction d'un dictionnaire Python a partir d'un objet BatchManagerCatalog C++
44 %typemap(out) std::map<std::string, Batch::FactBatchManager *> *
46 $result = PyDict_New();
48 // on itere sur toutes les clefs de la map
49 for(std::map<std::string, Batch::FactBatchManager *>::const_iterator it=(* $1).begin(); it!=(* $1).end(); it++) {
50 std::string key = (*it).first;
51 PyObject * obj = SWIG_NewPointerObj((void *) (*it).second, SWIGTYPE_p_Batch__FactBatchManager, 0);
52 PyDict_SetItem($result, PyString_FromString(key.c_str()), obj);
57 # // construction d'un dictionnaire Python a partir d'un objet Parametre C++
58 %typemap(out) Batch::Parametre
60 $result = PyDict_New();
62 // on itere sur toutes les clefs de la map, et on passe par la classe PyVersatile
63 // qui convertit un Versatile en PyObject et vice versa
64 for(Batch::Parametre::const_iterator it=$1.begin(); it!=$1.end(); it++) {
65 std::string key = (*it).first;
66 Batch::PyVersatile PyV = (*it).second;
67 PyDict_SetItem($result, PyString_FromString(key.c_str()), PyV);
72 # // construction d'un objet Parametre C++ a partir d'un dictionnaire Python
73 %typemap(in) Batch::Parametre & (Batch::Parametre PM)
75 if (!PyDict_Check($input)) {
76 PyErr_SetString(PyExc_ValueError,"Expected a dictionnary");
81 // on itere sur toutes les clefs du dictionnaire, et on passe par la classe PyVersatile
82 // qui convertit un Versatile en PyObject et vice versa
83 PyObject *key, *value;
85 while (PyDict_Next($input, &pos, &key, &value)) {
86 std::string mk = PyString_AsString(key);
87 Batch::PyVersatile PyV = value;
92 $1 = &PM; // $1 est une reference donc on lui passe une adresse
94 catch (Batch::GenericException & ex) {
95 std::string msg = ex.type + " : " + ex.message;
96 PyErr_SetString(PyExc_RuntimeWarning, msg.c_str());
100 PyErr_SetString(PyExc_RuntimeWarning, "unknown exception");
106 # // construction d'un objet Parametre C++ a partir d'un dictionnaire Python
107 %typemap(in) Batch::Parametre (Batch::Parametre PM)
109 if (!PyDict_Check($input)) {
110 PyErr_SetString(PyExc_ValueError,"Expected a dictionnary");
115 // on itere sur toutes les clefs du dictionnaire, et on passe par la classe PyVersatile
116 // qui convertit un Versatile en PyObject et vice versa
117 PyObject *key, *value;
119 while (PyDict_Next($input, &pos, &key, &value)) {
120 std::string mk = PyString_AsString(key);
121 Batch::PyVersatile PyV = value;
128 catch (Batch::GenericException & ex) {
129 std::string msg = ex.type + " : " + ex.message;
130 PyErr_SetString(PyExc_RuntimeWarning, msg.c_str());
134 PyErr_SetString(PyExc_RuntimeWarning, "unknown exception");
140 # // construction d'un dictionnaire Python a partir d'un objet Environnement C++
141 %typemap(out) Batch::Environnement
143 $result = PyDict_New();
145 // on itere sur toutes les clefs de la map
146 for(Batch::Environnement::const_iterator it=$1.begin(); it!=$1.end(); it++) {
147 std::string key = (*it).first;
148 std::string val = (*it).second;
149 PyDict_SetItem($result,
150 PyString_FromString(key.c_str()),
151 PyString_FromString(val.c_str()));
156 # // construction d'un objet Environnement C++ a partir d'un dictionnaire Python
157 %typemap(in) Batch::Environnement & (Batch::Environnement E)
159 if (!PyDict_Check($input)) {
160 PyErr_SetString(PyExc_ValueError,"Expected a dictionnary");
164 // on itere sur toutes les clefs du dictionnaire
165 PyObject *key, *value;
167 while (PyDict_Next($input, &pos, &key, &value)) {
168 std::string mk = PyString_AsString(key);
169 std::string val = PyString_AsString(value);
173 $1 = &E; // $1 est une reference donc on lui passe une adresse
178 # // construction d'un objet Environnement C++ a partir d'un dictionnaire Python
179 %typemap(in) Batch::Environnement (Batch::Environnement E)
181 if (!PyDict_Check($input)) {
182 PyErr_SetString(PyExc_ValueError,"Expected a dictionnary");
186 // on itere sur toutes les clefs du dictionnaire
187 PyObject *key, *value;
189 while (PyDict_Next($input, &pos, &key, &value)) {
190 std::string mk = PyString_AsString(key);
191 std::string val = PyString_AsString(value);
200 # // construction d'une string Python a partir d'une string STL
201 %typemap(python,out) std::string
203 $result = PyString_FromString($1.c_str());
208 # // construction d'une string STL a partir d'une string Python
209 #%typemap(in) string & (string S)
211 ## if (!PyString_Check($input)) {
212 # PyErr_SetString(PyExc_ValueError,"Expected a string");
216 # S = string(PyString_AsString($input));
217 # $1 = &S; // $1 est une reference donc on lui passe une adresse
222 # // construction d'une string STL a partir d'une string Python
223 #%typemap(in) string (string S)
225 ## if (!PyString_Check($input)) {
226 # PyErr_SetString(PyExc_ValueError,"Expected a string");
230 # S = string(PyString_AsString($input));