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"
67 #include "ObserverAsPlugin.hxx"
69 using namespace YACS::ENGINE;
77 PyObject* omnipy = PyImport_ImportModule((char*)"_omnipy");
80 PyErr_SetString(PyExc_ImportError,(char*)"Cannot import _omnipy");
83 PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
84 api = (omniORBpyAPI*)PyCapsule_GetPointer(pyapi,"_omnipy.API");
89 %ignore YACS::ENGINE::Any::operator[];
90 %ignore YACS::ENGINE::TypeCode::operator=;
91 %ignore YACS::ENGINE::DeploymentTree::operator=;
93 %ignore YACS::ENGINE::Runtime::_tc_double;
94 %ignore YACS::ENGINE::Runtime::_tc_int;
95 %ignore YACS::ENGINE::Runtime::_tc_bool;
96 %ignore YACS::ENGINE::Runtime::_tc_string;
97 %ignore YACS::ENGINE::Runtime::_tc_file;
98 %rename(StateLoader) YACS::ENGINE::StateLoader; // to suppress a 503 warning
99 %rename(NbDoneLoader) YACS::ENGINE::NbDoneLoader; // to suppress a 503 warning
100 %rename(getRuntime) YACS::ENGINE::getRuntime; // to suppress a 503 warning
101 %rename(_from) YACS::ENGINE::DataLinkInfo::from ; // to suppress a 314 warning
102 %rename(_from) YACS::ENGINE::StreamLinkInfo::from ; // to suppress a 314 warning
107 %template() std::pair<std::string, YACS::ENGINE::TypeCode *>;
108 %template() std::pair<std::string, YACS::ENGINE::Node *>;
109 %template() std::pair<std::string, YACS::ENGINE::InlineNode *>;
110 %template() std::pair<std::string, YACS::ENGINE::ServiceNode *>;
111 %template() std::pair<std::string, YACS::ENGINE::Container *>;
112 %template() std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *>;
113 %template() std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *>;
114 %template() std::pair< std::string, int >;
115 %template(ItPy3TC) IteratorPy3<YACS::ENGINE::TypeCode *>;
116 //%template(TCmap) std::map<std::string, YACS::ENGINE::TypeCode *>;
117 REFCOUNT_TEMPLATE(TCmap,YACS::ENGINE::TypeCode)
118 %template(NODEmap) std::map<std::string, YACS::ENGINE::Node *>;
119 %template(INODEmap) std::map<std::string, YACS::ENGINE::InlineNode *>;
120 %template(SNODEmap) std::map<std::string, YACS::ENGINE::ServiceNode *>;
121 //%template(CONTAINmap) std::map<std::string, YACS::ENGINE::Container *>;
122 %template(ItPy3Cont) IteratorPy3<YACS::ENGINE::Container * >;
123 REFCOUNT_TEMPLATE(CONTAINmap,YACS::ENGINE::Container)
124 %template(strvec) std::vector<std::string>;
125 %template(uivec) std::vector<unsigned int>;
126 %template(ivec) std::vector<int>;
127 %template(linksvec) std::vector< std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *> >;
128 %template(linkvec) std::vector< std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *> >;
129 %template(instreamlist) std::list<YACS::ENGINE::InputDataStreamPort *>;
130 %template(outstreamlist) std::list<YACS::ENGINE::OutputDataStreamPort *>;
131 %template(vpsi) std::vector< std::pair< std::string, int > >;
133 %template() std::pair<std::string, YACS::ENGINE::CatalogLoader *>;
134 %template(loadermap) std::map<std::string,YACS::ENGINE::CatalogLoader *>;
135 %template() std::pair<std::string, YACS::ENGINE::ComposedNode *>;
136 %template(composedmap) std::map<std::string,YACS::ENGINE::ComposedNode *>;
137 %template() std::pair<std::string, YACS::ENGINE::ComponentDefinition *>;
138 %template(compomap) std::map<std::string, YACS::ENGINE::ComponentDefinition *>;
139 %template() std::pair<std::string, std::string>;
140 %template(propmap) std::map<std::string, std::string>;
141 %template(ItPy3Comp) IteratorPy3<YACS::ENGINE::ComponentInstance *>;
142 REFCOUNT_TEMPLATE(CompoInstmap,YACS::ENGINE::ComponentInstance)
144 %include "exception.i"
147 * End of Template section
150 %typemap(out) Container *
152 $result=convertContainer($1,$owner);
155 %typemap(out) YACS::ENGINE::Container *
157 $result=convertContainer($1,$owner);
163 //Take ownership : it is not the default (constructor) as it is a factory
164 %newobject *::createProc;
165 %newobject *::createScriptNode;
166 %newobject *::createFuncNode;
167 %newobject *::createRefNode;
168 %newobject *::createCompoNode;
169 %newobject *::createSInlineNode;
170 %newobject *::createInDataNode;
171 %newobject *::createOutDataNode;
172 %newobject *::createBloc;
173 %newobject *::createForLoop;
174 %newobject *::createForEachLoop;
175 %newobject *::createWhileLoop;
176 %newobject *::createSwitch;
177 %newobject *::loadCatalog;
178 %newobject *::createComponentInstance;
179 %newobject *::createContainer;
182 %newobject *::createInputPort;
183 %newobject *::createOutputPort;
184 %newobject *::createInputDataStreamPort;
185 %newobject *::createOutputDataStreamPort;
187 %newobject *::cloneAlways;
188 %newobject *::cloneWithoutCompAndContDeepCpy;
191 //Take ownership : transfer it from C++ (has to be completed)
192 %newobject YACS::ENGINE::Loop::edRemoveNode;
193 %newobject YACS::ENGINE::Switch::edReleaseDefaultNode;
194 %newobject YACS::ENGINE::Switch::edReleaseCase;
195 %newobject YACS::ENGINE::DynParaLoop::edRemoveNode;
196 %newobject YACS::ENGINE::DynParaLoop::edRemoveInitNode;
197 //No other way to do ??
198 %feature("pythonappend") YACS::ENGINE::Bloc::edRemoveChild(Node *node)%{
202 %newobject *::createSequenceTc;
203 %newobject *::createInterfaceTc;
204 %newobject *::createStructTc;
205 %newobject *::createType;
207 %newobject YACS::ENGINE::SequenceAny::removeUnsetItemsFromThis;
209 %newobject YACS::ENGINE::TypeCode::interfaceTc;
210 %newobject YACS::ENGINE::TypeCode::sequenceTc;
211 %newobject YACS::ENGINE::TypeCode::structTc;
214 * End of ownership section
218 %include <define.hxx>
219 %include <YACSBasesExport.hxx>
220 %include <Exception.hxx>
221 %include <YACSlibEngineExport.hxx>
222 %include <ConversionException.hxx>
223 %include <Runtime.hxx>
224 %include <PropertyInterface.hxx>
226 PYEXCEPTION(YACS::ENGINE::Executor::RunW)
227 PYEXCEPTION(YACS::ENGINE::Executor::RunB)
228 PYEXCEPTION(YACS::ENGINE::Executor::setExecMode)
229 PYEXCEPTION(YACS::ENGINE::Executor::resumeCurrentBreakPoint)
230 PYEXCEPTION(YACS::ENGINE::Executor::stopExecution)
231 PYEXCEPTION(YACS::ENGINE::Executor::waitPause)
232 PYEXCEPTION(YACS::ENGINE::ComponentInstance::load)
234 %include <Executor.hxx>
236 EXCEPTION(YACS::ENGINE::ExecutorSwig::RunPy)
237 EXCEPTION(YACS::ENGINE::ExecutorSwig::waitPause)
238 %include <ExecutorSwig.hxx>
240 %include <RefCounter.hxx>
244 %ignore YACS::ENGINE::TypeCode::getOrBuildAnyFromZippedData;
245 %include <TypeCode.hxx>
247 %include <Scheduler.hxx>
249 %include <Dispatcher.hxx>
250 %include <DeploymentTree.hxx>
252 %extend YACS::ENGINE::Port
254 /* __cmp__ does not exist in Python 3 */
255 int __lt__(Port* other)
262 int __gt__(Port* other)
269 int __ne__(Port* other)
276 int __eq__(Port* other)
283 int __le__(Port* other)
290 int __ge__(Port* other)
303 %include <DataPort.hxx>
304 %include <InPort.hxx>
305 %include <OutPort.hxx>
306 %include <InGate.hxx>
307 %include <OutGate.hxx>
308 %include <DataFlowPort.hxx>
309 %include <DataStreamPort.hxx>
311 %include <LinkInfo.hxx>
312 %include <Logger.hxx>
314 %include <ComponentInstance.hxx>
315 %include <Container.hxx>
316 %include <HomogeneousPoolContainer.hxx>
317 %include <InputPort.hxx>
318 %extend YACS::ENGINE::InputPort
320 void edInitXML(const char * s)
322 self->edInit("XML",s);
324 void edInitPy(PyObject* ob)
326 self->edInit("Python",ob);
329 %include <InPropertyPort.hxx>
330 %extend YACS::ENGINE::InPropertyPort
332 void edInitXML(const char * s)
334 self->edInit("XML",s);
336 void edInitPy(PyObject* ob)
338 self->edInit("Python",ob);
342 %template(edInitInt) YACS::ENGINE::InputPort::edInit<int>;
343 %template(edInitBool) YACS::ENGINE::InputPort::edInit<bool>;
344 %template(edInitString) YACS::ENGINE::InputPort::edInit<std::string>;
345 %template(edInitDbl) YACS::ENGINE::InputPort::edInit<double>;
347 %include <AnyInputPort.hxx>
348 %include <ConditionInputPort.hxx>
349 %include <OutputPort.hxx>
350 %include <AnyOutputPort.hxx>
351 %include <InputDataStreamPort.hxx>
352 %include <OutputDataStreamPort.hxx>
353 %include <DataPort.hxx>
356 %extend YACS::ENGINE::Node
358 /* __cmp__ does not exist in Python 3 */
359 int __lt__(Node* other)
366 int __gt__(Node* other)
373 int __ne__(Node* other)
380 int __eq__(Node* other)
387 int __le__(Node* other)
394 int __ge__(Node* other)
407 %include <ComplexWeight.hxx>
408 %include <ElementaryNode.hxx>
409 %include <InlineNode.hxx>
410 %include <ServiceNode.hxx>
411 %include <ServiceInlineNode.hxx>
412 %include <ServerNode.hxx>
413 %include <DataNode.hxx>
415 %include <ComposedNode.hxx>
416 %include <StaticDefinedComposedNode.hxx>
421 %include <ForLoop.hxx>
422 %include <DynParaLoop.hxx>
423 %include <WhileLoop.hxx>
424 %include <ForEachLoop.hxx>
425 %include <OptimizerLoop.hxx>
426 %include <Switch.hxx>
427 %include <Visitor.hxx>
428 %include <VisitorSaveSchema.hxx>
429 %include <ComponentDefinition.hxx>
430 %include <Catalog.hxx>
433 %include <AlternateThread.hxx>
434 %include <AlternateThreadPT.hxx>
436 // Ignore class OptimizerAlgASync to avoid confusion with class
437 // OptimizerAlgASync in module SALOMERuntime
438 %ignore YACS::ENGINE::OptimizerAlgASync;
439 %include <OptimizerAlg.hxx>
440 %include "PlayGround.i"
442 %extend YACS::ENGINE::ConditionInputPort
446 return self->getValue();
449 %extend YACS::ENGINE::Any
453 YACS::ENGINE::AtomAny *self2(dynamic_cast<YACS::ENGINE::AtomAny *>(self));
455 throw YACS::Exception("getBytes : self is not an AtomAny !");
457 const char *pt(self2->getBytesValue(len));
458 return PyBytes_FromStringAndSize(pt,len);
462 %extend YACS::ENGINE::AnyInputPort
464 PyObject * getPyObj()
466 return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
470 %extend YACS::ENGINE::AnyOutputPort
472 PyObject * getPyObj()
474 return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
478 %extend YACS::ENGINE::Any
482 return (PyObject *)getRuntime()->convertNeutral(const_cast<YACS::ENGINE::TypeCode *>(self->getType()),self);
486 %newobject YACS::ENGINE::SequenceAny::__getitem__;
487 %extend YACS::ENGINE::SequenceAny
489 Any* __getitem__(int i)
491 if (i < self->size())
498 throw std::length_error("index too large");
502 %newobject YACS::ENGINE::StructAny::__getitem__;
503 %extend YACS::ENGINE::StructAny
505 Any* __getitem__(const char * key)
507 AnyPtr a=(*self)[key];
513 %extend YACS::ENGINE::ForEachLoop
515 PyObject *getPassedResults(Executor *execut) const
517 std::vector<SequenceAny *> ret1;
518 std::vector<std::string> ret2;
519 std::vector<unsigned int> ret0(self->getPassedResults(execut,ret1,ret2));
520 PyObject *ret(PyTuple_New(3));
522 PyObject *ret0Py(PyList_New(ret0.size()));
523 for(std::size_t i=0;i<ret0.size();i++)
524 PyList_SetItem(ret0Py,i,PyLong_FromLong(ret0[i]));
525 PyTuple_SetItem(ret,0,ret0Py);
527 PyObject *ret1Py(PyList_New(ret1.size()));
528 for(std::size_t i=0;i<ret1.size();i++)
529 PyList_SetItem(ret1Py,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret1[i]),SWIGTYPE_p_YACS__ENGINE__SequenceAny, SWIG_POINTER_OWN | 0 ));
530 PyTuple_SetItem(ret,1,ret1Py);
532 PyObject *ret2Py(PyList_New(ret2.size()));
533 for(std::size_t i=0;i<ret2.size();i++)
534 PyList_SetItem(ret2Py,i,PyUnicode_FromString(ret2[i].c_str()));
535 PyTuple_SetItem(ret,2,ret2Py);
539 void assignPassedResults(const std::vector<unsigned int>& passedIds, PyObject *passedOutputs, const std::vector<std::string>& nameOfOutputs)
541 std::vector<SequenceAny *> passedOutputsCpp;
542 convertFromPyObjVectorOfObj<YACS::ENGINE::SequenceAny *>(passedOutputs,SWIGTYPE_p_YACS__ENGINE__SequenceAny,"SequenceAny",passedOutputsCpp);
543 self->assignPassedResults(passedIds,passedOutputsCpp,nameOfOutputs);
554 virtual ~AbstractPoint();
556 AbstractPoint(const AbstractPoint&);
559 class ElementaryPoint : public AbstractPoint
562 Node *getFirstNode();
566 ElementaryPoint(const ElementaryPoint&);
569 class BlocPoint : public AbstractPoint
574 BlocPoint(const BlocPoint&);
577 class LinkedBlocPoint : public BlocPoint
582 LinkedBlocPoint(const LinkedBlocPoint&);
585 class ForkBlocPoint : public BlocPoint
590 ForkBlocPoint(const ForkBlocPoint&);
596 SetOfPoints(const std::list<Node *>& nodes);
599 std::string getRepr() const;
602 void accept(PyObject *pv)
604 class MyPointVisitor : public YACS::ENGINE::PointVisitor
607 MyPointVisitor(PyObject *py):_py(py) { }
608 void beginForkBlocPoint(ForkBlocPoint *pt)
610 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__ForkBlocPoint,0));
611 PyObject *meth(PyString_FromString("beginForkBlocPoint"));
612 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
613 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
615 void endForkBlocPoint(ForkBlocPoint *pt)
617 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__ForkBlocPoint,0));
618 PyObject *meth(PyString_FromString("endForkBlocPoint"));
619 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
620 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
622 void beginLinkedBlocPoint(LinkedBlocPoint *pt)
624 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__LinkedBlocPoint,0));
625 PyObject *meth(PyString_FromString("beginLinkedBlocPoint"));
626 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
627 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
629 void endLinkedBlocPoint(LinkedBlocPoint *pt)
631 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__LinkedBlocPoint,0));
632 PyObject *meth(PyString_FromString("endLinkedBlocPoint"));
633 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
634 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
636 void beginElementaryPoint(ElementaryPoint *pt)
638 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__ElementaryPoint,0));//$descriptor(YACS::ENGINE::ElementaryPoint *)
639 PyObject *meth(PyString_FromString("beginElementaryPoint"));
640 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
641 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
643 void endElementaryPoint(ElementaryPoint *pt)
645 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__ElementaryPoint,0));
646 PyObject *meth(PyString_FromString("endElementaryPoint"));
647 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
648 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
653 MyPointVisitor mpv(pv);
661 %rename(LoadObserversPluginIfAny) LoadObserversPluginIfAnySwig;
662 %rename(UnLoadObserversPluginIfAny) UnLoadObserversPluginIfAnySwig;
665 void LoadObserversPluginIfAnySwig(YACS::ENGINE::ComposedNode *rootNode, YACS::ENGINE::ExecutorSwig *executor)
667 YACS::ENGINE::LoadObserversPluginIfAny(rootNode,executor);
670 void UnLoadObserversPluginIfAnySwig()
672 YACS::ENGINE::UnLoadObserversPluginIfAny();