1 // Copyright (C) 2006-2016 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, or (at your option) any later version.
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
77 static Runtime* getSingleton() { return Runtime::_singleton; }
92 static void setRuntime(long flags = UsePython+UseCorba+UseXml+UseCpp+UseSalome,
93 int argc = 0, char* argv[] = NULL);
95 friend RuntimeSALOME* getSALOMERuntime();
97 virtual std::string getVersion() const;
99 virtual void init(long flags, int argc, char* argv[]);
101 virtual std::vector< std::pair<std::string,int> > getCatalogOfComputeNodes() const;
102 virtual InputPort* createInputPort(const std::string& name,
103 const std::string& impl,
107 virtual OutputPort* createOutputPort(const std::string& name,
108 const std::string& impl,
111 virtual InputDataStreamPort* createInputDataStreamPort(const std::string& name,
112 Node *node,TypeCode *type);
114 virtual OutputDataStreamPort* createOutputDataStreamPort(const std::string& name,
115 Node *node,TypeCode *type);
117 virtual DataNode* createInDataNode(const std::string& kind,const std::string& name);
118 virtual DataNode* createOutDataNode(const std::string& kind,const std::string& name);
119 virtual InlineFuncNode* createFuncNode(const std::string& kind,const std::string& name);
120 virtual InlineNode* createScriptNode(const std::string& kind,const std::string& name);
122 virtual ServiceNode* createRefNode(const std::string& kind,const std::string& name);
123 virtual ServiceNode* createCompoNode(const std::string& kind,const std::string& name);
124 virtual ServiceInlineNode *createSInlineNode(const std::string& kind, const std::string& name);
125 virtual ComponentInstance* createComponentInstance(const std::string& name,
126 const std::string& kind="");
127 virtual Container *createContainer(const std::string& kind="");
128 virtual WhileLoop* createWhileLoop(const std::string& name);
129 virtual ForLoop* createForLoop(const std::string& name);
130 virtual OptimizerLoop* createOptimizerLoop(const std::string& name,const std::string& algLib,
131 const std::string& factoryName,bool algInitOnFile,
132 const std::string& kind="", Proc * procForTypes = NULL);
133 virtual Bloc* createBloc(const std::string& name);
134 virtual Proc* createProc(const std::string& name);
136 virtual TypeCode * createInterfaceTc(const std::string& id, const std::string& name,
137 std::list<TypeCodeObjref *> ltc);
138 virtual TypeCode * createSequenceTc(const std::string& id, const std::string& name, TypeCode *content);
139 virtual TypeCodeStruct * createStructTc(const std::string& id, const std::string& name);
141 virtual InputPort* adapt(InputPort* source,
142 const std::string& impl,
143 TypeCode * type,bool init=false) throw (ConversionException);
145 virtual InputPort* adapt(InPropertyPort* source,
146 const std::string& impl,
147 TypeCode * type,bool init=false) throw (ConversionException);
149 virtual InputPort* adaptNeutral(InputPort* source,
150 const std::string& impl,
151 TypeCode * type,bool init) throw (ConversionException);
153 virtual InputPort* adapt(InputCorbaPort* source,
154 const std::string& impl,
155 TypeCode * type,bool init) throw (ConversionException);
157 virtual InputPort* adaptCorbaToCorba(InputCorbaPort* source,
158 TypeCode * type) throw (ConversionException);
160 virtual InputPort* adaptCorbaToNeutral(InputCorbaPort* source,
161 TypeCode * type) throw (ConversionException);
163 virtual InputPort* adaptCorbaToPython(InputCorbaPort* source,
164 TypeCode * type) throw (ConversionException);
166 virtual InputPort* adaptCorbaToCpp(InputCorbaPort* source,
167 TypeCode * type) throw (ConversionException);
169 virtual InputPort* adaptCorbaToXml(InputCorbaPort* source,
170 TypeCode * type) throw (ConversionException);
172 virtual InputPort* adapt(InputPyPort* source,
173 const std::string& impl,
174 TypeCode * type,bool init) throw (ConversionException);
176 virtual InputPort* adaptPythonToCorba(InputPyPort* source,
177 TypeCode * type) throw (ConversionException);
179 virtual InputPort* adaptPythonToNeutral(InputPyPort* source,
180 TypeCode * type) throw (ConversionException);
182 virtual InputPort* adaptPythonToPython(InputPyPort* source,
183 TypeCode * type,bool init) throw (ConversionException);
185 virtual InputPort* adaptPythonToXml(InputPyPort* source,
186 TypeCode * type) throw (ConversionException);
188 virtual InputPort* adaptPythonToCpp(InputPyPort* source,
189 TypeCode * type) throw (ConversionException);
191 virtual InputPort* adapt(InputCppPort* source,
192 const std::string& impl,
193 TypeCode * type,bool init) throw (ConversionException);
195 virtual InputPort* adaptCppToCorba(InputCppPort* source,
196 TypeCode * type) throw (ConversionException);
198 virtual InputPort* adaptCppToNeutral(InputCppPort* source,
199 TypeCode * type) throw (ConversionException);
201 virtual InputPort* adaptCppToPython(InputCppPort* source,
202 TypeCode * type) throw (ConversionException);
204 virtual InputPort* adaptCppToXml(InputCppPort* source,
205 TypeCode * type) throw (ConversionException);
207 virtual InputPort* adaptCppToCpp(InputCppPort* source,
208 TypeCode * type) throw (ConversionException);
210 virtual InputPort* adapt(InputXmlPort* source,
211 const std::string& impl,
212 TypeCode * type,bool init) throw (ConversionException);
214 virtual InputPort* adaptXmlToCorba(InputXmlPort* source,
215 TypeCode * type) throw (ConversionException);
217 virtual InputPort* adaptXmlToPython(InputXmlPort* inport,
218 TypeCode * type) throw (ConversionException);
220 virtual InputPort* adaptXmlToCpp(InputXmlPort* inport,
221 TypeCode * type) throw (ConversionException);
223 virtual InputPort* adaptXmlToNeutral(InputXmlPort* inport,
224 TypeCode * type) throw (ConversionException);
225 virtual InputPort* adaptXmlToXml(InputXmlPort* inport,
226 TypeCode * type,bool init) throw (ConversionException);
229 virtual InputPort* adaptNeutralToXml(InputPort* inport,
230 TypeCode * type) throw (ConversionException);
232 virtual InputPort* adaptNeutralToPython(InputPort* inport,
233 TypeCode * type) throw (ConversionException);
235 virtual InputPort* adaptNeutralToCorba(InputPort* inport,
236 TypeCode * type) throw (ConversionException);
238 virtual InputPort* adaptNeutralToCpp(InputPort* inport,
239 TypeCode * type) throw (ConversionException);
241 virtual void* convertNeutral(TypeCode * type, Any *data);
242 virtual std::string convertNeutralAsString(TypeCode * type, Any *data);
243 virtual std::string convertPyObjectToString(PyObject* ob);
244 virtual PyObject* convertStringToPyObject(const std::string& s);
246 virtual ~RuntimeSALOME();
248 CORBA::ORB_ptr getOrb() const;
249 PyObject * getPyOrb() const;
250 PyObject * getBuiltins() const;
251 DynamicAny::DynAnyFactory_ptr getDynFactory() const;
252 omniORBpyAPI* getApi();
253 PyObject * get_omnipy();
256 RuntimeSALOME(); // singleton
257 RuntimeSALOME(long flags, int argc, char* argv[]); // singleton
262 DynamicAny::DynAnyFactory_var _dynFactory;
266 bool _usePython, _useCorba, _useCpp, _useXml;