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/
22 %module libSALOME_LifeCycleCORBA
25 #include "utilities.h"
26 #include "SALOME_LifeCycleCORBA.hxx"
31 %typemap(python,out) Engines::Container_ptr, Engines::Component_ptr
33 //MESSAGE("typemap out on CORBA object ptr");
36 // --- Get the Python orb
38 PyObject* pdict = PyDict_New();
39 PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
40 PyRun_String("from omniORB import CORBA", Py_single_input, pdict, pdict);
41 PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
43 PyObject* orb = PyDict_GetItemString(pdict, "o");
45 // --- Get the C++ orb
50 CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
51 string s = ORB->object_to_string($1);
53 PyObject * tmp = PyString_FromString(s.c_str());
55 $result = PyObject_CallMethod(orb, "string_to_object", "O", tmp);
60 %typemap(typecheck) const Engines::MachineParameters &
65 %typemap(python,in) const Engines::MachineParameters &
67 printf("typemap in on Engines::MachineParameters\n");
68 //MESSAGE("typemap in on Engines::MachineParameters");
69 //ASSERT (PyDict_Check($input))
70 if (PyDict_Check($input) == 1)
72 Engines::MachineParameters *param = new Engines::MachineParameters ;
73 param->container_name = CORBA::string_dup("");
74 param->hostname = CORBA::string_dup("");
75 param->OS = CORBA::string_dup("");
78 param->nb_proc_per_node = 0;
81 PyObject *key, *value;
83 while (PyDict_Next($input, &pos, &key, &value))
85 char* keystr = PyString_AsString(key);
86 printf("key: %s\n", keystr);
87 if (strcmp(keystr,"container_name")==0)
89 param->container_name = CORBA::string_dup(PyString_AsString(value));
91 else if (strcmp(keystr,"hostname")==0)
93 param->hostname = CORBA::string_dup(PyString_AsString(value));
95 else if (strcmp(keystr,"OS")==0)
97 param->OS = CORBA::string_dup(PyString_AsString(value));
99 else if (strcmp(keystr,"mem_mb")==0)
101 param->mem_mb = PyLong_AsLong(value);
103 else if (strcmp(keystr,"cpu_clock")==0)
105 param->cpu_clock = PyLong_AsLong(value);
107 else if (strcmp(keystr,"nb_proc_per_node")==0)
109 param->nb_proc_per_node = PyLong_AsLong(value);
111 else if (strcmp(keystr,"nb_node")==0)
113 param->nb_node = PyLong_AsLong(value);
115 else if (strcmp(keystr,"isMPI")==0)
117 param->isMPI = PyLong_AsLong(value);
124 printf("pas un dico\n");
129 %typemap(python,freearg) const Engines::MachineParameters &
131 MESSAGE("delete $1");
135 %include "SALOME_LifeCycleCORBA.hxx"