Salome HOME
331feeae71cd81251361134ebea6583937a9150e
[modules/yacs.git] / src / engine / pilot.i
1 //  Copyright (C) 2006-2008  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 %define DOCSTRING
20 "All is needed to create and execute a calculation schema."
21 %enddef
22
23 %module(docstring=DOCSTRING) pilot
24
25 #ifndef SWIGIMPORTED
26 //work around SWIG bug #1863647
27 #define PySwigIterator pilot_PySwigIterator
28 #endif
29
30 %feature("autodoc", "1");
31
32 %include "engtypemaps.i"
33
34 %{
35 #include "Any.hxx"
36 #include "TypeCode.hxx"
37 #include "ComponentDefinition.hxx"
38 #include "Visitor.hxx"
39 #include "VisitorSaveSchema.hxx"
40 #include "VisitorSaveState.hxx"
41 #include "LinkInfo.hxx"
42 #include "Catalog.hxx"
43 #include "Executor.hxx"
44 #include "ExecutorSwig.hxx"
45 #include "Dispatcher.hxx"
46 #include "Container.hxx"
47 #include "Logger.hxx"
48 #include "DeploymentTree.hxx"
49 #include "ComponentInstance.hxx"
50 #include "DataNode.hxx"
51
52 using namespace YACS::ENGINE;
53
54 %}
55
56 %init
57 %{
58   // init section
59 #ifdef OMNIORB
60   PyObject* omnipy = PyImport_ImportModule((char*)"_omnipy");
61   if (!omnipy)
62   {
63     PyErr_SetString(PyExc_ImportError,(char*)"Cannot import _omnipy");
64     return;
65   }
66   PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
67   api = (omniORBPYAPI*)PyCObject_AsVoidPtr(pyapi);
68   Py_DECREF(pyapi);
69 #endif
70 %}
71
72 %ignore YACS::ENGINE::TypeCode::operator=;
73 %ignore YACS::ENGINE::DeploymentTree::operator=;
74 %ignore operator<<;
75 %ignore YACS::ENGINE::Runtime::_tc_double;
76 %ignore YACS::ENGINE::Runtime::_tc_int;
77 %ignore YACS::ENGINE::Runtime::_tc_bool;
78 %ignore YACS::ENGINE::Runtime::_tc_string;
79 %ignore YACS::ENGINE::Runtime::_tc_file;
80 %rename(StateLoader) YACS::ENGINE::StateLoader; // to suppress a 503 warning
81 %rename(NbDoneLoader) YACS::ENGINE::NbDoneLoader; // to suppress a 503 warning
82 %rename(getRuntime) YACS::ENGINE::getRuntime; // to suppress a 503 warning
83 %rename(_from) YACS::ENGINE::DataLinkInfo::from ; // to suppress a 314 warning
84 %rename(_from) YACS::ENGINE::StreamLinkInfo::from ; // to suppress a 314 warning
85
86 /*
87  * Template section
88  */
89 %template()              std::pair<std::string, YACS::ENGINE::TypeCode *>;
90 %template()              std::pair<std::string, YACS::ENGINE::Node *>;
91 %template()              std::pair<std::string, YACS::ENGINE::InlineNode *>;
92 %template()              std::pair<std::string, YACS::ENGINE::ServiceNode *>;
93 %template()              std::pair<std::string, YACS::ENGINE::Container *>;
94 %template()              std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *>;
95 %template()              std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *>;
96 //%template(TCmap)         std::map<std::string, YACS::ENGINE::TypeCode *>;
97 REFCOUNT_TEMPLATE(TCmap,YACS::ENGINE::TypeCode)
98 %template(NODEmap)       std::map<std::string, YACS::ENGINE::Node *>;
99 %template(INODEmap)      std::map<std::string, YACS::ENGINE::InlineNode *>;
100 %template(SNODEmap)      std::map<std::string, YACS::ENGINE::ServiceNode *>;
101 //%template(CONTAINmap)    std::map<std::string, YACS::ENGINE::Container *>;
102 REFCOUNT_TEMPLATE(CONTAINmap,YACS::ENGINE::Container)
103 %template(strvec)        std::vector<std::string>;
104 %template(linksvec)      std::vector< std::pair<YACS::ENGINE::OutPort *,YACS::ENGINE::InPort *> >;
105 %template(linkvec)       std::vector< std::pair<YACS::ENGINE::InPort *,YACS::ENGINE::OutPort *> >;
106 %template(instreamlist)  std::list<YACS::ENGINE::InputDataStreamPort *>;
107 %template(outstreamlist) std::list<YACS::ENGINE::OutputDataStreamPort *>;
108
109 %template()              std::pair<std::string, YACS::ENGINE::CatalogLoader *>;
110 %template(loadermap)     std::map<std::string,YACS::ENGINE::CatalogLoader *>;
111 %template()              std::pair<std::string, YACS::ENGINE::ComposedNode *>;
112 %template(composedmap)   std::map<std::string,YACS::ENGINE::ComposedNode *>;
113 %template()              std::pair<std::string, YACS::ENGINE::ComponentDefinition *>;
114 %template(compomap)      std::map<std::string, YACS::ENGINE::ComponentDefinition *>;
115 %template()              std::pair<std::string, std::string>;
116 %template(propmap)       std::map<std::string, std::string>;
117
118 /*
119  * End of Template section
120  */
121
122
123 /*
124  * Ownership section
125  */
126 //Take ownership : it is not the default (constructor) as it is a factory
127 %newobject YACS::ENGINE::Runtime::createProc;
128 %newobject YACS::ENGINE::Runtime::createScriptNode;
129 %newobject YACS::ENGINE::Runtime::createFuncNode;
130 %newobject YACS::ENGINE::Runtime::createRefNode;
131 %newobject YACS::ENGINE::Runtime::createCompoNode;
132 %newobject YACS::ENGINE::Runtime::createSInlineNode;
133 %newobject YACS::ENGINE::Runtime::createInDataNode;
134 %newobject YACS::ENGINE::Runtime::createOutDataNode;
135 %newobject YACS::ENGINE::Runtime::createBloc;
136 %newobject YACS::ENGINE::Runtime::createForLoop;
137 %newobject YACS::ENGINE::Runtime::createForEachLoop;
138 %newobject YACS::ENGINE::Runtime::createWhileLoop;
139 %newobject YACS::ENGINE::Runtime::createSwitch;
140 %newobject YACS::ENGINE::Runtime::loadCatalog;
141 %newobject YACS::ENGINE::Runtime::createComponentInstance;
142 %newobject YACS::ENGINE::Runtime::createContainer;
143 %newobject YACS::ENGINE::Runtime::createInputPort;
144 %newobject YACS::ENGINE::Runtime::createOutputPort;
145 %newobject YACS::ENGINE::Runtime::createInputDataStreamPort;
146 %newobject YACS::ENGINE::Runtime::createOutputDataStreamPort;
147 %newobject YACS::ENGINE::Node::clone;
148
149 //Take ownership : transfer it from C++ (has to be completed)
150 %newobject YACS::ENGINE::Loop::edRemoveNode;
151 %newobject YACS::ENGINE::Switch::edReleaseDefaultNode;
152 %newobject YACS::ENGINE::Switch::edReleaseCase;
153 %newobject YACS::ENGINE::DynParaLoop::edRemoveNode;
154 %newobject YACS::ENGINE::DynParaLoop::edRemoveInitNode;
155 //No other way to do ??
156 %feature("pythonappend") YACS::ENGINE::Bloc::edRemoveChild(Node *node)%{
157         args[1].thisown=1
158 %}
159
160 %newobject YACS::ENGINE::Proc::createContainer;
161 %newobject YACS::ENGINE::Proc::createSequenceTc;
162 %newobject YACS::ENGINE::Proc::createInterfaceTc;
163 %newobject YACS::ENGINE::Proc::createStructTc;
164 %newobject YACS::ENGINE::Proc::createType;
165
166 %newobject YACS::ENGINE::TypeCode::interfaceTc;
167 %newobject YACS::ENGINE::TypeCode::sequenceTc;
168 %newobject YACS::ENGINE::TypeCode::structTc;
169
170 /*
171  * End of ownership section
172  */
173
174 %include <define.hxx>
175 %include <Exception.hxx>
176 %include <ConversionException.hxx>
177 %include <Runtime.hxx>
178
179 PYEXCEPTION(YACS::ENGINE::Executor::RunW)
180 PYEXCEPTION(YACS::ENGINE::Executor::RunB)
181 PYEXCEPTION(YACS::ENGINE::Executor::setExecMode)
182 PYEXCEPTION(YACS::ENGINE::Executor::resumeCurrentBreakPoint)
183 PYEXCEPTION(YACS::ENGINE::Executor::stopExecution)
184 PYEXCEPTION(YACS::ENGINE::Executor::waitPause)
185 PYEXCEPTION(YACS::ENGINE::ComponentInstance::load)
186
187 %include <Executor.hxx>
188
189 EXCEPTION(YACS::ENGINE::ExecutorSwig::RunPy)
190 EXCEPTION(YACS::ENGINE::ExecutorSwig::waitPause)
191 %include <ExecutorSwig.hxx>
192
193 %include <RefCounter.hxx>
194
195 %ignore YACS::ENGINE::TypeCode::getOrBuildAnyFromZippedData;
196 %include <TypeCode.hxx>
197
198 %include <Scheduler.hxx>
199 %include <Task.hxx>
200 %include <Dispatcher.hxx>
201 %include <DeploymentTree.hxx>
202 %include <Port.hxx>
203 %extend YACS::ENGINE::Port
204 {
205   int __cmp__(Port* other)
206     {
207       if(self==other)
208         return 0;
209       else 
210         return 1;
211     }
212   long ptr()
213     {
214       return (long)self;
215     }
216 }
217 %include <DataPort.hxx>
218 %include <InPort.hxx>
219 %include <OutPort.hxx>
220 %include <InGate.hxx>
221 %include <OutGate.hxx>
222 %include <DataFlowPort.hxx>
223 %include <DataStreamPort.hxx>
224
225 %include <LinkInfo.hxx>
226 %include <Logger.hxx>
227
228 %include <ComponentInstance.hxx>
229 %include <Container.hxx>
230 %include <InputPort.hxx>
231 %extend YACS::ENGINE::InputPort
232 {
233   void edInitXML(const char * s)
234     {
235       self->edInit("XML",s);
236     }
237   void edInitPy(PyObject* ob)
238     {
239       self->edInit("Python",ob);
240     }
241 }
242
243 %template(edInitInt)       YACS::ENGINE::InputPort::edInit<int>;
244 %template(edInitBool)      YACS::ENGINE::InputPort::edInit<bool>;
245 %template(edInitString)    YACS::ENGINE::InputPort::edInit<std::string>;
246 %template(edInitDbl)       YACS::ENGINE::InputPort::edInit<double>;
247
248 %include <AnyInputPort.hxx>
249 %include <ConditionInputPort.hxx>
250 %include <OutputPort.hxx>
251 %include <InputDataStreamPort.hxx>
252 %include <OutputDataStreamPort.hxx>
253 %include <DataPort.hxx>
254
255 %include <Node.hxx>
256 %extend YACS::ENGINE::Node 
257 {
258   int __cmp__(Node* other)
259     {
260       if(self==other)
261         return 0;
262       else 
263         return 1;
264     }
265   long ptr()
266     {
267           return (long)self;
268     }
269 }
270
271 %include <ElementaryNode.hxx>
272 %include <InlineNode.hxx>
273 %include <ServiceNode.hxx>
274 %include <ServiceInlineNode.hxx>
275 %include <DataNode.hxx>
276
277 %include <ComposedNode.hxx>
278 %include <StaticDefinedComposedNode.hxx>
279 %include <Bloc.hxx>
280 %include <Proc.hxx>
281
282 %include <Loop.hxx>
283 %include <ForLoop.hxx>
284 %include <DynParaLoop.hxx>
285 %include <WhileLoop.hxx>
286 %include <ForEachLoop.hxx>
287 %include <OptimizerAlg.hxx>
288 %include <OptimizerLoop.hxx>
289 %include <Switch.hxx>
290 %include <Visitor.hxx>
291 %include <VisitorSaveSchema.hxx>
292 %include <ComponentDefinition.hxx>
293 %include <Catalog.hxx>
294
295 %extend YACS::ENGINE::ConditionInputPort
296 {
297   bool getPyObj()
298   {
299     return self->getValue();
300   }
301 }
302
303 %extend YACS::ENGINE::AnyInputPort
304 {
305   PyObject * getPyObj()
306   {
307     return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
308   }
309 }
310
311 %extend YACS::ENGINE::AnyOutputPort
312 {
313   PyObject * getPyObj()
314   {
315     return (PyObject *)getRuntime()->convertNeutral(self->edGetType(),self->getValue());
316   }
317 }
318