]> SALOME platform Git repositories - modules/yacs.git/blob - src/runtime/RuntimeSALOME.hxx
Salome HOME
merge from branch DEV tag mergeto_trunk_04apr08
[modules/yacs.git] / src / runtime / RuntimeSALOME.hxx
1
2 #ifndef _RUNTIMESALOME_HXX_
3 #define _RUNTIMESALOME_HXX_
4
5 #include <Python.h>
6 #include <omniORB4/CORBA.h>
7 #include "Runtime.hxx"
8
9 #include<string>
10 #include<set>
11
12 //--- from omniORBpy.h (not present on Debian Sarge packages)
13 struct omniORBpyAPI
14 {
15       PyObject* (*cxxObjRefToPyObjRef)(const CORBA::Object_ptr cxx_obj,
16                                        CORBA::Boolean hold_lock);
17       // Convert a C++ object reference to a Python object reference.
18       // If <hold_lock> is true, caller holds the Python interpreter lock.
19
20       CORBA::Object_ptr (*pyObjRefToCxxObjRef)(PyObject* py_obj,
21                                                CORBA::Boolean hold_lock);
22       // Convert a Python object reference to a C++ object reference.
23       // Raises BAD_PARAM if the Python object is not an object reference.
24       // If <hold_lock> is true, caller holds the Python interpreter lock.
25
26       PyObject* (*handleCxxSystemException)(const CORBA::SystemException& ex);
27       // Sets the Python exception state to reflect the given C++ system
28       // exception. Always returns NULL. The caller must hold the Python
29       // interpreter lock.
30 };
31 //--- end of from omniORBpy.h (not present on Debian Sarge packages)
32       
33 namespace YACS
34 {
35   namespace ENGINE
36   {
37
38     class RuntimeSALOME;
39     RuntimeSALOME* getSALOMERuntime();
40
41     class InputCorbaPort;
42     class InputPyPort;
43     class InputXmlPort;
44     class InputCppPort;
45
46     class RuntimeSALOME: public Runtime
47     {
48     public:
49       
50       enum 
51       {
52               IsPyExt = 1,
53         UsePython = 2,
54               UseCorba = 4,
55               UseXml = 8,
56               UseCpp = 16,
57               UseSalome = 32
58       } FLAGS;
59
60       static void setRuntime(long flags = UsePython+UseCorba+UseXml+UseCpp+UseSalome); // singleton creation
61       
62       friend RuntimeSALOME* getSALOMERuntime();
63
64       virtual void init(long flags);
65       virtual void fini();
66
67       virtual InputPort* createInputPort(const std::string& name,
68                                          const std::string& impl,
69                                          Node * node,
70                                          TypeCode * type);
71
72       virtual OutputPort* createOutputPort(const std::string& name,
73                                            const std::string& impl,
74                                            Node * node,
75                                            TypeCode * type);
76       virtual InputDataStreamPort* createInputDataStreamPort(const std::string& name,
77                                                              Node *node,TypeCode *type);
78
79       virtual OutputDataStreamPort* createOutputDataStreamPort(const std::string& name,
80                                                                Node *node,TypeCode *type);
81
82       virtual DataNode* createInDataNode(const std::string& kind,const std::string& name);
83       virtual DataNode* createOutDataNode(const std::string& kind,const std::string& name);
84       virtual InlineFuncNode* createFuncNode(const std::string& kind,const std::string& name);
85       virtual InlineNode* createScriptNode(const std::string& kind,const std::string& name);
86
87       virtual ServiceNode* createRefNode(const std::string& kind,const std::string& name);
88       virtual ServiceNode* createCompoNode(const std::string& kind,const std::string& name);
89       virtual ServiceInlineNode *createSInlineNode(const std::string& kind, const std::string& name);
90       virtual ComponentInstance* createComponentInstance(const std::string& name,
91                                                          const std::string& kind="");
92       virtual Container *createContainer(const std::string& kind="");
93       virtual WhileLoop* createWhileLoop(const std::string& name);
94       virtual ForLoop* createForLoop(const std::string& name);
95       virtual Bloc* createBloc(const std::string& name);
96       virtual Proc* createProc(const std::string& name);
97
98       virtual InputPort* adapt(InputPort* source,
99                                const std::string& impl,
100                                TypeCode * type) throw (ConversionException);
101
102       virtual InputPort* adaptNeutral(InputPort* source,
103                                       const std::string& impl,
104                                       TypeCode * type) throw (ConversionException);
105
106       virtual InputPort* adapt(InputCorbaPort* source,
107                                const std::string& impl,
108                                TypeCode * type) throw (ConversionException);
109
110       virtual InputPort* adaptCorbaToCorba(InputCorbaPort* source,
111                                            TypeCode * type) throw (ConversionException);
112   
113       virtual InputPort* adaptCorbaToNeutral(InputCorbaPort* source,
114                                              TypeCode * type) throw (ConversionException);
115
116       virtual InputPort* adaptCorbaToPython(InputCorbaPort* source,
117                                             TypeCode * type) throw (ConversionException);
118
119       virtual InputPort* adaptCorbaToCpp(InputCorbaPort* source,
120                                          TypeCode * type) throw (ConversionException);
121
122       virtual InputPort* adaptCorbaToXml(InputCorbaPort* source,
123                                          TypeCode * type) throw (ConversionException);
124
125       virtual InputPort* adapt(InputPyPort* source,
126                                const std::string& impl,
127                                TypeCode * type) throw (ConversionException);
128
129       virtual InputPort* adaptPythonToCorba(InputPyPort* source,
130                                             TypeCode * type) throw (ConversionException);
131       
132       virtual InputPort* adaptPythonToNeutral(InputPyPort* source,
133                                               TypeCode * type) throw (ConversionException);
134
135       virtual InputPort* adaptPythonToPython(InputPyPort* source,
136                                              TypeCode * type) throw (ConversionException);
137       
138       virtual InputPort* adaptPythonToXml(InputPyPort* source,
139                                           TypeCode * type) throw (ConversionException);
140
141       virtual InputPort* adaptPythonToCpp(InputPyPort* source,
142                                           TypeCode * type) throw (ConversionException);
143
144       virtual InputPort* adapt(InputCppPort* source,
145                                const std::string& impl,
146                                TypeCode * type) throw (ConversionException);
147                                
148       virtual InputPort* adaptCppToCorba(InputCppPort* source,
149                                             TypeCode * type) throw (ConversionException);
150       
151       virtual InputPort* adaptCppToNeutral(InputCppPort* source,
152                                               TypeCode * type) throw (ConversionException);
153
154       virtual InputPort* adaptCppToPython(InputCppPort* source,
155                                              TypeCode * type) throw (ConversionException);
156       
157       virtual InputPort* adaptCppToXml(InputCppPort* source,
158                                           TypeCode * type) throw (ConversionException);
159
160       virtual InputPort* adaptCppToCpp(InputCppPort* source,
161                                           TypeCode * type) throw (ConversionException);
162
163       virtual InputPort* adapt(InputXmlPort* source,
164                                const std::string& impl,
165                                TypeCode * type) throw (ConversionException);
166
167       virtual InputPort* adaptXmlToCorba(InputXmlPort* source,
168                                          TypeCode * type) throw (ConversionException);
169
170       virtual InputPort* adaptXmlToPython(InputXmlPort* inport,
171                                           TypeCode * type) throw (ConversionException);
172
173       virtual InputPort* adaptXmlToCpp(InputXmlPort* inport,
174                                           TypeCode * type) throw (ConversionException);
175
176       virtual InputPort* adaptXmlToNeutral(InputXmlPort* inport,
177                                           TypeCode * type) throw (ConversionException);
178
179       virtual InputPort* adaptNeutralToXml(InputPort* inport,
180                                            TypeCode * type) throw (ConversionException);
181
182       virtual InputPort* adaptNeutralToPython(InputPort* inport,
183                                               TypeCode * type) throw (ConversionException);
184
185       virtual InputPort* adaptNeutralToCorba(InputPort* inport,
186                                              TypeCode * type) throw (ConversionException);
187
188       virtual InputPort* adaptNeutralToCpp(InputPort* inport,
189                                              TypeCode * type) throw (ConversionException);
190       virtual ~RuntimeSALOME(); 
191
192       CORBA::ORB_ptr getOrb();
193       PyObject * getPyOrb();
194       PyObject * getBuiltins();
195       DynamicAny::DynAnyFactory_ptr getDynFactory();
196       omniORBpyAPI* getApi();
197       PyObject * get_omnipy();
198
199     protected:
200       RuntimeSALOME();  // singleton
201       RuntimeSALOME(long flags);  // singleton
202       void initBuiltins();
203       CORBA::ORB_var _orb;
204       PyObject * _pyorb;
205       PyObject * _bltins;
206       DynamicAny::DynAnyFactory_var _dynFactory;
207       omniORBpyAPI* _api;
208       PyObject* _omnipy;
209       long _flags;
210       bool _usePython, _useCorba, _useCpp, _useXml;
211
212     };
213   }
214 }
215
216 #endif