Salome HOME
Ready to update Executor to take into account of the new type of containers.
[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  * End of Template section
132  */
133
134
135 /*
136  * Ownership section
137  */
138 //Take ownership : it is not the default (constructor) as it is a factory
139 %newobject *::createProc;
140 %newobject *::createScriptNode;
141 %newobject *::createFuncNode;
142 %newobject *::createRefNode;
143 %newobject *::createCompoNode;
144 %newobject *::createSInlineNode;
145 %newobject *::createInDataNode;
146 %newobject *::createOutDataNode;
147 %newobject *::createBloc;
148 %newobject *::createForLoop;
149 %newobject *::createForEachLoop;
150 %newobject *::createWhileLoop;
151 %newobject *::createSwitch;
152 %newobject *::loadCatalog;
153 %newobject *::createComponentInstance;
154 %newobject *::createContainer;
155
156
157 %newobject *::createInputPort;
158 %newobject *::createOutputPort;
159 %newobject *::createInputDataStreamPort;
160 %newobject *::createOutputDataStreamPort;
161 %newobject *::clone;
162 %newobject *::cloneAlways;
163 %newobject *::New;
164
165 //Take ownership : transfer it from C++ (has to be completed)
166 %newobject YACS::ENGINE::Loop::edRemoveNode;
167 %newobject YACS::ENGINE::Switch::edReleaseDefaultNode;
168 %newobject YACS::ENGINE::Switch::edReleaseCase;
169 %newobject YACS::ENGINE::DynParaLoop::edRemoveNode;
170 %newobject YACS::ENGINE::DynParaLoop::edRemoveInitNode;
171 //No other way to do ??
172 %feature("pythonappend") YACS::ENGINE::Bloc::edRemoveChild(Node *node)%{
173         args[1].thisown=1
174 %}
175
176 %newobject *::createSequenceTc;
177 %newobject *::createInterfaceTc;
178 %newobject *::createStructTc;
179 %newobject *::createType;
180
181 %newobject YACS::ENGINE::TypeCode::interfaceTc;
182 %newobject YACS::ENGINE::TypeCode::sequenceTc;
183 %newobject YACS::ENGINE::TypeCode::structTc;
184
185 /*
186  * End of ownership section
187  */
188
189
190 %include <define.hxx>
191 %include <YACSBasesExport.hxx>
192 %include <Exception.hxx>
193 %include <YACSlibEngineExport.hxx>
194 %include <ConversionException.hxx>
195 %include <Runtime.hxx>
196 %include <PropertyInterface.hxx>
197
198 PYEXCEPTION(YACS::ENGINE::Executor::RunW)
199 PYEXCEPTION(YACS::ENGINE::Executor::RunB)
200 PYEXCEPTION(YACS::ENGINE::Executor::setExecMode)
201 PYEXCEPTION(YACS::ENGINE::Executor::resumeCurrentBreakPoint)
202 PYEXCEPTION(YACS::ENGINE::Executor::stopExecution)
203 PYEXCEPTION(YACS::ENGINE::Executor::waitPause)
204 PYEXCEPTION(YACS::ENGINE::ComponentInstance::load)
205
206 %include <Executor.hxx>
207
208 EXCEPTION(YACS::ENGINE::ExecutorSwig::RunPy)
209 EXCEPTION(YACS::ENGINE::ExecutorSwig::waitPause)
210 %include <ExecutorSwig.hxx>
211
212 %include <RefCounter.hxx>
213
214 %include <Any.hxx>
215
216 %ignore YACS::ENGINE::TypeCode::getOrBuildAnyFromZippedData;
217 %include <TypeCode.hxx>
218
219 %include <Scheduler.hxx>
220 %include <Task.hxx>
221 %include <Dispatcher.hxx>
222 %include <DeploymentTree.hxx>
223 %include <Port.hxx>
224 %extend YACS::ENGINE::Port
225 {
226   int __cmp__(Port* other)
227     {
228       if(self==other)
229         return 0;
230       else 
231         return 1;
232     }
233   long ptr()
234     {
235       return (long)self;
236     }
237 }
238 %include <DataPort.hxx>
239 %include <InPort.hxx>
240 %include <OutPort.hxx>
241 %include <InGate.hxx>
242 %include <OutGate.hxx>
243 %include <DataFlowPort.hxx>
244 %include <DataStreamPort.hxx>
245
246 %include <LinkInfo.hxx>
247 %include <Logger.hxx>
248
249 %include <ComponentInstance.hxx>
250 %include <Container.hxx>
251 %include <HomogeneousPoolContainer.hxx>
252 %include <InputPort.hxx>
253 %extend YACS::ENGINE::InputPort
254 {
255   void edInitXML(const char * s)
256     {
257       self->edInit("XML",s);
258     }
259   void edInitPy(PyObject* ob)
260     {
261       self->edInit("Python",ob);
262     }
263 }
264 %include <InPropertyPort.hxx>
265 %extend YACS::ENGINE::InPropertyPort
266 {
267   void edInitXML(const char * s)
268     {
269       self->edInit("XML",s);
270     }
271   void edInitPy(PyObject* ob)
272     {
273       self->edInit("Python",ob);
274     }
275 }
276
277 %template(edInitInt)       YACS::ENGINE::InputPort::edInit<int>;
278 %template(edInitBool)      YACS::ENGINE::InputPort::edInit<bool>;
279 %template(edInitString)    YACS::ENGINE::InputPort::edInit<std::string>;
280 %template(edInitDbl)       YACS::ENGINE::InputPort::edInit<double>;
281
282 %include <AnyInputPort.hxx>
283 %include <ConditionInputPort.hxx>
284 %include <OutputPort.hxx>
285 %include <AnyOutputPort.hxx>
286 %include <InputDataStreamPort.hxx>
287 %include <OutputDataStreamPort.hxx>
288 %include <DataPort.hxx>
289
290 %include <Node.hxx>
291 %extend YACS::ENGINE::Node 
292 {
293   int __cmp__(Node* other)
294     {
295       if(self==other)
296         return 0;
297       else 
298         return 1;
299     }
300   long ptr()
301     {
302           return (long)self;
303     }
304 }
305
306 %include <ElementaryNode.hxx>
307 %include <InlineNode.hxx>
308 %include <ServiceNode.hxx>
309 %include <ServiceInlineNode.hxx>
310 %include <ServerNode.hxx>
311 %include <DataNode.hxx>
312
313 %include <ComposedNode.hxx>
314 %include <StaticDefinedComposedNode.hxx>
315 %include <Bloc.hxx>
316 %include <Proc.hxx>
317
318 %include <Loop.hxx>
319 %include <ForLoop.hxx>
320 %include <DynParaLoop.hxx>
321 %include <WhileLoop.hxx>
322 %include <ForEachLoop.hxx>
323 %include <OptimizerLoop.hxx>
324 %include <Switch.hxx>
325 %include <Visitor.hxx>
326 %include <VisitorSaveSchema.hxx>
327 %include <ComponentDefinition.hxx>
328 %include <Catalog.hxx>
329 %include <Pool.hxx>
330
331 %include <AlternateThread.hxx>
332 %include <AlternateThreadPT.hxx>
333
334 // Ignore class OptimizerAlgASync to avoid confusion with class
335 // OptimizerAlgASync in module SALOMERuntime
336 %ignore YACS::ENGINE::OptimizerAlgASync;
337 %include <OptimizerAlg.hxx>
338
339 %extend YACS::ENGINE::ConditionInputPort
340 {
341   bool getPyObj()
342   {
343     return self->getValue();
344   }
345 }
346
347 %extend YACS::ENGINE::AnyInputPort
348 {
349   PyObject * getPyObj()
350   {
351     return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
352   }
353 }
354
355 %extend YACS::ENGINE::AnyOutputPort
356 {
357   PyObject * getPyObj()
358   {
359     return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
360   }
361 }
362
363 %newobject YACS::ENGINE::SequenceAny::__getitem__;
364 %extend YACS::ENGINE::SequenceAny
365 {
366   Any* __getitem__(int i)
367   {
368     if (i < self->size())
369       {
370         AnyPtr a=(*self)[i];
371         a->incrRef();
372         return a;
373       }
374     else
375       throw std::length_error("index too large");
376   }
377 }
378
379 %newobject YACS::ENGINE::StructAny::__getitem__;
380 %extend YACS::ENGINE::StructAny
381 {
382   Any* __getitem__(const char * key)
383   {
384     AnyPtr a=(*self)[key];
385     a->incrRef();
386     return a;
387   }
388 }