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*)PyCObject_AsVoidPtr(pyapi);
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(TCmap) std::map<std::string, YACS::ENGINE::TypeCode *>;
115 REFCOUNT_TEMPLATE(TCmap,YACS::ENGINE::TypeCode)
116 %template(NODEmap) std::map<std::string, YACS::ENGINE::Node *>;
117 %template(INODEmap) std::map<std::string, YACS::ENGINE::InlineNode *>;
118 %template(SNODEmap) std::map<std::string, YACS::ENGINE::ServiceNode *>;
119 //%template(CONTAINmap) std::map<std::string, YACS::ENGINE::Container *>;
120 REFCOUNT_TEMPLATE(CONTAINmap,YACS::ENGINE::Container)
121 %template(strvec) std::vector<std::string>;
122 %template(uivec) std::vector<unsigned int>;
123 %template(ivec) std::vector<int>;
124 %template(linksvec) std::vector< std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *> >;
125 %template(linkvec) std::vector< std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *> >;
126 %template(instreamlist) std::list<YACS::ENGINE::InputDataStreamPort *>;
127 %template(outstreamlist) std::list<YACS::ENGINE::OutputDataStreamPort *>;
128 %template(vpsi) std::vector< std::pair< std::string, int > >;
130 %template() std::pair<std::string, YACS::ENGINE::CatalogLoader *>;
131 %template(loadermap) std::map<std::string,YACS::ENGINE::CatalogLoader *>;
132 %template() std::pair<std::string, YACS::ENGINE::ComposedNode *>;
133 %template(composedmap) std::map<std::string,YACS::ENGINE::ComposedNode *>;
134 %template() std::pair<std::string, YACS::ENGINE::ComponentDefinition *>;
135 %template(compomap) std::map<std::string, YACS::ENGINE::ComponentDefinition *>;
136 %template() std::pair<std::string, std::string>;
137 %template(propmap) std::map<std::string, std::string>;
139 REFCOUNT_TEMPLATE(CompoInstmap,YACS::ENGINE::ComponentInstance)
142 * End of Template section
145 %typemap(out) Container *
147 $result=convertContainer($1,$owner);
150 %typemap(out) YACS::ENGINE::Container *
152 $result=convertContainer($1,$owner);
158 //Take ownership : it is not the default (constructor) as it is a factory
159 %newobject *::createProc;
160 %newobject *::createScriptNode;
161 %newobject *::createFuncNode;
162 %newobject *::createRefNode;
163 %newobject *::createCompoNode;
164 %newobject *::createSInlineNode;
165 %newobject *::createInDataNode;
166 %newobject *::createOutDataNode;
167 %newobject *::createBloc;
168 %newobject *::createForLoop;
169 %newobject *::createForEachLoop;
170 %newobject *::createWhileLoop;
171 %newobject *::createSwitch;
172 %newobject *::loadCatalog;
173 %newobject *::createComponentInstance;
174 %newobject *::createContainer;
177 %newobject *::createInputPort;
178 %newobject *::createOutputPort;
179 %newobject *::createInputDataStreamPort;
180 %newobject *::createOutputDataStreamPort;
182 %newobject *::cloneAlways;
183 %newobject *::cloneWithoutCompAndContDeepCpy;
186 //Take ownership : transfer it from C++ (has to be completed)
187 %newobject YACS::ENGINE::Loop::edRemoveNode;
188 %newobject YACS::ENGINE::Switch::edReleaseDefaultNode;
189 %newobject YACS::ENGINE::Switch::edReleaseCase;
190 %newobject YACS::ENGINE::DynParaLoop::edRemoveNode;
191 %newobject YACS::ENGINE::DynParaLoop::edRemoveInitNode;
192 //No other way to do ??
193 %feature("pythonappend") YACS::ENGINE::Bloc::edRemoveChild(Node *node)%{
197 %newobject *::createSequenceTc;
198 %newobject *::createInterfaceTc;
199 %newobject *::createStructTc;
200 %newobject *::createType;
202 %newobject YACS::ENGINE::SequenceAny::removeUnsetItemsFromThis;
204 %newobject YACS::ENGINE::TypeCode::interfaceTc;
205 %newobject YACS::ENGINE::TypeCode::sequenceTc;
206 %newobject YACS::ENGINE::TypeCode::structTc;
209 * End of ownership section
213 %include <define.hxx>
214 %include <YACSBasesExport.hxx>
215 %include <Exception.hxx>
216 %include <YACSlibEngineExport.hxx>
217 %include <ConversionException.hxx>
218 %include <Runtime.hxx>
219 %include <PropertyInterface.hxx>
221 PYEXCEPTION(YACS::ENGINE::Executor::RunW)
222 PYEXCEPTION(YACS::ENGINE::Executor::RunB)
223 PYEXCEPTION(YACS::ENGINE::Executor::setExecMode)
224 PYEXCEPTION(YACS::ENGINE::Executor::resumeCurrentBreakPoint)
225 PYEXCEPTION(YACS::ENGINE::Executor::stopExecution)
226 PYEXCEPTION(YACS::ENGINE::Executor::waitPause)
227 PYEXCEPTION(YACS::ENGINE::ComponentInstance::load)
229 %include <Executor.hxx>
231 EXCEPTION(YACS::ENGINE::ExecutorSwig::RunPy)
232 EXCEPTION(YACS::ENGINE::ExecutorSwig::waitPause)
233 %include <ExecutorSwig.hxx>
235 %include <RefCounter.hxx>
239 %ignore YACS::ENGINE::TypeCode::getOrBuildAnyFromZippedData;
240 %include <TypeCode.hxx>
242 %include <Scheduler.hxx>
244 %include <Dispatcher.hxx>
245 %include <DeploymentTree.hxx>
247 %extend YACS::ENGINE::Port
249 int __cmp__(Port* other)
261 %include <DataPort.hxx>
262 %include <InPort.hxx>
263 %include <OutPort.hxx>
264 %include <InGate.hxx>
265 %include <OutGate.hxx>
266 %include <DataFlowPort.hxx>
267 %include <DataStreamPort.hxx>
269 %include <LinkInfo.hxx>
270 %include <Logger.hxx>
272 %include <ComponentInstance.hxx>
273 %include <Container.hxx>
274 %include <HomogeneousPoolContainer.hxx>
275 %include <InputPort.hxx>
276 %extend YACS::ENGINE::InputPort
278 void edInitXML(const char * s)
280 self->edInit("XML",s);
282 void edInitPy(PyObject* ob)
284 self->edInit("Python",ob);
287 %include <InPropertyPort.hxx>
288 %extend YACS::ENGINE::InPropertyPort
290 void edInitXML(const char * s)
292 self->edInit("XML",s);
294 void edInitPy(PyObject* ob)
296 self->edInit("Python",ob);
300 %template(edInitInt) YACS::ENGINE::InputPort::edInit<int>;
301 %template(edInitBool) YACS::ENGINE::InputPort::edInit<bool>;
302 %template(edInitString) YACS::ENGINE::InputPort::edInit<std::string>;
303 %template(edInitDbl) YACS::ENGINE::InputPort::edInit<double>;
305 %include <AnyInputPort.hxx>
306 %include <ConditionInputPort.hxx>
307 %include <OutputPort.hxx>
308 %include <AnyOutputPort.hxx>
309 %include <InputDataStreamPort.hxx>
310 %include <OutputDataStreamPort.hxx>
311 %include <DataPort.hxx>
314 %extend YACS::ENGINE::Node
316 int __cmp__(Node* other)
328 %include <ComplexWeight.hxx>
329 %include <ElementaryNode.hxx>
330 %include <InlineNode.hxx>
331 %include <ServiceNode.hxx>
332 %include <ServiceInlineNode.hxx>
333 %include <ServerNode.hxx>
334 %include <DataNode.hxx>
336 %include <ComposedNode.hxx>
337 %include <StaticDefinedComposedNode.hxx>
342 %include <ForLoop.hxx>
343 %include <DynParaLoop.hxx>
344 %include <WhileLoop.hxx>
345 %include <ForEachLoop.hxx>
346 %include <OptimizerLoop.hxx>
347 %include <Switch.hxx>
348 %include <Visitor.hxx>
349 %include <VisitorSaveSchema.hxx>
350 %include <ComponentDefinition.hxx>
351 %include <Catalog.hxx>
354 %include <AlternateThread.hxx>
355 %include <AlternateThreadPT.hxx>
357 // Ignore class OptimizerAlgASync to avoid confusion with class
358 // OptimizerAlgASync in module SALOMERuntime
359 %ignore YACS::ENGINE::OptimizerAlgASync;
360 %include <OptimizerAlg.hxx>
361 %include "PlayGround.i"
363 %extend YACS::ENGINE::ConditionInputPort
367 return self->getValue();
371 %extend YACS::ENGINE::AnyInputPort
373 PyObject * getPyObj()
375 return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
379 %extend YACS::ENGINE::AnyOutputPort
381 PyObject * getPyObj()
383 return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
387 %extend YACS::ENGINE::Any
391 return (PyObject *)getRuntime()->convertNeutral(const_cast<YACS::ENGINE::TypeCode *>(self->getType()),self);
395 %newobject YACS::ENGINE::SequenceAny::__getitem__;
396 %extend YACS::ENGINE::SequenceAny
398 Any* __getitem__(int i)
400 if (i < self->size())
407 throw std::length_error("index too large");
411 %newobject YACS::ENGINE::StructAny::__getitem__;
412 %extend YACS::ENGINE::StructAny
414 Any* __getitem__(const char * key)
416 AnyPtr a=(*self)[key];
422 %extend YACS::ENGINE::ForEachLoop
424 PyObject *getPassedResults(Executor *execut) const
426 std::vector<SequenceAny *> ret1;
427 std::vector<std::string> ret2;
428 std::vector<unsigned int> ret0(self->getPassedResults(execut,ret1,ret2));
429 PyObject *ret(PyTuple_New(3));
431 PyObject *ret0Py(PyList_New(ret0.size()));
432 for(std::size_t i=0;i<ret0.size();i++)
433 PyList_SetItem(ret0Py,i,PyInt_FromLong(ret0[i]));
434 PyTuple_SetItem(ret,0,ret0Py);
436 PyObject *ret1Py(PyList_New(ret1.size()));
437 for(std::size_t i=0;i<ret1.size();i++)
438 PyList_SetItem(ret1Py,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret1[i]),SWIGTYPE_p_YACS__ENGINE__SequenceAny, SWIG_POINTER_OWN | 0 ));
439 PyTuple_SetItem(ret,1,ret1Py);
441 PyObject *ret2Py(PyList_New(ret2.size()));
442 for(std::size_t i=0;i<ret2.size();i++)
443 PyList_SetItem(ret2Py,i,PyString_FromString(ret2[i].c_str()));
444 PyTuple_SetItem(ret,2,ret2Py);
448 void assignPassedResults(const std::vector<unsigned int>& passedIds, PyObject *passedOutputs, const std::vector<std::string>& nameOfOutputs)
450 std::vector<SequenceAny *> passedOutputsCpp;
451 convertFromPyObjVectorOfObj<YACS::ENGINE::SequenceAny *>(passedOutputs,SWIGTYPE_p_YACS__ENGINE__SequenceAny,"SequenceAny",passedOutputsCpp);
452 self->assignPassedResults(passedIds,passedOutputsCpp,nameOfOutputs);
463 virtual ~AbstractPoint();
465 AbstractPoint(const AbstractPoint&);
468 class ElementaryPoint : public AbstractPoint
471 Node *getFirstNode();
475 ElementaryPoint(const ElementaryPoint&);
478 class BlocPoint : public AbstractPoint
483 BlocPoint(const BlocPoint&);
486 class LinkedBlocPoint : public BlocPoint
491 LinkedBlocPoint(const LinkedBlocPoint&);
494 class ForkBlocPoint : public BlocPoint
499 ForkBlocPoint(const ForkBlocPoint&);
505 SetOfPoints(const std::list<Node *>& nodes);
508 std::string getRepr() const;
511 void accept(PyObject *pv)
513 class MyPointVisitor : public YACS::ENGINE::PointVisitor
516 MyPointVisitor(PyObject *py):_py(py) { }
517 void beginForkBlocPoint(ForkBlocPoint *pt)
519 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__ForkBlocPoint,0));
520 PyObject *meth(PyString_FromString("beginForkBlocPoint"));
521 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
522 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
524 void endForkBlocPoint(ForkBlocPoint *pt)
526 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__ForkBlocPoint,0));
527 PyObject *meth(PyString_FromString("endForkBlocPoint"));
528 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
529 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
531 void beginLinkedBlocPoint(LinkedBlocPoint *pt)
533 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__LinkedBlocPoint,0));
534 PyObject *meth(PyString_FromString("beginLinkedBlocPoint"));
535 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
536 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
538 void endLinkedBlocPoint(LinkedBlocPoint *pt)
540 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__LinkedBlocPoint,0));
541 PyObject *meth(PyString_FromString("endLinkedBlocPoint"));
542 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
543 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
545 void beginElementaryPoint(ElementaryPoint *pt)
547 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__ElementaryPoint,0));//$descriptor(YACS::ENGINE::ElementaryPoint *)
548 PyObject *meth(PyString_FromString("beginElementaryPoint"));
549 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
550 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
552 void endElementaryPoint(ElementaryPoint *pt)
554 PyObject *ptPy(SWIG_NewPointerObj((void*)pt,SWIGTYPE_p_YACS__ENGINE__ElementaryPoint,0));
555 PyObject *meth(PyString_FromString("endElementaryPoint"));
556 PyObject *ret(PyObject_CallMethodObjArgs(_py,meth,ptPy,nullptr));
557 Py_XDECREF(ret); Py_XDECREF(meth); Py_XDECREF(ptPy);
562 MyPointVisitor mpv(pv);