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