Salome HOME
6262f477304eb9a88bfe601602d70b5252dc25f6
[modules/yacs.git] / src / engine_swig / pilot.i
1 // Copyright (C) 2006-2014  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 %define DOCSTRING
21 "All is needed to create and execute a calculation schema."
22 %enddef
23
24 %module(docstring=DOCSTRING) pilot
25
26 #ifndef SWIGIMPORTED
27 //work around SWIG bug #1863647
28 #if SWIG_VERSION >= 0x010336
29 #define SwigPyIterator pilot_PySwigIterator
30 #else
31 #define PySwigIterator pilot_PySwigIterator
32 #endif
33 #endif
34
35 %feature("autodoc", "1");
36
37 %include "engtypemaps.i"
38
39 #ifdef DOXYGEN_IS_OK
40 %include docengine.i
41 #endif
42
43 %{
44 #include "Any.hxx"
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"
57 #include "Logger.hxx"
58 #include "DeploymentTree.hxx"
59 #include "ComponentInstance.hxx"
60 #include "DataNode.hxx"
61
62 using namespace YACS::ENGINE;
63
64 %}
65
66 %init
67 %{
68   // init section
69 #ifdef OMNIORB
70   PyObject* omnipy = PyImport_ImportModule((char*)"_omnipy");
71   if (!omnipy)
72   {
73     PyErr_SetString(PyExc_ImportError,(char*)"Cannot import _omnipy");
74     return;
75   }
76   PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
77   api = (omniORBPYAPI*)PyCObject_AsVoidPtr(pyapi);
78   Py_DECREF(pyapi);
79 #endif
80 %}
81
82 %ignore YACS::ENGINE::Any::operator[];
83 %ignore YACS::ENGINE::TypeCode::operator=;
84 %ignore YACS::ENGINE::DeploymentTree::operator=;
85 %ignore 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
96
97 /*
98  * Template section
99  */
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(linksvec)      std::vector< std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *> >;
116 %template(linkvec)       std::vector< std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *> >;
117 %template(instreamlist)  std::list<YACS::ENGINE::InputDataStreamPort *>;
118 %template(outstreamlist) std::list<YACS::ENGINE::OutputDataStreamPort *>;
119
120 %template()              std::pair<std::string, YACS::ENGINE::CatalogLoader *>;
121 %template(loadermap)     std::map<std::string,YACS::ENGINE::CatalogLoader *>;
122 %template()              std::pair<std::string, YACS::ENGINE::ComposedNode *>;
123 %template(composedmap)   std::map<std::string,YACS::ENGINE::ComposedNode *>;
124 %template()              std::pair<std::string, YACS::ENGINE::ComponentDefinition *>;
125 %template(compomap)      std::map<std::string, YACS::ENGINE::ComponentDefinition *>;
126 %template()              std::pair<std::string, std::string>;
127 %template(propmap)       std::map<std::string, std::string>;
128
129 REFCOUNT_TEMPLATE(CompoInstmap,YACS::ENGINE::ComponentInstance)
130
131 /*
132  * End of Template section
133  */
134
135 %typemap(out) Container *
136 {
137   $result=convertContainer($1,$owner);
138 }
139
140 %typemap(out) YACS::ENGINE::Container *
141 {
142   $result=convertContainer($1,$owner);
143 }
144
145 /*
146  * Ownership section
147  */
148 //Take ownership : it is not the default (constructor) as it is a factory
149 %newobject *::createProc;
150 %newobject *::createScriptNode;
151 %newobject *::createFuncNode;
152 %newobject *::createRefNode;
153 %newobject *::createCompoNode;
154 %newobject *::createSInlineNode;
155 %newobject *::createInDataNode;
156 %newobject *::createOutDataNode;
157 %newobject *::createBloc;
158 %newobject *::createForLoop;
159 %newobject *::createForEachLoop;
160 %newobject *::createWhileLoop;
161 %newobject *::createSwitch;
162 %newobject *::loadCatalog;
163 %newobject *::createComponentInstance;
164 %newobject *::createContainer;
165
166
167 %newobject *::createInputPort;
168 %newobject *::createOutputPort;
169 %newobject *::createInputDataStreamPort;
170 %newobject *::createOutputDataStreamPort;
171 %newobject *::clone;
172 %newobject *::cloneAlways;
173 %newobject *::cloneWithoutCompAndContDeepCpy;
174 %newobject *::New;
175
176 //Take ownership : transfer it from C++ (has to be completed)
177 %newobject YACS::ENGINE::Loop::edRemoveNode;
178 %newobject YACS::ENGINE::Switch::edReleaseDefaultNode;
179 %newobject YACS::ENGINE::Switch::edReleaseCase;
180 %newobject YACS::ENGINE::DynParaLoop::edRemoveNode;
181 %newobject YACS::ENGINE::DynParaLoop::edRemoveInitNode;
182 //No other way to do ??
183 %feature("pythonappend") YACS::ENGINE::Bloc::edRemoveChild(Node *node)%{
184         args[1].thisown=1
185 %}
186
187 %newobject *::createSequenceTc;
188 %newobject *::createInterfaceTc;
189 %newobject *::createStructTc;
190 %newobject *::createType;
191
192 %newobject YACS::ENGINE::TypeCode::interfaceTc;
193 %newobject YACS::ENGINE::TypeCode::sequenceTc;
194 %newobject YACS::ENGINE::TypeCode::structTc;
195
196 /*
197  * End of ownership section
198  */
199
200
201 %include <define.hxx>
202 %include <YACSBasesExport.hxx>
203 %include <Exception.hxx>
204 %include <YACSlibEngineExport.hxx>
205 %include <ConversionException.hxx>
206 %include <Runtime.hxx>
207 %include <PropertyInterface.hxx>
208
209 PYEXCEPTION(YACS::ENGINE::Executor::RunW)
210 PYEXCEPTION(YACS::ENGINE::Executor::RunB)
211 PYEXCEPTION(YACS::ENGINE::Executor::setExecMode)
212 PYEXCEPTION(YACS::ENGINE::Executor::resumeCurrentBreakPoint)
213 PYEXCEPTION(YACS::ENGINE::Executor::stopExecution)
214 PYEXCEPTION(YACS::ENGINE::Executor::waitPause)
215 PYEXCEPTION(YACS::ENGINE::ComponentInstance::load)
216
217 %include <Executor.hxx>
218
219 EXCEPTION(YACS::ENGINE::ExecutorSwig::RunPy)
220 EXCEPTION(YACS::ENGINE::ExecutorSwig::waitPause)
221 %include <ExecutorSwig.hxx>
222
223 %include <RefCounter.hxx>
224
225 %include <Any.hxx>
226
227 %ignore YACS::ENGINE::TypeCode::getOrBuildAnyFromZippedData;
228 %include <TypeCode.hxx>
229
230 %include <Scheduler.hxx>
231 %include <Task.hxx>
232 %include <Dispatcher.hxx>
233 %include <DeploymentTree.hxx>
234 %include <Port.hxx>
235 %extend YACS::ENGINE::Port
236 {
237   int __cmp__(Port* other)
238     {
239       if(self==other)
240         return 0;
241       else 
242         return 1;
243     }
244   long ptr()
245     {
246       return (long)self;
247     }
248 }
249 %include <DataPort.hxx>
250 %include <InPort.hxx>
251 %include <OutPort.hxx>
252 %include <InGate.hxx>
253 %include <OutGate.hxx>
254 %include <DataFlowPort.hxx>
255 %include <DataStreamPort.hxx>
256
257 %include <LinkInfo.hxx>
258 %include <Logger.hxx>
259
260 %include <ComponentInstance.hxx>
261 %include <Container.hxx>
262 %include <HomogeneousPoolContainer.hxx>
263 %include <InputPort.hxx>
264 %extend YACS::ENGINE::InputPort
265 {
266   void edInitXML(const char * s)
267     {
268       self->edInit("XML",s);
269     }
270   void edInitPy(PyObject* ob)
271     {
272       self->edInit("Python",ob);
273     }
274 }
275 %include <InPropertyPort.hxx>
276 %extend YACS::ENGINE::InPropertyPort
277 {
278   void edInitXML(const char * s)
279     {
280       self->edInit("XML",s);
281     }
282   void edInitPy(PyObject* ob)
283     {
284       self->edInit("Python",ob);
285     }
286 }
287
288 %template(edInitInt)       YACS::ENGINE::InputPort::edInit<int>;
289 %template(edInitBool)      YACS::ENGINE::InputPort::edInit<bool>;
290 %template(edInitString)    YACS::ENGINE::InputPort::edInit<std::string>;
291 %template(edInitDbl)       YACS::ENGINE::InputPort::edInit<double>;
292
293 %include <AnyInputPort.hxx>
294 %include <ConditionInputPort.hxx>
295 %include <OutputPort.hxx>
296 %include <AnyOutputPort.hxx>
297 %include <InputDataStreamPort.hxx>
298 %include <OutputDataStreamPort.hxx>
299 %include <DataPort.hxx>
300
301 %include <Node.hxx>
302 %extend YACS::ENGINE::Node 
303 {
304   int __cmp__(Node* other)
305     {
306       if(self==other)
307         return 0;
308       else 
309         return 1;
310     }
311   long ptr()
312     {
313           return (long)self;
314     }
315 }
316
317 %include <ElementaryNode.hxx>
318 %include <InlineNode.hxx>
319 %include <ServiceNode.hxx>
320 %include <ServiceInlineNode.hxx>
321 %include <ServerNode.hxx>
322 %include <DataNode.hxx>
323
324 %include <ComposedNode.hxx>
325 %include <StaticDefinedComposedNode.hxx>
326 %include <Bloc.hxx>
327 %include <Proc.hxx>
328
329 %include <Loop.hxx>
330 %include <ForLoop.hxx>
331 %include <DynParaLoop.hxx>
332 %include <WhileLoop.hxx>
333 %include <ForEachLoop.hxx>
334 %include <OptimizerLoop.hxx>
335 %include <Switch.hxx>
336 %include <Visitor.hxx>
337 %include <VisitorSaveSchema.hxx>
338 %include <ComponentDefinition.hxx>
339 %include <Catalog.hxx>
340 %include <Pool.hxx>
341
342 %include <AlternateThread.hxx>
343 %include <AlternateThreadPT.hxx>
344
345 // Ignore class OptimizerAlgASync to avoid confusion with class
346 // OptimizerAlgASync in module SALOMERuntime
347 %ignore YACS::ENGINE::OptimizerAlgASync;
348 %include <OptimizerAlg.hxx>
349
350 %extend YACS::ENGINE::ConditionInputPort
351 {
352   bool getPyObj()
353   {
354     return self->getValue();
355   }
356 }
357
358 %extend YACS::ENGINE::AnyInputPort
359 {
360   PyObject * getPyObj()
361   {
362     return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
363   }
364 }
365
366 %extend YACS::ENGINE::AnyOutputPort
367 {
368   PyObject * getPyObj()
369   {
370     return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
371   }
372 }
373
374 %newobject YACS::ENGINE::SequenceAny::__getitem__;
375 %extend YACS::ENGINE::SequenceAny
376 {
377   Any* __getitem__(int i)
378   {
379     if (i < self->size())
380       {
381         AnyPtr a=(*self)[i];
382         a->incrRef();
383         return a;
384       }
385     else
386       throw std::length_error("index too large");
387   }
388 }
389
390 %newobject YACS::ENGINE::StructAny::__getitem__;
391 %extend YACS::ENGINE::StructAny
392 {
393   Any* __getitem__(const char * key)
394   {
395     AnyPtr a=(*self)[key];
396     a->incrRef();
397     return a;
398   }
399 }