1 // Copyright (C) 2006-2016 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
21 "All is needed to create and execute a calculation schema."
24 %module(docstring=DOCSTRING) pilot
27 //work around SWIG bug #1863647
28 #if SWIG_VERSION >= 0x010336
29 #define SwigPyIterator pilot_PySwigIterator
31 #define PySwigIterator pilot_PySwigIterator
35 %feature("autodoc", "1");
37 %include "engtypemaps.i"
45 #include "TypeCode.hxx"
46 #include "ComponentDefinition.hxx"
47 #include "Visitor.hxx"
48 #include "VisitorSaveSchema.hxx"
49 #include "VisitorSaveState.hxx"
50 #include "LinkInfo.hxx"
51 #include "Catalog.hxx"
52 #include "Executor.hxx"
53 #include "ExecutorSwig.hxx"
54 #include "Dispatcher.hxx"
55 #include "Container.hxx"
56 #include "HomogeneousPoolContainer.hxx"
58 #include "DeploymentTree.hxx"
59 #include "ComponentInstance.hxx"
60 #include "DataNode.hxx"
62 using namespace YACS::ENGINE;
70 PyObject* omnipy = PyImport_ImportModule((char*)"_omnipy");
73 PyErr_SetString(PyExc_ImportError,(char*)"Cannot import _omnipy");
76 PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
77 api = (omniORBpyAPI*)PyCapsule_GetPointer(pyapi,"_omnipy.API");
82 %ignore YACS::ENGINE::Any::operator[];
83 %ignore YACS::ENGINE::TypeCode::operator=;
84 %ignore YACS::ENGINE::DeploymentTree::operator=;
86 %ignore YACS::ENGINE::Runtime::_tc_double;
87 %ignore YACS::ENGINE::Runtime::_tc_int;
88 %ignore YACS::ENGINE::Runtime::_tc_bool;
89 %ignore YACS::ENGINE::Runtime::_tc_string;
90 %ignore YACS::ENGINE::Runtime::_tc_file;
91 %rename(StateLoader) YACS::ENGINE::StateLoader; // to suppress a 503 warning
92 %rename(NbDoneLoader) YACS::ENGINE::NbDoneLoader; // to suppress a 503 warning
93 %rename(getRuntime) YACS::ENGINE::getRuntime; // to suppress a 503 warning
94 %rename(_from) YACS::ENGINE::DataLinkInfo::from ; // to suppress a 314 warning
95 %rename(_from) YACS::ENGINE::StreamLinkInfo::from ; // to suppress a 314 warning
100 %template() std::pair<std::string, YACS::ENGINE::TypeCode *>;
101 %template() std::pair<std::string, YACS::ENGINE::Node *>;
102 %template() std::pair<std::string, YACS::ENGINE::InlineNode *>;
103 %template() std::pair<std::string, YACS::ENGINE::ServiceNode *>;
104 %template() std::pair<std::string, YACS::ENGINE::Container *>;
105 %template() std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *>;
106 %template() std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *>;
107 //%template(TCmap) std::map<std::string, YACS::ENGINE::TypeCode *>;
108 REFCOUNT_TEMPLATE(TCmap,YACS::ENGINE::TypeCode)
109 %template(NODEmap) std::map<std::string, YACS::ENGINE::Node *>;
110 %template(INODEmap) std::map<std::string, YACS::ENGINE::InlineNode *>;
111 %template(SNODEmap) std::map<std::string, YACS::ENGINE::ServiceNode *>;
112 //%template(CONTAINmap) std::map<std::string, YACS::ENGINE::Container *>;
113 REFCOUNT_TEMPLATE(CONTAINmap,YACS::ENGINE::Container)
114 %template(strvec) std::vector<std::string>;
115 %template(uivec) std::vector<unsigned int>;
116 %template(linksvec) std::vector< std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *> >;
117 %template(linkvec) std::vector< std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *> >;
118 %template(instreamlist) std::list<YACS::ENGINE::InputDataStreamPort *>;
119 %template(outstreamlist) std::list<YACS::ENGINE::OutputDataStreamPort *>;
121 %template() std::pair<std::string, YACS::ENGINE::CatalogLoader *>;
122 %template(loadermap) std::map<std::string,YACS::ENGINE::CatalogLoader *>;
123 %template() std::pair<std::string, YACS::ENGINE::ComposedNode *>;
124 %template(composedmap) std::map<std::string,YACS::ENGINE::ComposedNode *>;
125 %template() std::pair<std::string, YACS::ENGINE::ComponentDefinition *>;
126 %template(compomap) std::map<std::string, YACS::ENGINE::ComponentDefinition *>;
127 %template() std::pair<std::string, std::string>;
128 %template(propmap) std::map<std::string, std::string>;
130 REFCOUNT_TEMPLATE(CompoInstmap,YACS::ENGINE::ComponentInstance)
133 * End of Template section
136 %typemap(out) Container *
138 $result=convertContainer($1,$owner);
141 %typemap(out) YACS::ENGINE::Container *
143 $result=convertContainer($1,$owner);
149 //Take ownership : it is not the default (constructor) as it is a factory
150 %newobject *::createProc;
151 %newobject *::createScriptNode;
152 %newobject *::createFuncNode;
153 %newobject *::createRefNode;
154 %newobject *::createCompoNode;
155 %newobject *::createSInlineNode;
156 %newobject *::createInDataNode;
157 %newobject *::createOutDataNode;
158 %newobject *::createBloc;
159 %newobject *::createForLoop;
160 %newobject *::createForEachLoop;
161 %newobject *::createWhileLoop;
162 %newobject *::createSwitch;
163 %newobject *::loadCatalog;
164 %newobject *::createComponentInstance;
165 %newobject *::createContainer;
168 %newobject *::createInputPort;
169 %newobject *::createOutputPort;
170 %newobject *::createInputDataStreamPort;
171 %newobject *::createOutputDataStreamPort;
173 %newobject *::cloneAlways;
174 %newobject *::cloneWithoutCompAndContDeepCpy;
177 //Take ownership : transfer it from C++ (has to be completed)
178 %newobject YACS::ENGINE::Loop::edRemoveNode;
179 %newobject YACS::ENGINE::Switch::edReleaseDefaultNode;
180 %newobject YACS::ENGINE::Switch::edReleaseCase;
181 %newobject YACS::ENGINE::DynParaLoop::edRemoveNode;
182 %newobject YACS::ENGINE::DynParaLoop::edRemoveInitNode;
183 //No other way to do ??
184 %feature("pythonappend") YACS::ENGINE::Bloc::edRemoveChild(Node *node)%{
188 %newobject *::createSequenceTc;
189 %newobject *::createInterfaceTc;
190 %newobject *::createStructTc;
191 %newobject *::createType;
193 %newobject YACS::ENGINE::SequenceAny::removeUnsetItemsFromThis;
195 %newobject YACS::ENGINE::TypeCode::interfaceTc;
196 %newobject YACS::ENGINE::TypeCode::sequenceTc;
197 %newobject YACS::ENGINE::TypeCode::structTc;
200 * End of ownership section
204 %include <define.hxx>
205 %include <YACSBasesExport.hxx>
206 %include <Exception.hxx>
207 %include <YACSlibEngineExport.hxx>
208 %include <ConversionException.hxx>
209 %include <Runtime.hxx>
210 %include <PropertyInterface.hxx>
212 PYEXCEPTION(YACS::ENGINE::Executor::RunW)
213 PYEXCEPTION(YACS::ENGINE::Executor::RunB)
214 PYEXCEPTION(YACS::ENGINE::Executor::setExecMode)
215 PYEXCEPTION(YACS::ENGINE::Executor::resumeCurrentBreakPoint)
216 PYEXCEPTION(YACS::ENGINE::Executor::stopExecution)
217 PYEXCEPTION(YACS::ENGINE::Executor::waitPause)
218 PYEXCEPTION(YACS::ENGINE::ComponentInstance::load)
220 %include <Executor.hxx>
222 EXCEPTION(YACS::ENGINE::ExecutorSwig::RunPy)
223 EXCEPTION(YACS::ENGINE::ExecutorSwig::waitPause)
224 %include <ExecutorSwig.hxx>
226 %include <RefCounter.hxx>
230 %ignore YACS::ENGINE::TypeCode::getOrBuildAnyFromZippedData;
231 %include <TypeCode.hxx>
233 %include <Scheduler.hxx>
235 %include <Dispatcher.hxx>
236 %include <DeploymentTree.hxx>
238 %extend YACS::ENGINE::Port
240 /* __cmp__ does not exist in Python 3 */
241 int __lt__(Port* other)
248 int __gt__(Port* other)
255 int __ne__(Port* other)
262 int __eq__(Port* other)
269 int __le__(Port* other)
276 int __ge__(Port* other)
289 %include <DataPort.hxx>
290 %include <InPort.hxx>
291 %include <OutPort.hxx>
292 %include <InGate.hxx>
293 %include <OutGate.hxx>
294 %include <DataFlowPort.hxx>
295 %include <DataStreamPort.hxx>
297 %include <LinkInfo.hxx>
298 %include <Logger.hxx>
300 %include <ComponentInstance.hxx>
301 %include <Container.hxx>
302 %include <HomogeneousPoolContainer.hxx>
303 %include <InputPort.hxx>
304 %extend YACS::ENGINE::InputPort
306 void edInitXML(const char * s)
308 self->edInit("XML",s);
310 void edInitPy(PyObject* ob)
312 self->edInit("Python",ob);
315 %include <InPropertyPort.hxx>
316 %extend YACS::ENGINE::InPropertyPort
318 void edInitXML(const char * s)
320 self->edInit("XML",s);
322 void edInitPy(PyObject* ob)
324 self->edInit("Python",ob);
328 %template(edInitInt) YACS::ENGINE::InputPort::edInit<int>;
329 %template(edInitBool) YACS::ENGINE::InputPort::edInit<bool>;
330 %template(edInitString) YACS::ENGINE::InputPort::edInit<std::string>;
331 %template(edInitDbl) YACS::ENGINE::InputPort::edInit<double>;
333 %include <AnyInputPort.hxx>
334 %include <ConditionInputPort.hxx>
335 %include <OutputPort.hxx>
336 %include <AnyOutputPort.hxx>
337 %include <InputDataStreamPort.hxx>
338 %include <OutputDataStreamPort.hxx>
339 %include <DataPort.hxx>
342 %extend YACS::ENGINE::Node
344 /* __cmp__ does not exist in Python 3 */
345 int __lt__(Node* other)
352 int __gt__(Node* other)
359 int __ne__(Node* other)
366 int __eq__(Node* other)
373 int __le__(Node* other)
380 int __ge__(Node* other)
394 %include <ElementaryNode.hxx>
395 %include <InlineNode.hxx>
396 %include <ServiceNode.hxx>
397 %include <ServiceInlineNode.hxx>
398 %include <ServerNode.hxx>
399 %include <DataNode.hxx>
401 %include <ComposedNode.hxx>
402 %include <StaticDefinedComposedNode.hxx>
407 %include <ForLoop.hxx>
408 %include <DynParaLoop.hxx>
409 %include <WhileLoop.hxx>
410 %include <ForEachLoop.hxx>
411 %include <OptimizerLoop.hxx>
412 %include <Switch.hxx>
413 %include <Visitor.hxx>
414 %include <VisitorSaveSchema.hxx>
415 %include <ComponentDefinition.hxx>
416 %include <Catalog.hxx>
419 %include <AlternateThread.hxx>
420 %include <AlternateThreadPT.hxx>
422 // Ignore class OptimizerAlgASync to avoid confusion with class
423 // OptimizerAlgASync in module SALOMERuntime
424 %ignore YACS::ENGINE::OptimizerAlgASync;
425 %include <OptimizerAlg.hxx>
427 %extend YACS::ENGINE::ConditionInputPort
431 return self->getValue();
435 %extend YACS::ENGINE::AnyInputPort
437 PyObject * getPyObj()
439 return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
443 %extend YACS::ENGINE::AnyOutputPort
445 PyObject * getPyObj()
447 return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
451 %extend YACS::ENGINE::Any
455 return (PyObject *)getRuntime()->convertNeutral(const_cast<YACS::ENGINE::TypeCode *>(self->getType()),self);
459 %newobject YACS::ENGINE::SequenceAny::__getitem__;
460 %extend YACS::ENGINE::SequenceAny
462 Any* __getitem__(int i)
464 if (i < self->size())
471 throw std::length_error("index too large");
475 %newobject YACS::ENGINE::StructAny::__getitem__;
476 %extend YACS::ENGINE::StructAny
478 Any* __getitem__(const char * key)
480 AnyPtr a=(*self)[key];
486 %extend YACS::ENGINE::ForEachLoop
488 PyObject *getPassedResults(Executor *execut) const
490 std::vector<SequenceAny *> ret1;
491 std::vector<std::string> ret2;
492 std::vector<unsigned int> ret0(self->getPassedResults(execut,ret1,ret2));
493 PyObject *ret(PyTuple_New(3));
495 PyObject *ret0Py(PyList_New(ret0.size()));
496 for(std::size_t i=0;i<ret0.size();i++)
497 PyList_SetItem(ret0Py,i,PyLong_FromLong(ret0[i]));
498 PyTuple_SetItem(ret,0,ret0Py);
500 PyObject *ret1Py(PyList_New(ret1.size()));
501 for(std::size_t i=0;i<ret1.size();i++)
502 PyList_SetItem(ret1Py,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret1[i]),SWIGTYPE_p_YACS__ENGINE__SequenceAny, SWIG_POINTER_OWN | 0 ));
503 PyTuple_SetItem(ret,1,ret1Py);
505 PyObject *ret2Py(PyList_New(ret2.size()));
506 for(std::size_t i=0;i<ret2.size();i++)
507 PyList_SetItem(ret2Py,i,PyBytes_FromString(ret2[i].c_str()));
508 PyTuple_SetItem(ret,2,ret2Py);
512 void assignPassedResults(const std::vector<unsigned int>& passedIds, PyObject *passedOutputs, const std::vector<std::string>& nameOfOutputs)
514 std::vector<SequenceAny *> passedOutputsCpp;
515 convertFromPyObjVectorOfObj<YACS::ENGINE::SequenceAny *>(passedOutputs,SWIGTYPE_p_YACS__ENGINE__SequenceAny,"SequenceAny",passedOutputsCpp);
516 self->assignPassedResults(passedIds,passedOutputsCpp,nameOfOutputs);