1 // Copyright (C) 2006-2012 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
20 #ifndef _RUNTIMESALOME_HXX_
21 #define _RUNTIMESALOME_HXX_
23 #include "YACSRuntimeSALOMEExport.hxx"
25 // rnv: avoid compilation warning on Linux : "_POSIX_C_SOURCE" and "_XOPEN_SOURCE" are redefined
26 #ifdef _POSIX_C_SOURCE
27 #undef _POSIX_C_SOURCE
35 #include <omniORB4/CORBA.h>
36 #include "Runtime.hxx"
41 //--- from omniORBpy.h (not present on Debian Sarge packages)
44 PyObject* (*cxxObjRefToPyObjRef)(const CORBA::Object_ptr cxx_obj,
45 CORBA::Boolean hold_lock);
46 // Convert a C++ object reference to a Python object reference.
47 // If <hold_lock> is true, caller holds the Python interpreter lock.
49 CORBA::Object_ptr (*pyObjRefToCxxObjRef)(PyObject* py_obj,
50 CORBA::Boolean hold_lock);
51 // Convert a Python object reference to a C++ object reference.
52 // Raises BAD_PARAM if the Python object is not an object reference.
53 // If <hold_lock> is true, caller holds the Python interpreter lock.
55 PyObject* (*handleCxxSystemException)(const CORBA::SystemException& ex);
56 // Sets the Python exception state to reflect the given C++ system
57 // exception. Always returns NULL. The caller must hold the Python
60 //--- end of from omniORBpy.h (not present on Debian Sarge packages)
68 YACSRUNTIMESALOME_EXPORT RuntimeSALOME* getSALOMERuntime();
75 class YACSRUNTIMESALOME_EXPORT RuntimeSALOME: public Runtime
89 static void setRuntime(long flags = UsePython+UseCorba+UseXml+UseCpp+UseSalome); // singleton creation
91 friend RuntimeSALOME* getSALOMERuntime();
93 virtual void init(long flags);
96 virtual InputPort* createInputPort(const std::string& name,
97 const std::string& impl,
101 virtual OutputPort* createOutputPort(const std::string& name,
102 const std::string& impl,
105 virtual InputDataStreamPort* createInputDataStreamPort(const std::string& name,
106 Node *node,TypeCode *type);
108 virtual OutputDataStreamPort* createOutputDataStreamPort(const std::string& name,
109 Node *node,TypeCode *type);
111 virtual DataNode* createInDataNode(const std::string& kind,const std::string& name);
112 virtual DataNode* createOutDataNode(const std::string& kind,const std::string& name);
113 virtual InlineFuncNode* createFuncNode(const std::string& kind,const std::string& name);
114 virtual InlineNode* createScriptNode(const std::string& kind,const std::string& name);
116 virtual ServiceNode* createRefNode(const std::string& kind,const std::string& name);
117 virtual ServiceNode* createCompoNode(const std::string& kind,const std::string& name);
118 virtual ServiceInlineNode *createSInlineNode(const std::string& kind, const std::string& name);
119 virtual ComponentInstance* createComponentInstance(const std::string& name,
120 const std::string& kind="");
121 virtual Container *createContainer(const std::string& kind="");
122 virtual WhileLoop* createWhileLoop(const std::string& name);
123 virtual ForLoop* createForLoop(const std::string& name);
124 virtual OptimizerLoop* createOptimizerLoop(const std::string& name,const std::string& algLib,
125 const std::string& factoryName,bool algInitOnFile,
126 const std::string& kind="", Proc * procForTypes = NULL);
127 virtual Bloc* createBloc(const std::string& name);
128 virtual Proc* createProc(const std::string& name);
130 virtual TypeCode * createInterfaceTc(const std::string& id, const std::string& name,
131 std::list<TypeCodeObjref *> ltc);
132 virtual TypeCode * createSequenceTc(const std::string& id, const std::string& name, TypeCode *content);
133 virtual TypeCodeStruct * createStructTc(const std::string& id, const std::string& name);
135 virtual InputPort* adapt(InputPort* source,
136 const std::string& impl,
137 TypeCode * type,bool init=false) throw (ConversionException);
139 virtual InputPort* adapt(InPropertyPort* source,
140 const std::string& impl,
141 TypeCode * type,bool init=false) throw (ConversionException);
143 virtual InputPort* adaptNeutral(InputPort* source,
144 const std::string& impl,
145 TypeCode * type,bool init) throw (ConversionException);
147 virtual InputPort* adapt(InputCorbaPort* source,
148 const std::string& impl,
149 TypeCode * type,bool init) throw (ConversionException);
151 virtual InputPort* adaptCorbaToCorba(InputCorbaPort* source,
152 TypeCode * type) throw (ConversionException);
154 virtual InputPort* adaptCorbaToNeutral(InputCorbaPort* source,
155 TypeCode * type) throw (ConversionException);
157 virtual InputPort* adaptCorbaToPython(InputCorbaPort* source,
158 TypeCode * type) throw (ConversionException);
160 virtual InputPort* adaptCorbaToCpp(InputCorbaPort* source,
161 TypeCode * type) throw (ConversionException);
163 virtual InputPort* adaptCorbaToXml(InputCorbaPort* source,
164 TypeCode * type) throw (ConversionException);
166 virtual InputPort* adapt(InputPyPort* source,
167 const std::string& impl,
168 TypeCode * type,bool init) throw (ConversionException);
170 virtual InputPort* adaptPythonToCorba(InputPyPort* source,
171 TypeCode * type) throw (ConversionException);
173 virtual InputPort* adaptPythonToNeutral(InputPyPort* source,
174 TypeCode * type) throw (ConversionException);
176 virtual InputPort* adaptPythonToPython(InputPyPort* source,
177 TypeCode * type,bool init) throw (ConversionException);
179 virtual InputPort* adaptPythonToXml(InputPyPort* source,
180 TypeCode * type) throw (ConversionException);
182 virtual InputPort* adaptPythonToCpp(InputPyPort* source,
183 TypeCode * type) throw (ConversionException);
185 virtual InputPort* adapt(InputCppPort* source,
186 const std::string& impl,
187 TypeCode * type,bool init) throw (ConversionException);
189 virtual InputPort* adaptCppToCorba(InputCppPort* source,
190 TypeCode * type) throw (ConversionException);
192 virtual InputPort* adaptCppToNeutral(InputCppPort* source,
193 TypeCode * type) throw (ConversionException);
195 virtual InputPort* adaptCppToPython(InputCppPort* source,
196 TypeCode * type) throw (ConversionException);
198 virtual InputPort* adaptCppToXml(InputCppPort* source,
199 TypeCode * type) throw (ConversionException);
201 virtual InputPort* adaptCppToCpp(InputCppPort* source,
202 TypeCode * type) throw (ConversionException);
204 virtual InputPort* adapt(InputXmlPort* source,
205 const std::string& impl,
206 TypeCode * type,bool init) throw (ConversionException);
208 virtual InputPort* adaptXmlToCorba(InputXmlPort* source,
209 TypeCode * type) throw (ConversionException);
211 virtual InputPort* adaptXmlToPython(InputXmlPort* inport,
212 TypeCode * type) throw (ConversionException);
214 virtual InputPort* adaptXmlToCpp(InputXmlPort* inport,
215 TypeCode * type) throw (ConversionException);
217 virtual InputPort* adaptXmlToNeutral(InputXmlPort* inport,
218 TypeCode * type) throw (ConversionException);
219 virtual InputPort* adaptXmlToXml(InputXmlPort* inport,
220 TypeCode * type,bool init) throw (ConversionException);
223 virtual InputPort* adaptNeutralToXml(InputPort* inport,
224 TypeCode * type) throw (ConversionException);
226 virtual InputPort* adaptNeutralToPython(InputPort* inport,
227 TypeCode * type) throw (ConversionException);
229 virtual InputPort* adaptNeutralToCorba(InputPort* inport,
230 TypeCode * type) throw (ConversionException);
232 virtual InputPort* adaptNeutralToCpp(InputPort* inport,
233 TypeCode * type) throw (ConversionException);
235 virtual void* convertNeutral(TypeCode * type, Any *data);
236 virtual std::string convertNeutralAsString(TypeCode * type, Any *data);
237 virtual std::string convertPyObjectToString(PyObject* ob);
238 virtual PyObject* convertStringToPyObject(const std::string& s);
240 virtual ~RuntimeSALOME();
242 CORBA::ORB_ptr getOrb();
243 PyObject * getPyOrb();
244 PyObject * getBuiltins();
245 DynamicAny::DynAnyFactory_ptr getDynFactory();
246 omniORBpyAPI* getApi();
247 PyObject * get_omnipy();
250 RuntimeSALOME(); // singleton
251 RuntimeSALOME(long flags); // singleton
256 DynamicAny::DynAnyFactory_var _dynFactory;
260 bool _usePython, _useCorba, _useCpp, _useXml;