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"
63 using namespace YACS::ENGINE;
71 PyObject* omnipy = PyImport_ImportModule((char*)"_omnipy");
74 PyErr_SetString(PyExc_ImportError,(char*)"Cannot import _omnipy");
77 PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
78 api = (omniORBpyAPI*)PyCapsule_GetPointer(pyapi,"_omnipy.API");
83 %ignore YACS::ENGINE::Any::operator[];
84 %ignore YACS::ENGINE::TypeCode::operator=;
85 %ignore YACS::ENGINE::DeploymentTree::operator=;
87 %ignore YACS::ENGINE::Runtime::_tc_double;
88 %ignore YACS::ENGINE::Runtime::_tc_int;
89 %ignore YACS::ENGINE::Runtime::_tc_bool;
90 %ignore YACS::ENGINE::Runtime::_tc_string;
91 %ignore YACS::ENGINE::Runtime::_tc_file;
92 %rename(StateLoader) YACS::ENGINE::StateLoader; // to suppress a 503 warning
93 %rename(NbDoneLoader) YACS::ENGINE::NbDoneLoader; // to suppress a 503 warning
94 %rename(getRuntime) YACS::ENGINE::getRuntime; // to suppress a 503 warning
95 %rename(_from) YACS::ENGINE::DataLinkInfo::from ; // to suppress a 314 warning
96 %rename(_from) YACS::ENGINE::StreamLinkInfo::from ; // to suppress a 314 warning
101 %template() std::pair<std::string, YACS::ENGINE::TypeCode *>;
102 %template() std::pair<std::string, YACS::ENGINE::Node *>;
103 %template() std::pair<std::string, YACS::ENGINE::InlineNode *>;
104 %template() std::pair<std::string, YACS::ENGINE::ServiceNode *>;
105 %template() std::pair<std::string, YACS::ENGINE::Container *>;
106 %template() std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *>;
107 %template() std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *>;
108 %template() std::pair< std::string, int >;
109 //%template(TCmap) std::map<std::string, YACS::ENGINE::TypeCode *>;
110 REFCOUNT_TEMPLATE(TCmap,YACS::ENGINE::TypeCode)
111 %template(NODEmap) std::map<std::string, YACS::ENGINE::Node *>;
112 %template(INODEmap) std::map<std::string, YACS::ENGINE::InlineNode *>;
113 %template(SNODEmap) std::map<std::string, YACS::ENGINE::ServiceNode *>;
114 //%template(CONTAINmap) std::map<std::string, YACS::ENGINE::Container *>;
115 REFCOUNT_TEMPLATE(CONTAINmap,YACS::ENGINE::Container)
116 %template(strvec) std::vector<std::string>;
117 %template(uivec) std::vector<unsigned int>;
118 %template(ivec) std::vector<int>;
119 %template(linksvec) std::vector< std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *> >;
120 %template(linkvec) std::vector< std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *> >;
121 %template(instreamlist) std::list<YACS::ENGINE::InputDataStreamPort *>;
122 %template(outstreamlist) std::list<YACS::ENGINE::OutputDataStreamPort *>;
123 %template(vpsi) std::vector< std::pair< std::string, int > >;
125 %template() std::pair<std::string, YACS::ENGINE::CatalogLoader *>;
126 %template(loadermap) std::map<std::string,YACS::ENGINE::CatalogLoader *>;
127 %template() std::pair<std::string, YACS::ENGINE::ComposedNode *>;
128 %template(composedmap) std::map<std::string,YACS::ENGINE::ComposedNode *>;
129 %template() std::pair<std::string, YACS::ENGINE::ComponentDefinition *>;
130 %template(compomap) std::map<std::string, YACS::ENGINE::ComponentDefinition *>;
131 %template() std::pair<std::string, std::string>;
132 %template(propmap) std::map<std::string, std::string>;
134 REFCOUNT_TEMPLATE(CompoInstmap,YACS::ENGINE::ComponentInstance)
137 * End of Template section
140 %typemap(out) Container *
142 $result=convertContainer($1,$owner);
145 %typemap(out) YACS::ENGINE::Container *
147 $result=convertContainer($1,$owner);
153 //Take ownership : it is not the default (constructor) as it is a factory
154 %newobject *::createProc;
155 %newobject *::createScriptNode;
156 %newobject *::createFuncNode;
157 %newobject *::createRefNode;
158 %newobject *::createCompoNode;
159 %newobject *::createSInlineNode;
160 %newobject *::createInDataNode;
161 %newobject *::createOutDataNode;
162 %newobject *::createBloc;
163 %newobject *::createForLoop;
164 %newobject *::createForEachLoop;
165 %newobject *::createWhileLoop;
166 %newobject *::createSwitch;
167 %newobject *::loadCatalog;
168 %newobject *::createComponentInstance;
169 %newobject *::createContainer;
172 %newobject *::createInputPort;
173 %newobject *::createOutputPort;
174 %newobject *::createInputDataStreamPort;
175 %newobject *::createOutputDataStreamPort;
177 %newobject *::cloneAlways;
178 %newobject *::cloneWithoutCompAndContDeepCpy;
181 //Take ownership : transfer it from C++ (has to be completed)
182 %newobject YACS::ENGINE::Loop::edRemoveNode;
183 %newobject YACS::ENGINE::Switch::edReleaseDefaultNode;
184 %newobject YACS::ENGINE::Switch::edReleaseCase;
185 %newobject YACS::ENGINE::DynParaLoop::edRemoveNode;
186 %newobject YACS::ENGINE::DynParaLoop::edRemoveInitNode;
187 //No other way to do ??
188 %feature("pythonappend") YACS::ENGINE::Bloc::edRemoveChild(Node *node)%{
192 %newobject *::createSequenceTc;
193 %newobject *::createInterfaceTc;
194 %newobject *::createStructTc;
195 %newobject *::createType;
197 %newobject YACS::ENGINE::SequenceAny::removeUnsetItemsFromThis;
199 %newobject YACS::ENGINE::TypeCode::interfaceTc;
200 %newobject YACS::ENGINE::TypeCode::sequenceTc;
201 %newobject YACS::ENGINE::TypeCode::structTc;
204 * End of ownership section
208 %include <define.hxx>
209 %include <YACSBasesExport.hxx>
210 %include <Exception.hxx>
211 %include <YACSlibEngineExport.hxx>
212 %include <ConversionException.hxx>
213 %include <Runtime.hxx>
214 %include <PropertyInterface.hxx>
216 PYEXCEPTION(YACS::ENGINE::Executor::RunW)
217 PYEXCEPTION(YACS::ENGINE::Executor::RunB)
218 PYEXCEPTION(YACS::ENGINE::Executor::setExecMode)
219 PYEXCEPTION(YACS::ENGINE::Executor::resumeCurrentBreakPoint)
220 PYEXCEPTION(YACS::ENGINE::Executor::stopExecution)
221 PYEXCEPTION(YACS::ENGINE::Executor::waitPause)
222 PYEXCEPTION(YACS::ENGINE::ComponentInstance::load)
224 %include <Executor.hxx>
226 EXCEPTION(YACS::ENGINE::ExecutorSwig::RunPy)
227 EXCEPTION(YACS::ENGINE::ExecutorSwig::waitPause)
228 %include <ExecutorSwig.hxx>
230 %include <RefCounter.hxx>
234 %ignore YACS::ENGINE::TypeCode::getOrBuildAnyFromZippedData;
235 %include <TypeCode.hxx>
237 %include <Scheduler.hxx>
239 %include <Dispatcher.hxx>
240 %include <DeploymentTree.hxx>
242 %extend YACS::ENGINE::Port
244 /* __cmp__ does not exist in Python 3 */
245 int __lt__(Port* other)
252 int __gt__(Port* other)
259 int __ne__(Port* other)
266 int __eq__(Port* other)
273 int __le__(Port* other)
280 int __ge__(Port* other)
293 %include <DataPort.hxx>
294 %include <InPort.hxx>
295 %include <OutPort.hxx>
296 %include <InGate.hxx>
297 %include <OutGate.hxx>
298 %include <DataFlowPort.hxx>
299 %include <DataStreamPort.hxx>
301 %include <LinkInfo.hxx>
302 %include <Logger.hxx>
304 %include <ComponentInstance.hxx>
305 %include <Container.hxx>
306 %include <HomogeneousPoolContainer.hxx>
307 %include <InputPort.hxx>
308 %extend YACS::ENGINE::InputPort
310 void edInitXML(const char * s)
312 self->edInit("XML",s);
314 void edInitPy(PyObject* ob)
316 self->edInit("Python",ob);
319 %include <InPropertyPort.hxx>
320 %extend YACS::ENGINE::InPropertyPort
322 void edInitXML(const char * s)
324 self->edInit("XML",s);
326 void edInitPy(PyObject* ob)
328 self->edInit("Python",ob);
332 %template(edInitInt) YACS::ENGINE::InputPort::edInit<int>;
333 %template(edInitBool) YACS::ENGINE::InputPort::edInit<bool>;
334 %template(edInitString) YACS::ENGINE::InputPort::edInit<std::string>;
335 %template(edInitDbl) YACS::ENGINE::InputPort::edInit<double>;
337 %include <AnyInputPort.hxx>
338 %include <ConditionInputPort.hxx>
339 %include <OutputPort.hxx>
340 %include <AnyOutputPort.hxx>
341 %include <InputDataStreamPort.hxx>
342 %include <OutputDataStreamPort.hxx>
343 %include <DataPort.hxx>
346 %extend YACS::ENGINE::Node
348 /* __cmp__ does not exist in Python 3 */
349 int __lt__(Node* other)
356 int __gt__(Node* other)
363 int __ne__(Node* other)
370 int __eq__(Node* other)
377 int __le__(Node* other)
384 int __ge__(Node* other)
398 %include <ElementaryNode.hxx>
399 %include <InlineNode.hxx>
400 %include <ServiceNode.hxx>
401 %include <ServiceInlineNode.hxx>
402 %include <ServerNode.hxx>
403 %include <DataNode.hxx>
405 %include <ComposedNode.hxx>
406 %include <StaticDefinedComposedNode.hxx>
411 %include <ForLoop.hxx>
412 %include <DynParaLoop.hxx>
413 %include <WhileLoop.hxx>
414 %include <ForEachLoop.hxx>
415 %include <OptimizerLoop.hxx>
416 %include <Switch.hxx>
417 %include <Visitor.hxx>
418 %include <VisitorSaveSchema.hxx>
419 %include <ComponentDefinition.hxx>
420 %include <Catalog.hxx>
423 %include <AlternateThread.hxx>
424 %include <AlternateThreadPT.hxx>
426 // Ignore class OptimizerAlgASync to avoid confusion with class
427 // OptimizerAlgASync in module SALOMERuntime
428 %ignore YACS::ENGINE::OptimizerAlgASync;
429 %include <OptimizerAlg.hxx>
430 %include "PlayGround.i"
432 %extend YACS::ENGINE::ConditionInputPort
436 return self->getValue();
440 %extend YACS::ENGINE::AnyInputPort
442 PyObject * getPyObj()
444 return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
448 %extend YACS::ENGINE::AnyOutputPort
450 PyObject * getPyObj()
452 return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
456 %extend YACS::ENGINE::Any
460 return (PyObject *)getRuntime()->convertNeutral(const_cast<YACS::ENGINE::TypeCode *>(self->getType()),self);
464 %newobject YACS::ENGINE::SequenceAny::__getitem__;
465 %extend YACS::ENGINE::SequenceAny
467 Any* __getitem__(int i)
469 if (i < self->size())
476 throw std::length_error("index too large");
480 %newobject YACS::ENGINE::StructAny::__getitem__;
481 %extend YACS::ENGINE::StructAny
483 Any* __getitem__(const char * key)
485 AnyPtr a=(*self)[key];
491 %extend YACS::ENGINE::ForEachLoop
493 PyObject *getPassedResults(Executor *execut) const
495 std::vector<SequenceAny *> ret1;
496 std::vector<std::string> ret2;
497 std::vector<unsigned int> ret0(self->getPassedResults(execut,ret1,ret2));
498 PyObject *ret(PyTuple_New(3));
500 PyObject *ret0Py(PyList_New(ret0.size()));
501 for(std::size_t i=0;i<ret0.size();i++)
502 PyList_SetItem(ret0Py,i,PyLong_FromLong(ret0[i]));
503 PyTuple_SetItem(ret,0,ret0Py);
505 PyObject *ret1Py(PyList_New(ret1.size()));
506 for(std::size_t i=0;i<ret1.size();i++)
507 PyList_SetItem(ret1Py,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret1[i]),SWIGTYPE_p_YACS__ENGINE__SequenceAny, SWIG_POINTER_OWN | 0 ));
508 PyTuple_SetItem(ret,1,ret1Py);
510 PyObject *ret2Py(PyList_New(ret2.size()));
511 for(std::size_t i=0;i<ret2.size();i++)
512 PyList_SetItem(ret2Py,i,PyBytes_FromString(ret2[i].c_str()));
513 PyTuple_SetItem(ret,2,ret2Py);
517 void assignPassedResults(const std::vector<unsigned int>& passedIds, PyObject *passedOutputs, const std::vector<std::string>& nameOfOutputs)
519 std::vector<SequenceAny *> passedOutputsCpp;
520 convertFromPyObjVectorOfObj<YACS::ENGINE::SequenceAny *>(passedOutputs,SWIGTYPE_p_YACS__ENGINE__SequenceAny,"SequenceAny",passedOutputsCpp);
521 self->assignPassedResults(passedIds,passedOutputsCpp,nameOfOutputs);