1 // Copyright (C) 2006-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // ----------------------------------------------------------------------------
22 %define SALOMEDOCSTRING
23 "Implementation of nodes for SALOME platform."
26 %module(directors="1",docstring=SALOMEDOCSTRING) SALOMERuntime
28 //work around SWIG bug #1863647
29 #if SWIG_VERSION >= 0x010336
30 #define SwigPyIterator SALOMERuntime_PySwigIterator
32 #define PySwigIterator SALOMERuntime_PySwigIterator
35 %feature("autodoc", "1");
37 %include engtypemaps.i
43 // ----------------------------------------------------------------------------
46 #include "SalomeContainer.hxx"
47 #include "SalomeHPContainer.hxx"
48 #include "RuntimeSALOME.hxx"
49 #include "SALOMEDispatcher.hxx"
50 #include "SalomeProc.hxx"
51 #include "PythonNode.hxx"
52 #include "PythonPorts.hxx"
53 #include "PresetNode.hxx"
54 #include "PresetPorts.hxx"
55 #include "CORBANode.hxx"
56 #include "CORBAPorts.hxx"
57 #include "StudyNodes.hxx"
58 #include "StudyPorts.hxx"
59 #include "TypeConversions.hxx"
60 #include "TypeCode.hxx"
61 #include "VisitorSaveSalomeSchema.hxx"
62 #include "SalomeOptimizerLoop.hxx"
63 #include "DistributedPythonNode.hxx"
64 #include "PyOptimizerAlg.hxx"
65 #include "PyStdout.hxx"
69 // ----------------------------------------------------------------------------
75 PyObject* omnipy = PyImport_ImportModule((char*)"_omnipy");
78 PyErr_SetString(PyExc_ImportError,(char*)"Cannot import _omnipy");
81 PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
82 api = (omniORBPYAPI*)PyCObject_AsVoidPtr(pyapi);
86 // ----------------------------------------------------------------------------
89 %typemap(out) YACS_ORB::Observer_ptr
91 $result = api->cxxObjRefToPyObjRef($1, 1);
94 %typemap(in) YACS_ORB::Observer_ptr
98 CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1);
99 $1 = YACS_ORB::Observer::_narrow(obj);
103 PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr");
108 %typemap(out) YACS::ENGINE::PyObj * "Py_INCREF($1); $result = $1;";
112 // ----------------------------------------------------------------------------
116 %rename(getSALOMERuntime) YACS::ENGINE::getSALOMERuntime; // to suppress a 503 warning
117 %ignore omniORBpyAPI;
119 %include <YACSRuntimeSALOMEExport.hxx>
120 %include "SalomeContainer.hxx"
121 %include "SalomeHPContainer.hxx"
122 %include "RuntimeSALOME.hxx"
123 %include "SALOMEDispatcher.hxx"
124 %include "SalomeProc.hxx"
125 %include "PythonNode.hxx"
126 %include "PythonPorts.hxx"
127 %include "XMLPorts.hxx"
128 %include "PresetNode.hxx"
129 %include "PresetPorts.hxx"
130 %include "CORBANode.hxx"
131 %include "CORBAPorts.hxx"
132 %include "StudyNodes.hxx"
133 %include "StudyPorts.hxx"
134 %include "SalomeOptimizerLoop.hxx"
135 %include "DistributedPythonNode.hxx"
137 %extend YACS::ENGINE::OutputPresetPort
139 void setDataPy(PyObject *ob)
141 std::string sss = convertPyObjectXml(self->edGetType(),ob);
147 // Define the methods that can (default) or cannot (nodirector) be overloaded in Python
148 %feature("director") YACS::ENGINE::PyOptimizerAlgBase;
149 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgBase::getTCForInProxy;
150 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgBase::getTCForOutProxy;
151 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgBase::initializeProxy;
152 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgBase::startProxy;
153 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgBase::takeDecisionProxy;
154 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgBase::finishProxy;
155 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgBase::hasError;
156 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgBase::getError;
157 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgBase::setError;
158 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgBase::getTCForAlgoInitProxy;
159 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgBase::getTCForAlgoResultProxy;
160 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgBase::getAlgoResultProxy;
161 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgBase::setProc;
163 %feature("director") YACS::ENGINE::PyOptimizerAlgASync;
164 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::getTCForInProxy;
165 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::getTCForOutProxy;
166 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::initializeProxy;
167 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::startProxy;
168 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::takeDecisionProxy;
169 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::finishProxy;
170 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::hasError;
171 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::getError;
172 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::setError;
173 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::signalMasterAndWait;
174 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::signalSlaveAndWait;
175 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::start;
176 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::takeDecision;
177 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::run;
178 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::getTCForAlgoInitProxy;
179 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::getTCForAlgoResultProxy;
180 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::getAlgoResultProxy;
181 %feature("nodirector") YACS::ENGINE::PyOptimizerAlgASync::setProc;
183 %feature("director:except") {
184 if ($error != NULL) {
185 std::string errorMessage;
186 PyObject* new_stderr = YACS::ENGINE::newPyStdOut(errorMessage);
187 PySys_SetObject((char*)"stderr", new_stderr);
189 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
190 Py_DECREF(new_stderr);
191 throw YACS::Exception(errorMessage);
195 // Warning: as PyOptimizerAlgSync is only a typedef in PyOptimizerAlg.hxx, we have to
196 // directly rename PyOptimizerAlgBase in OptimizerAlgSync. If someday PyOptimizerAlgSync
197 // becomes a real derived class, this will have to be changed.
198 %rename(OptimizerAlgSync) YACS::ENGINE::PyOptimizerAlgBase;
199 %rename(OptimizerAlgASync) YACS::ENGINE::PyOptimizerAlgASync;
200 %include "PyOptimizerAlg.hxx"