1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 * Auteur : Ivan DUTKA-MALEN - EDF R&D
26 * Date : Septembre 2003
35 #include "Batch_Parametre.hxx"
36 #include "Batch_PyVersatile.hxx"
37 #include "Batch_JobId.hxx"
38 #include "Batch_FactBatchManager.hxx"
39 #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
40 typedef int Py_ssize_t;
41 #define PY_SSIZE_T_MAX INT_MAX
42 #define PY_SSIZE_T_MIN INT_MIN
46 # // supprime toutes les definitions par defaut => sert au debug
47 # %typemap(in) SWIGTYPE ;
50 # // construction d'un dictionnaire Python a partir d'un objet BatchManagerCatalog C++
51 %typemap(out) std::map<std::string, Batch::FactBatchManager *> *
53 $result = PyDict_New();
55 // on itere sur toutes les clefs de la map
56 for(std::map<std::string, Batch::FactBatchManager *>::const_iterator it=(* $1).begin(); it!=(* $1).end(); it++) {
57 std::string key = (*it).first;
58 PyObject * obj = SWIG_NewPointerObj((void *) (*it).second, SWIGTYPE_p_Batch__FactBatchManager, 0);
59 PyDict_SetItem($result, PyString_FromString(key.c_str()), obj);
63 %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) Batch::Parametre
65 $1 = PyDict_Check($input)? 1 : 0;
68 # // construction d'un dictionnaire Python a partir d'un objet Parametre C++
69 %typemap(out) Batch::Parametre
71 $result = PyDict_New();
73 // on itere sur toutes les clefs de la map, et on passe par la classe PyVersatile
74 // qui convertit un Versatile en PyObject et vice versa
75 for(Batch::Parametre::const_iterator it=$1.begin(); it!=$1.end(); it++) {
76 std::string key = (*it).first;
77 Batch::PyVersatile PyV = (*it).second;
78 PyDict_SetItem($result, PyString_FromString(key.c_str()), PyV);
83 # // construction d'un objet Parametre C++ a partir d'un dictionnaire Python
84 %typemap(in) Batch::Parametre & (Batch::Parametre PM)
86 if (!PyDict_Check($input)) {
87 PyErr_SetString(PyExc_ValueError,"Expected a dictionnary");
92 // on itere sur toutes les clefs du dictionnaire, et on passe par la classe PyVersatile
93 // qui convertit un Versatile en PyObject et vice versa
94 PyObject *key, *value;
96 while (PyDict_Next($input, &pos, &key, &value)) {
97 std::string mk = PyString_AsString(key);
98 Batch::PyVersatile PyV = value;
103 $1 = &PM; // $1 est une reference donc on lui passe une adresse
105 catch (Batch::GenericException & ex) {
106 std::string msg = ex.type + " : " + ex.message;
107 PyErr_SetString(PyExc_RuntimeWarning, msg.c_str());
111 PyErr_SetString(PyExc_RuntimeWarning, "unknown exception");
117 # // construction d'un objet Parametre C++ a partir d'un dictionnaire Python
118 %typemap(in) Batch::Parametre (Batch::Parametre PM)
120 if (!PyDict_Check($input)) {
121 PyErr_SetString(PyExc_ValueError,"Expected a dictionnary");
126 // on itere sur toutes les clefs du dictionnaire, et on passe par la classe PyVersatile
127 // qui convertit un Versatile en PyObject et vice versa
128 PyObject *key, *value;
130 while (PyDict_Next($input, &pos, &key, &value)) {
131 std::string mk = PyString_AsString(key);
132 Batch::PyVersatile PyV = value;
139 catch (Batch::GenericException & ex) {
140 std::string msg = ex.type + " : " + ex.message;
141 PyErr_SetString(PyExc_RuntimeWarning, msg.c_str());
145 PyErr_SetString(PyExc_RuntimeWarning, "unknown exception");
150 %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) Batch::Environnement
152 $1 = PyDict_Check($input)? 1 : 0;
155 # // construction d'un dictionnaire Python a partir d'un objet Environnement C++
156 %typemap(out) Batch::Environnement
158 $result = PyDict_New();
160 // on itere sur toutes les clefs de la map
161 for(Batch::Environnement::const_iterator it=$1.begin(); it!=$1.end(); it++) {
162 std::string key = (*it).first;
163 std::string val = (*it).second;
164 PyDict_SetItem($result,
165 PyString_FromString(key.c_str()),
166 PyString_FromString(val.c_str()));
171 # // construction d'un objet Environnement C++ a partir d'un dictionnaire Python
172 %typemap(in) Batch::Environnement & (Batch::Environnement E)
174 if (!PyDict_Check($input)) {
175 PyErr_SetString(PyExc_ValueError,"Expected a dictionnary");
179 // on itere sur toutes les clefs du dictionnaire
180 PyObject *key, *value;
182 while (PyDict_Next($input, &pos, &key, &value)) {
183 std::string mk = PyString_AsString(key);
184 std::string val = PyString_AsString(value);
188 $1 = &E; // $1 est une reference donc on lui passe une adresse
193 # // construction d'un objet Environnement C++ a partir d'un dictionnaire Python
194 %typemap(in) Batch::Environnement (Batch::Environnement E)
196 if (!PyDict_Check($input)) {
197 PyErr_SetString(PyExc_ValueError,"Expected a dictionnary");
201 // on itere sur toutes les clefs du dictionnaire
202 PyObject *key, *value;
204 while (PyDict_Next($input, &pos, &key, &value)) {
205 std::string mk = PyString_AsString(key);
206 std::string val = PyString_AsString(value);
213 // Dynamic cast to FactBatchManager_eClient if necessary
214 %typemap(out) Batch::FactBatchManager *
216 if(dynamic_cast<Batch::FactBatchManager_eClient *>($1))
217 $result=SWIG_NewPointerObj((void*)$1,$descriptor(Batch::FactBatchManager_eClient *),$owner);
219 $result=SWIG_NewPointerObj((void*)$1,$descriptor(Batch::FactBatchManager *),$owner);