1 // Copyright (C) 2006-2008 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef _RUNTIMESALOME_HXX_
20 #define _RUNTIMESALOME_HXX_
23 #include <omniORB4/CORBA.h>
24 #include "Runtime.hxx"
29 //--- from omniORBpy.h (not present on Debian Sarge packages)
32 PyObject* (*cxxObjRefToPyObjRef)(const CORBA::Object_ptr cxx_obj,
33 CORBA::Boolean hold_lock);
34 // Convert a C++ object reference to a Python object reference.
35 // If <hold_lock> is true, caller holds the Python interpreter lock.
37 CORBA::Object_ptr (*pyObjRefToCxxObjRef)(PyObject* py_obj,
38 CORBA::Boolean hold_lock);
39 // Convert a Python object reference to a C++ object reference.
40 // Raises BAD_PARAM if the Python object is not an object reference.
41 // If <hold_lock> is true, caller holds the Python interpreter lock.
43 PyObject* (*handleCxxSystemException)(const CORBA::SystemException& ex);
44 // Sets the Python exception state to reflect the given C++ system
45 // exception. Always returns NULL. The caller must hold the Python
48 //--- end of from omniORBpy.h (not present on Debian Sarge packages)
56 RuntimeSALOME* getSALOMERuntime();
63 class RuntimeSALOME: public Runtime
77 static void setRuntime(long flags = UsePython+UseCorba+UseXml+UseCpp+UseSalome); // singleton creation
79 friend RuntimeSALOME* getSALOMERuntime();
81 virtual void init(long flags);
84 virtual InputPort* createInputPort(const std::string& name,
85 const std::string& impl,
89 virtual OutputPort* createOutputPort(const std::string& name,
90 const std::string& impl,
93 virtual InputDataStreamPort* createInputDataStreamPort(const std::string& name,
94 Node *node,TypeCode *type);
96 virtual OutputDataStreamPort* createOutputDataStreamPort(const std::string& name,
97 Node *node,TypeCode *type);
99 virtual DataNode* createInDataNode(const std::string& kind,const std::string& name);
100 virtual DataNode* createOutDataNode(const std::string& kind,const std::string& name);
101 virtual InlineFuncNode* createFuncNode(const std::string& kind,const std::string& name);
102 virtual InlineNode* createScriptNode(const std::string& kind,const std::string& name);
104 virtual ServiceNode* createRefNode(const std::string& kind,const std::string& name);
105 virtual ServiceNode* createCompoNode(const std::string& kind,const std::string& name);
106 virtual ServiceInlineNode *createSInlineNode(const std::string& kind, const std::string& name);
107 virtual ComponentInstance* createComponentInstance(const std::string& name,
108 const std::string& kind="");
109 virtual Container *createContainer(const std::string& kind="");
110 virtual WhileLoop* createWhileLoop(const std::string& name);
111 virtual ForLoop* createForLoop(const std::string& name);
112 virtual Bloc* createBloc(const std::string& name);
113 virtual Proc* createProc(const std::string& name);
115 virtual InputPort* adapt(InputPort* source,
116 const std::string& impl,
117 TypeCode * type,bool init=false) throw (ConversionException);
119 virtual InputPort* adaptNeutral(InputPort* source,
120 const std::string& impl,
121 TypeCode * type,bool init) throw (ConversionException);
123 virtual InputPort* adapt(InputCorbaPort* source,
124 const std::string& impl,
125 TypeCode * type,bool init) throw (ConversionException);
127 virtual InputPort* adaptCorbaToCorba(InputCorbaPort* source,
128 TypeCode * type) throw (ConversionException);
130 virtual InputPort* adaptCorbaToNeutral(InputCorbaPort* source,
131 TypeCode * type) throw (ConversionException);
133 virtual InputPort* adaptCorbaToPython(InputCorbaPort* source,
134 TypeCode * type) throw (ConversionException);
136 virtual InputPort* adaptCorbaToCpp(InputCorbaPort* source,
137 TypeCode * type) throw (ConversionException);
139 virtual InputPort* adaptCorbaToXml(InputCorbaPort* source,
140 TypeCode * type) throw (ConversionException);
142 virtual InputPort* adapt(InputPyPort* source,
143 const std::string& impl,
144 TypeCode * type,bool init) throw (ConversionException);
146 virtual InputPort* adaptPythonToCorba(InputPyPort* source,
147 TypeCode * type) throw (ConversionException);
149 virtual InputPort* adaptPythonToNeutral(InputPyPort* source,
150 TypeCode * type) throw (ConversionException);
152 virtual InputPort* adaptPythonToPython(InputPyPort* source,
153 TypeCode * type,bool init) throw (ConversionException);
155 virtual InputPort* adaptPythonToXml(InputPyPort* source,
156 TypeCode * type) throw (ConversionException);
158 virtual InputPort* adaptPythonToCpp(InputPyPort* source,
159 TypeCode * type) throw (ConversionException);
161 virtual InputPort* adapt(InputCppPort* source,
162 const std::string& impl,
163 TypeCode * type,bool init) throw (ConversionException);
165 virtual InputPort* adaptCppToCorba(InputCppPort* source,
166 TypeCode * type) throw (ConversionException);
168 virtual InputPort* adaptCppToNeutral(InputCppPort* source,
169 TypeCode * type) throw (ConversionException);
171 virtual InputPort* adaptCppToPython(InputCppPort* source,
172 TypeCode * type) throw (ConversionException);
174 virtual InputPort* adaptCppToXml(InputCppPort* source,
175 TypeCode * type) throw (ConversionException);
177 virtual InputPort* adaptCppToCpp(InputCppPort* source,
178 TypeCode * type) throw (ConversionException);
180 virtual InputPort* adapt(InputXmlPort* source,
181 const std::string& impl,
182 TypeCode * type,bool init) throw (ConversionException);
184 virtual InputPort* adaptXmlToCorba(InputXmlPort* source,
185 TypeCode * type) throw (ConversionException);
187 virtual InputPort* adaptXmlToPython(InputXmlPort* inport,
188 TypeCode * type) throw (ConversionException);
190 virtual InputPort* adaptXmlToCpp(InputXmlPort* inport,
191 TypeCode * type) throw (ConversionException);
193 virtual InputPort* adaptXmlToNeutral(InputXmlPort* inport,
194 TypeCode * type) throw (ConversionException);
196 virtual InputPort* adaptNeutralToXml(InputPort* inport,
197 TypeCode * type) throw (ConversionException);
199 virtual InputPort* adaptNeutralToPython(InputPort* inport,
200 TypeCode * type) throw (ConversionException);
202 virtual InputPort* adaptNeutralToCorba(InputPort* inport,
203 TypeCode * type) throw (ConversionException);
205 virtual InputPort* adaptNeutralToCpp(InputPort* inport,
206 TypeCode * type) throw (ConversionException);
208 virtual void* convertNeutral(TypeCode * type, Any *data);
209 virtual std::string convertNeutralAsString(TypeCode * type, Any *data);
210 virtual std::string convertPyObjectToString(PyObject* ob);
211 virtual PyObject* convertStringToPyObject(const std::string& s);
213 virtual ~RuntimeSALOME();
215 CORBA::ORB_ptr getOrb();
216 PyObject * getPyOrb();
217 PyObject * getBuiltins();
218 DynamicAny::DynAnyFactory_ptr getDynFactory();
219 omniORBpyAPI* getApi();
220 PyObject * get_omnipy();
223 RuntimeSALOME(); // singleton
224 RuntimeSALOME(long flags); // singleton
229 DynamicAny::DynAnyFactory_var _dynFactory;
233 bool _usePython, _useCorba, _useCpp, _useXml;