Salome HOME
Fix make check with Python 2.7
[modules/yacs.git] / src / engine_swig / pilot.i
1 // Copyright (C) 2006-2012  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.
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 "Logger.hxx"
57 #include "DeploymentTree.hxx"
58 #include "ComponentInstance.hxx"
59 #include "DataNode.hxx"
60
61 using namespace YACS::ENGINE;
62
63 %}
64
65 %init
66 %{
67   // init section
68 #ifdef OMNIORB
69   PyObject* omnipy = PyImport_ImportModule((char*)"_omnipy");
70   if (!omnipy)
71   {
72     PyErr_SetString(PyExc_ImportError,(char*)"Cannot import _omnipy");
73     return;
74   }
75   PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
76   api = (omniORBPYAPI*)PyCObject_AsVoidPtr(pyapi);
77   Py_DECREF(pyapi);
78 #endif
79 %}
80
81 %ignore YACS::ENGINE::Any::operator[];
82 %ignore YACS::ENGINE::TypeCode::operator=;
83 %ignore YACS::ENGINE::DeploymentTree::operator=;
84 %ignore operator<<;
85 %ignore YACS::ENGINE::Runtime::_tc_double;
86 %ignore YACS::ENGINE::Runtime::_tc_int;
87 %ignore YACS::ENGINE::Runtime::_tc_bool;
88 %ignore YACS::ENGINE::Runtime::_tc_string;
89 %ignore YACS::ENGINE::Runtime::_tc_file;
90 %rename(StateLoader) YACS::ENGINE::StateLoader; // to suppress a 503 warning
91 %rename(NbDoneLoader) YACS::ENGINE::NbDoneLoader; // to suppress a 503 warning
92 %rename(getRuntime) YACS::ENGINE::getRuntime; // to suppress a 503 warning
93 %rename(_from) YACS::ENGINE::DataLinkInfo::from ; // to suppress a 314 warning
94 %rename(_from) YACS::ENGINE::StreamLinkInfo::from ; // to suppress a 314 warning
95
96 /*
97  * Template section
98  */
99 %template()              std::pair<std::string, YACS::ENGINE::TypeCode *>;
100 %template()              std::pair<std::string, YACS::ENGINE::Node *>;
101 %template()              std::pair<std::string, YACS::ENGINE::InlineNode *>;
102 %template()              std::pair<std::string, YACS::ENGINE::ServiceNode *>;
103 %template()              std::pair<std::string, YACS::ENGINE::Container *>;
104 %template()              std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *>;
105 %template()              std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *>;
106 //%template(TCmap)         std::map<std::string, YACS::ENGINE::TypeCode *>;
107 REFCOUNT_TEMPLATE(TCmap,YACS::ENGINE::TypeCode)
108 %template(NODEmap)       std::map<std::string, YACS::ENGINE::Node *>;
109 %template(INODEmap)      std::map<std::string, YACS::ENGINE::InlineNode *>;
110 %template(SNODEmap)      std::map<std::string, YACS::ENGINE::ServiceNode *>;
111 //%template(CONTAINmap)    std::map<std::string, YACS::ENGINE::Container *>;
112 REFCOUNT_TEMPLATE(CONTAINmap,YACS::ENGINE::Container)
113 %template(strvec)        std::vector<std::string>;
114 %template(linksvec)      std::vector< std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *> >;
115 %template(linkvec)       std::vector< std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *> >;
116 %template(instreamlist)  std::list<YACS::ENGINE::InputDataStreamPort *>;
117 %template(outstreamlist) std::list<YACS::ENGINE::OutputDataStreamPort *>;
118
119 %template()              std::pair<std::string, YACS::ENGINE::CatalogLoader *>;
120 %template(loadermap)     std::map<std::string,YACS::ENGINE::CatalogLoader *>;
121 %template()              std::pair<std::string, YACS::ENGINE::ComposedNode *>;
122 %template(composedmap)   std::map<std::string,YACS::ENGINE::ComposedNode *>;
123 %template()              std::pair<std::string, YACS::ENGINE::ComponentDefinition *>;
124 %template(compomap)      std::map<std::string, YACS::ENGINE::ComponentDefinition *>;
125 %template()              std::pair<std::string, std::string>;
126 %template(propmap)       std::map<std::string, std::string>;
127
128 REFCOUNT_TEMPLATE(CompoInstmap,YACS::ENGINE::ComponentInstance)
129 /*
130  * End of Template section
131  */
132
133
134 /*
135  * Ownership section
136  */
137 //Take ownership : it is not the default (constructor) as it is a factory
138 %newobject *::createProc;
139 %newobject *::createScriptNode;
140 %newobject *::createFuncNode;
141 %newobject *::createRefNode;
142 %newobject *::createCompoNode;
143 %newobject *::createSInlineNode;
144 %newobject *::createInDataNode;
145 %newobject *::createOutDataNode;
146 %newobject *::createBloc;
147 %newobject *::createForLoop;
148 %newobject *::createForEachLoop;
149 %newobject *::createWhileLoop;
150 %newobject *::createSwitch;
151 %newobject *::loadCatalog;
152 %newobject *::createComponentInstance;
153 %newobject *::createContainer;
154
155
156 %newobject *::createInputPort;
157 %newobject *::createOutputPort;
158 %newobject *::createInputDataStreamPort;
159 %newobject *::createOutputDataStreamPort;
160 %newobject *::clone;
161 %newobject *::New;
162
163 //Take ownership : transfer it from C++ (has to be completed)
164 %newobject YACS::ENGINE::Loop::edRemoveNode;
165 %newobject YACS::ENGINE::Switch::edReleaseDefaultNode;
166 %newobject YACS::ENGINE::Switch::edReleaseCase;
167 %newobject YACS::ENGINE::DynParaLoop::edRemoveNode;
168 %newobject YACS::ENGINE::DynParaLoop::edRemoveInitNode;
169 //No other way to do ??
170 %feature("pythonappend") YACS::ENGINE::Bloc::edRemoveChild(Node *node)%{
171         args[1].thisown=1
172 %}
173
174 %newobject *::createSequenceTc;
175 %newobject *::createInterfaceTc;
176 %newobject *::createStructTc;
177 %newobject *::createType;
178
179 %newobject YACS::ENGINE::TypeCode::interfaceTc;
180 %newobject YACS::ENGINE::TypeCode::sequenceTc;
181 %newobject YACS::ENGINE::TypeCode::structTc;
182
183 /*
184  * End of ownership section
185  */
186
187
188 %include <define.hxx>
189 %include <YACSBasesExport.hxx>
190 %include <Exception.hxx>
191 %include <YACSlibEngineExport.hxx>
192 %include <ConversionException.hxx>
193 %include <Runtime.hxx>
194 %include <PropertyInterface.hxx>
195
196 PYEXCEPTION(YACS::ENGINE::Executor::RunW)
197 PYEXCEPTION(YACS::ENGINE::Executor::RunB)
198 PYEXCEPTION(YACS::ENGINE::Executor::setExecMode)
199 PYEXCEPTION(YACS::ENGINE::Executor::resumeCurrentBreakPoint)
200 PYEXCEPTION(YACS::ENGINE::Executor::stopExecution)
201 PYEXCEPTION(YACS::ENGINE::Executor::waitPause)
202 PYEXCEPTION(YACS::ENGINE::ComponentInstance::load)
203
204 %include <Executor.hxx>
205
206 EXCEPTION(YACS::ENGINE::ExecutorSwig::RunPy)
207 EXCEPTION(YACS::ENGINE::ExecutorSwig::waitPause)
208 %include <ExecutorSwig.hxx>
209
210 %include <RefCounter.hxx>
211
212 %include <Any.hxx>
213
214 %ignore YACS::ENGINE::TypeCode::getOrBuildAnyFromZippedData;
215 %include <TypeCode.hxx>
216
217 %include <Scheduler.hxx>
218 %include <Task.hxx>
219 %include <Dispatcher.hxx>
220 %include <DeploymentTree.hxx>
221 %include <Port.hxx>
222 %extend YACS::ENGINE::Port
223 {
224   int __cmp__(Port* other)
225     {
226       if(self==other)
227         return 0;
228       else 
229         return 1;
230     }
231   long ptr()
232     {
233       return (long)self;
234     }
235 }
236 %include <DataPort.hxx>
237 %include <InPort.hxx>
238 %include <OutPort.hxx>
239 %include <InGate.hxx>
240 %include <OutGate.hxx>
241 %include <DataFlowPort.hxx>
242 %include <DataStreamPort.hxx>
243
244 %include <LinkInfo.hxx>
245 %include <Logger.hxx>
246
247 %include <ComponentInstance.hxx>
248 %include <Container.hxx>
249 %include <InputPort.hxx>
250 %extend YACS::ENGINE::InputPort
251 {
252   void edInitXML(const char * s)
253     {
254       self->edInit("XML",s);
255     }
256   void edInitPy(PyObject* ob)
257     {
258       self->edInit("Python",ob);
259     }
260 }
261 %include <InPropertyPort.hxx>
262 %extend YACS::ENGINE::InPropertyPort
263 {
264   void edInitXML(const char * s)
265     {
266       self->edInit("XML",s);
267     }
268   void edInitPy(PyObject* ob)
269     {
270       self->edInit("Python",ob);
271     }
272 }
273
274 %template(edInitInt)       YACS::ENGINE::InputPort::edInit<int>;
275 %template(edInitBool)      YACS::ENGINE::InputPort::edInit<bool>;
276 %template(edInitString)    YACS::ENGINE::InputPort::edInit<std::string>;
277 %template(edInitDbl)       YACS::ENGINE::InputPort::edInit<double>;
278
279 %include <AnyInputPort.hxx>
280 %include <ConditionInputPort.hxx>
281 %include <OutputPort.hxx>
282 %include <AnyOutputPort.hxx>
283 %include <InputDataStreamPort.hxx>
284 %include <OutputDataStreamPort.hxx>
285 %include <DataPort.hxx>
286
287 %include <Node.hxx>
288 %extend YACS::ENGINE::Node 
289 {
290   int __cmp__(Node* other)
291     {
292       if(self==other)
293         return 0;
294       else 
295         return 1;
296     }
297   long ptr()
298     {
299           return (long)self;
300     }
301 }
302
303 %include <ElementaryNode.hxx>
304 %include <InlineNode.hxx>
305 %include <ServiceNode.hxx>
306 %include <ServiceInlineNode.hxx>
307 %include <ServerNode.hxx>
308 %include <DataNode.hxx>
309
310 %include <ComposedNode.hxx>
311 %include <StaticDefinedComposedNode.hxx>
312 %include <Bloc.hxx>
313 %include <Proc.hxx>
314
315 %include <Loop.hxx>
316 %include <ForLoop.hxx>
317 %include <DynParaLoop.hxx>
318 %include <WhileLoop.hxx>
319 %include <ForEachLoop.hxx>
320 %include <OptimizerLoop.hxx>
321 %include <Switch.hxx>
322 %include <Visitor.hxx>
323 %include <VisitorSaveSchema.hxx>
324 %include <ComponentDefinition.hxx>
325 %include <Catalog.hxx>
326 %include <Pool.hxx>
327
328 %include <AlternateThread.hxx>
329 %include <AlternateThreadPT.hxx>
330
331 // Ignore class OptimizerAlgASync to avoid confusion with class
332 // OptimizerAlgASync in module SALOMERuntime
333 %ignore YACS::ENGINE::OptimizerAlgASync;
334 %include <OptimizerAlg.hxx>
335
336 %extend YACS::ENGINE::ConditionInputPort
337 {
338   bool getPyObj()
339   {
340     return self->getValue();
341   }
342 }
343
344 %extend YACS::ENGINE::AnyInputPort
345 {
346   PyObject * getPyObj()
347   {
348     return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
349   }
350 }
351
352 %extend YACS::ENGINE::AnyOutputPort
353 {
354   PyObject * getPyObj()
355   {
356     return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
357   }
358 }
359
360 %newobject YACS::ENGINE::SequenceAny::__getitem__;
361 %extend YACS::ENGINE::SequenceAny
362 {
363   Any* __getitem__(int i)
364   {
365     if (i < self->size())
366       {
367         AnyPtr a=(*self)[i];
368         a->incrRef();
369         return a;
370       }
371     else
372       throw std::length_error("index too large");
373   }
374 }
375
376 %newobject YACS::ENGINE::StructAny::__getitem__;
377 %extend YACS::ENGINE::StructAny
378 {
379   Any* __getitem__(const char * key)
380   {
381     AnyPtr a=(*self)[key];
382     a->incrRef();
383     return a;
384   }
385 }