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*)PyCObject_AsVoidPtr(pyapi);
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 int __cmp__(Port* other)
252 %include <DataPort.hxx>
253 %include <InPort.hxx>
254 %include <OutPort.hxx>
255 %include <InGate.hxx>
256 %include <OutGate.hxx>
257 %include <DataFlowPort.hxx>
258 %include <DataStreamPort.hxx>
260 %include <LinkInfo.hxx>
261 %include <Logger.hxx>
263 %include <ComponentInstance.hxx>
264 %include <Container.hxx>
265 %include <HomogeneousPoolContainer.hxx>
266 %include <InputPort.hxx>
267 %extend YACS::ENGINE::InputPort
269 void edInitXML(const char * s)
271 self->edInit("XML",s);
273 void edInitPy(PyObject* ob)
275 self->edInit("Python",ob);
278 %include <InPropertyPort.hxx>
279 %extend YACS::ENGINE::InPropertyPort
281 void edInitXML(const char * s)
283 self->edInit("XML",s);
285 void edInitPy(PyObject* ob)
287 self->edInit("Python",ob);
291 %template(edInitInt) YACS::ENGINE::InputPort::edInit<int>;
292 %template(edInitBool) YACS::ENGINE::InputPort::edInit<bool>;
293 %template(edInitString) YACS::ENGINE::InputPort::edInit<std::string>;
294 %template(edInitDbl) YACS::ENGINE::InputPort::edInit<double>;
296 %include <AnyInputPort.hxx>
297 %include <ConditionInputPort.hxx>
298 %include <OutputPort.hxx>
299 %include <AnyOutputPort.hxx>
300 %include <InputDataStreamPort.hxx>
301 %include <OutputDataStreamPort.hxx>
302 %include <DataPort.hxx>
305 %extend YACS::ENGINE::Node
307 int __cmp__(Node* other)
320 %include <ElementaryNode.hxx>
321 %include <InlineNode.hxx>
322 %include <ServiceNode.hxx>
323 %include <ServiceInlineNode.hxx>
324 %include <ServerNode.hxx>
325 %include <DataNode.hxx>
327 %include <ComposedNode.hxx>
328 %include <StaticDefinedComposedNode.hxx>
333 %include <ForLoop.hxx>
334 %include <DynParaLoop.hxx>
335 %include <WhileLoop.hxx>
336 %include <ForEachLoop.hxx>
337 %include <OptimizerLoop.hxx>
338 %include <Switch.hxx>
339 %include <Visitor.hxx>
340 %include <VisitorSaveSchema.hxx>
341 %include <ComponentDefinition.hxx>
342 %include <Catalog.hxx>
345 %include <AlternateThread.hxx>
346 %include <AlternateThreadPT.hxx>
348 // Ignore class OptimizerAlgASync to avoid confusion with class
349 // OptimizerAlgASync in module SALOMERuntime
350 %ignore YACS::ENGINE::OptimizerAlgASync;
351 %include <OptimizerAlg.hxx>
353 %extend YACS::ENGINE::ConditionInputPort
357 return self->getValue();
361 %extend YACS::ENGINE::AnyInputPort
363 PyObject * getPyObj()
365 return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
369 %extend YACS::ENGINE::AnyOutputPort
371 PyObject * getPyObj()
373 return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
377 %extend YACS::ENGINE::Any
381 return (PyObject *)getRuntime()->convertNeutral(const_cast<YACS::ENGINE::TypeCode *>(self->getType()),self);
385 %newobject YACS::ENGINE::SequenceAny::__getitem__;
386 %extend YACS::ENGINE::SequenceAny
388 Any* __getitem__(int i)
390 if (i < self->size())
397 throw std::length_error("index too large");
401 %newobject YACS::ENGINE::StructAny::__getitem__;
402 %extend YACS::ENGINE::StructAny
404 Any* __getitem__(const char * key)
406 AnyPtr a=(*self)[key];
412 %extend YACS::ENGINE::ForEachLoop
414 PyObject *getPassedResults(Executor *execut) const
416 std::vector<SequenceAny *> ret1;
417 std::vector<std::string> ret2;
418 std::vector<unsigned int> ret0(self->getPassedResults(execut,ret1,ret2));
419 PyObject *ret(PyTuple_New(3));
421 PyObject *ret0Py(PyList_New(ret0.size()));
422 for(std::size_t i=0;i<ret0.size();i++)
423 PyList_SetItem(ret0Py,i,PyInt_FromLong(ret0[i]));
424 PyTuple_SetItem(ret,0,ret0Py);
426 PyObject *ret1Py(PyList_New(ret1.size()));
427 for(std::size_t i=0;i<ret1.size();i++)
428 PyList_SetItem(ret1Py,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret1[i]),SWIGTYPE_p_YACS__ENGINE__SequenceAny, SWIG_POINTER_OWN | 0 ));
429 PyTuple_SetItem(ret,1,ret1Py);
431 PyObject *ret2Py(PyList_New(ret2.size()));
432 for(std::size_t i=0;i<ret2.size();i++)
433 PyList_SetItem(ret2Py,i,PyString_FromString(ret2[i].c_str()));
434 PyTuple_SetItem(ret,2,ret2Py);
438 void assignPassedResults(const std::vector<unsigned int>& passedIds, PyObject *passedOutputs, const std::vector<std::string>& nameOfOutputs)
440 std::vector<SequenceAny *> passedOutputsCpp;
441 convertFromPyObjVectorOfObj<YACS::ENGINE::SequenceAny *>(passedOutputs,SWIGTYPE_p_YACS__ENGINE__SequenceAny,"SequenceAny",passedOutputsCpp);
442 self->assignPassedResults(passedIds,passedOutputsCpp,nameOfOutputs);