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"
61 #include "PlayGround.hxx"
62 #include "SetOfPoints.hxx"
63 #include "PointVisitor.hxx"
64 #include "ForkBlocPoint.hxx"
65 #include "LinkedBlocPoint.hxx"
66 #include "ElementaryPoint.hxx"
68 using namespace YACS::ENGINE;
76 PyObject* omnipy = PyImport_ImportModule((char*)"_omnipy");
79 PyErr_SetString(PyExc_ImportError,(char*)"Cannot import _omnipy");
82 PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
83 api = (omniORBpyAPI*)PyCapsule_GetPointer(pyapi,"_omnipy.API");
88 %ignore YACS::ENGINE::Any::operator[];
89 %ignore YACS::ENGINE::TypeCode::operator=;
90 %ignore YACS::ENGINE::DeploymentTree::operator=;
92 %ignore YACS::ENGINE::Runtime::_tc_double;
93 %ignore YACS::ENGINE::Runtime::_tc_int;
94 %ignore YACS::ENGINE::Runtime::_tc_bool;
95 %ignore YACS::ENGINE::Runtime::_tc_string;
96 %ignore YACS::ENGINE::Runtime::_tc_file;
97 %rename(StateLoader) YACS::ENGINE::StateLoader; // to suppress a 503 warning
98 %rename(NbDoneLoader) YACS::ENGINE::NbDoneLoader; // to suppress a 503 warning
99 %rename(getRuntime) YACS::ENGINE::getRuntime; // to suppress a 503 warning
100 %rename(_from) YACS::ENGINE::DataLinkInfo::from ; // to suppress a 314 warning
101 %rename(_from) YACS::ENGINE::StreamLinkInfo::from ; // to suppress a 314 warning
106 %template() std::pair<std::string, YACS::ENGINE::TypeCode *>;
107 %template() std::pair<std::string, YACS::ENGINE::Node *>;
108 %template() std::pair<std::string, YACS::ENGINE::InlineNode *>;
109 %template() std::pair<std::string, YACS::ENGINE::ServiceNode *>;
110 %template() std::pair<std::string, YACS::ENGINE::Container *>;
111 %template() std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *>;
112 %template() std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *>;
113 %template() std::pair< std::string, int >;
114 %template(ItPy3TC) IteratorPy3<YACS::ENGINE::TypeCode *>;
115 //%template(TCmap) std::map<std::string, YACS::ENGINE::TypeCode *>;
116 REFCOUNT_TEMPLATE(TCmap,YACS::ENGINE::TypeCode)
117 %template(NODEmap) std::map<std::string, YACS::ENGINE::Node *>;
118 %template(INODEmap) std::map<std::string, YACS::ENGINE::InlineNode *>;
119 %template(SNODEmap) std::map<std::string, YACS::ENGINE::ServiceNode *>;
120 //%template(CONTAINmap) std::map<std::string, YACS::ENGINE::Container *>;
121 %template(ItPy3Cont) IteratorPy3<YACS::ENGINE::Container * >;
122 REFCOUNT_TEMPLATE(CONTAINmap,YACS::ENGINE::Container)
123 %template(strvec) std::vector<std::string>;
124 %template(uivec) std::vector<unsigned int>;
125 %template(ivec) std::vector<int>;
126 %template(linksvec) std::vector< std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *> >;
127 %template(linkvec) std::vector< std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *> >;
128 %template(instreamlist) std::list<YACS::ENGINE::InputDataStreamPort *>;
129 %template(outstreamlist) std::list<YACS::ENGINE::OutputDataStreamPort *>;
130 %template(vpsi) std::vector< std::pair< std::string, int > >;
132 %template() std::pair<std::string, YACS::ENGINE::CatalogLoader *>;
133 %template(loadermap) std::map<std::string,YACS::ENGINE::CatalogLoader *>;
134 %template() std::pair<std::string, YACS::ENGINE::ComposedNode *>;
135 %template(composedmap) std::map<std::string,YACS::ENGINE::ComposedNode *>;
136 %template() std::pair<std::string, YACS::ENGINE::ComponentDefinition *>;
137 %template(compomap) std::map<std::string, YACS::ENGINE::ComponentDefinition *>;
138 %template() std::pair<std::string, std::string>;
139 %template(propmap) std::map<std::string, std::string>;
140 %template(ItPy3Comp) IteratorPy3<YACS::ENGINE::ComponentInstance *>;
141 REFCOUNT_TEMPLATE(CompoInstmap,YACS::ENGINE::ComponentInstance)
143 %include "exception.i"
146 * End of Template section
149 %typemap(out) Container *
151 $result=convertContainer($1,$owner);
154 %typemap(out) YACS::ENGINE::Container *
156 $result=convertContainer($1,$owner);
162 //Take ownership : it is not the default (constructor) as it is a factory
163 %newobject *::createProc;
164 %newobject *::createScriptNode;
165 %newobject *::createFuncNode;
166 %newobject *::createRefNode;
167 %newobject *::createCompoNode;
168 %newobject *::createSInlineNode;
169 %newobject *::createInDataNode;
170 %newobject *::createOutDataNode;
171 %newobject *::createBloc;
172 %newobject *::createForLoop;
173 %newobject *::createForEachLoop;
174 %newobject *::createWhileLoop;
175 %newobject *::createSwitch;
176 %newobject *::loadCatalog;
177 %newobject *::createComponentInstance;
178 %newobject *::createContainer;
181 %newobject *::createInputPort;
182 %newobject *::createOutputPort;
183 %newobject *::createInputDataStreamPort;
184 %newobject *::createOutputDataStreamPort;
186 %newobject *::cloneAlways;
187 %newobject *::cloneWithoutCompAndContDeepCpy;
190 //Take ownership : transfer it from C++ (has to be completed)
191 %newobject YACS::ENGINE::Loop::edRemoveNode;
192 %newobject YACS::ENGINE::Switch::edReleaseDefaultNode;
193 %newobject YACS::ENGINE::Switch::edReleaseCase;
194 %newobject YACS::ENGINE::DynParaLoop::edRemoveNode;
195 %newobject YACS::ENGINE::DynParaLoop::edRemoveInitNode;
196 //No other way to do ??
197 %feature("pythonappend") YACS::ENGINE::Bloc::edRemoveChild(Node *node)%{
201 %newobject *::createSequenceTc;
202 %newobject *::createInterfaceTc;
203 %newobject *::createStructTc;
204 %newobject *::createType;
206 %newobject YACS::ENGINE::SequenceAny::removeUnsetItemsFromThis;
208 %newobject YACS::ENGINE::TypeCode::interfaceTc;
209 %newobject YACS::ENGINE::TypeCode::sequenceTc;
210 %newobject YACS::ENGINE::TypeCode::structTc;
213 * End of ownership section
217 %include <define.hxx>
218 %include <YACSBasesExport.hxx>
219 %include <Exception.hxx>
220 %include <YACSlibEngineExport.hxx>
221 %include <ConversionException.hxx>
222 %include <Runtime.hxx>
223 %include <PropertyInterface.hxx>
225 PYEXCEPTION(YACS::ENGINE::Executor::RunW)
226 PYEXCEPTION(YACS::ENGINE::Executor::RunB)
227 PYEXCEPTION(YACS::ENGINE::Executor::setExecMode)
228 PYEXCEPTION(YACS::ENGINE::Executor::resumeCurrentBreakPoint)
229 PYEXCEPTION(YACS::ENGINE::Executor::stopExecution)
230 PYEXCEPTION(YACS::ENGINE::Executor::waitPause)
231 PYEXCEPTION(YACS::ENGINE::ComponentInstance::load)
233 %include <Executor.hxx>
235 EXCEPTION(YACS::ENGINE::ExecutorSwig::RunPy)
236 EXCEPTION(YACS::ENGINE::ExecutorSwig::waitPause)
237 %include <ExecutorSwig.hxx>
239 %include <RefCounter.hxx>
243 %ignore YACS::ENGINE::TypeCode::getOrBuildAnyFromZippedData;
244 %include <TypeCode.hxx>
246 %include <Scheduler.hxx>
248 %include <Dispatcher.hxx>
249 %include <DeploymentTree.hxx>
251 %extend YACS::ENGINE::Port
253 /* __cmp__ does not exist in Python 3 */
254 int __lt__(Port* other)
261 int __gt__(Port* other)
268 int __ne__(Port* other)
275 int __eq__(Port* other)
282 int __le__(Port* other)
289 int __ge__(Port* other)
302 %include <DataPort.hxx>
303 %include <InPort.hxx>
304 %include <OutPort.hxx>
305 %include <InGate.hxx>
306 %include <OutGate.hxx>
307 %include <DataFlowPort.hxx>
308 %include <DataStreamPort.hxx>
310 %include <LinkInfo.hxx>
311 %include <Logger.hxx>
313 %include <ComponentInstance.hxx>
314 %include <Container.hxx>
315 %include <HomogeneousPoolContainer.hxx>
316 %include <InputPort.hxx>
317 %extend YACS::ENGINE::InputPort
319 void edInitXML(const char * s)
321 self->edInit("XML",s);
323 void edInitPy(PyObject* ob)
325 self->edInit("Python",ob);
328 %include <InPropertyPort.hxx>
329 %extend YACS::ENGINE::InPropertyPort
331 void edInitXML(const char * s)
333 self->edInit("XML",s);
335 void edInitPy(PyObject* ob)
337 self->edInit("Python",ob);
341 %template(edInitInt) YACS::ENGINE::InputPort::edInit<int>;
342 %template(edInitBool) YACS::ENGINE::InputPort::edInit<bool>;
343 %template(edInitString) YACS::ENGINE::InputPort::edInit<std::string>;
344 %template(edInitDbl) YACS::ENGINE::InputPort::edInit<double>;
346 %include <AnyInputPort.hxx>
347 %include <ConditionInputPort.hxx>
348 %include <OutputPort.hxx>
349 %include <AnyOutputPort.hxx>
350 %include <InputDataStreamPort.hxx>
351 %include <OutputDataStreamPort.hxx>
352 %include <DataPort.hxx>
355 %extend YACS::ENGINE::Node
357 /* __cmp__ does not exist in Python 3 */
358 int __lt__(Node* other)
365 int __gt__(Node* other)
372 int __ne__(Node* other)
379 int __eq__(Node* other)
386 int __le__(Node* other)
393 int __ge__(Node* other)
406 %include <ComplexWeight.hxx>
407 %include <ElementaryNode.hxx>
408 %include <InlineNode.hxx>
409 %include <ServiceNode.hxx>
410 %include <ServiceInlineNode.hxx>
411 %include <ServerNode.hxx>
412 %include <DataNode.hxx>
414 %include <ComposedNode.hxx>
415 %include <StaticDefinedComposedNode.hxx>
420 %include <ForLoop.hxx>
421 %include <DynParaLoop.hxx>
422 %include <WhileLoop.hxx>
423 %include <ForEachLoop.hxx>
424 %include <OptimizerLoop.hxx>
425 %include <Switch.hxx>
426 %include <Visitor.hxx>
427 %include <VisitorSaveSchema.hxx>
428 %include <ComponentDefinition.hxx>
429 %include <Catalog.hxx>
432 %include <AlternateThread.hxx>
433 %include <AlternateThreadPT.hxx>
435 // Ignore class OptimizerAlgASync to avoid confusion with class
436 // OptimizerAlgASync in module SALOMERuntime
437 %ignore YACS::ENGINE::OptimizerAlgASync;
438 %include <OptimizerAlg.hxx>
439 %include "PlayGround.i"
441 %extend YACS::ENGINE::ConditionInputPort
445 return self->getValue();
449 %extend YACS::ENGINE::AnyInputPort
451 PyObject * getPyObj()
453 return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
457 %extend YACS::ENGINE::AnyOutputPort
459 PyObject * getPyObj()
461 return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
465 %extend YACS::ENGINE::Any
469 return (PyObject *)getRuntime()->convertNeutral(const_cast<YACS::ENGINE::TypeCode *>(self->getType()),self);
473 %newobject YACS::ENGINE::SequenceAny::__getitem__;
474 %extend YACS::ENGINE::SequenceAny
476 Any* __getitem__(int i)
478 if (i < self->size())
485 throw std::length_error("index too large");
489 %newobject YACS::ENGINE::StructAny::__getitem__;
490 %extend YACS::ENGINE::StructAny
492 Any* __getitem__(const char * key)
494 AnyPtr a=(*self)[key];
500 %extend YACS::ENGINE::ForEachLoop
502 PyObject *getPassedResults(Executor *execut) const
504 std::vector<SequenceAny *> ret1;
505 std::vector<std::string> ret2;
506 std::vector<unsigned int> ret0(self->getPassedResults(execut,ret1,ret2));
507 PyObject *ret(PyTuple_New(3));
509 PyObject *ret0Py(PyList_New(ret0.size()));
510 for(std::size_t i=0;i<ret0.size();i++)
511 PyList_SetItem(ret0Py,i,PyLong_FromLong(ret0[i]));
512 PyTuple_SetItem(ret,0,ret0Py);
514 PyObject *ret1Py(PyList_New(ret1.size()));
515 for(std::size_t i=0;i<ret1.size();i++)
516 PyList_SetItem(ret1Py,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret1[i]),SWIGTYPE_p_YACS__ENGINE__SequenceAny, SWIG_POINTER_OWN | 0 ));
517 PyTuple_SetItem(ret,1,ret1Py);
519 PyObject *ret2Py(PyList_New(ret2.size()));
520 for(std::size_t i=0;i<ret2.size();i++)
521 PyList_SetItem(ret2Py,i,PyUnicode_FromString(ret2[i].c_str()));
522 PyTuple_SetItem(ret,2,ret2Py);
526 void assignPassedResults(const std::vector<unsigned int>& passedIds, PyObject *passedOutputs, const std::vector<std::string>& nameOfOutputs)
528 std::vector<SequenceAny *> passedOutputsCpp;
529 convertFromPyObjVectorOfObj<YACS::ENGINE::SequenceAny *>(passedOutputs,SWIGTYPE_p_YACS__ENGINE__SequenceAny,"SequenceAny",passedOutputsCpp);
530 self->assignPassedResults(passedIds,passedOutputsCpp,nameOfOutputs);
541 virtual ~AbstractPoint();
543 AbstractPoint(const AbstractPoint&);
546 class ElementaryPoint : public AbstractPoint
549 Node *getFirstNode();
553 ElementaryPoint(const ElementaryPoint&);
556 class BlocPoint : public AbstractPoint
561 BlocPoint(const BlocPoint&);
564 class LinkedBlocPoint : public BlocPoint
569 LinkedBlocPoint(const LinkedBlocPoint&);
572 class ForkBlocPoint : public BlocPoint
577 ForkBlocPoint(const ForkBlocPoint&);
583 SetOfPoints(const std::list<Node *>& nodes);
586 std::string getRepr() const;
589 void accept(PyObject *pv)
591 class MyPointVisitor : public YACS::ENGINE::PointVisitor
594 MyPointVisitor(PyObject *py):_py(py) { }
595 void beginForkBlocPoint(ForkBlocPoint *pt)
597 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__ForkBlocPoint,0));
598 PyObject *meth(PyString_FromString("beginForkBlocPoint"));
599 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
600 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
602 void endForkBlocPoint(ForkBlocPoint *pt)
604 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__ForkBlocPoint,0));
605 PyObject *meth(PyString_FromString("endForkBlocPoint"));
606 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
607 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
609 void beginLinkedBlocPoint(LinkedBlocPoint *pt)
611 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__LinkedBlocPoint,0));
612 PyObject *meth(PyString_FromString("beginLinkedBlocPoint"));
613 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
614 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
616 void endLinkedBlocPoint(LinkedBlocPoint *pt)
618 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__LinkedBlocPoint,0));
619 PyObject *meth(PyString_FromString("endLinkedBlocPoint"));
620 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
621 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
623 void beginElementaryPoint(ElementaryPoint *pt)
625 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__ElementaryPoint,0));//$descriptor(YACS::ENGINE::ElementaryPoint *)
626 PyObject *meth(PyString_FromString("beginElementaryPoint"));
627 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
628 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
630 void endElementaryPoint(ElementaryPoint *pt)
632 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__ElementaryPoint,0));
633 PyObject *meth(PyString_FromString("endElementaryPoint"));
634 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
635 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
640 MyPointVisitor mpv(pv);