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 <omniORBpy.h>
37 #include "Runtime.hxx"
48 YACSRUNTIMESALOME_EXPORT RuntimeSALOME* getSALOMERuntime();
55 class YACSRUNTIMESALOME_EXPORT RuntimeSALOME: public Runtime
57 static Runtime* getSingleton() { return Runtime::_singleton; }
72 static void setRuntime(long flags = UsePython+UseCorba+UseXml+UseCpp+UseSalome,
73 int argc = 0, char* argv[] = NULL);
75 friend RuntimeSALOME* getSALOMERuntime();
77 virtual std::string getVersion() const;
79 virtual void init(long flags, int argc, char* argv[]);
82 virtual InputPort* createInputPort(const std::string& name,
83 const std::string& impl,
87 virtual OutputPort* createOutputPort(const std::string& name,
88 const std::string& impl,
91 virtual InputDataStreamPort* createInputDataStreamPort(const std::string& name,
92 Node *node,TypeCode *type);
94 virtual OutputDataStreamPort* createOutputDataStreamPort(const std::string& name,
95 Node *node,TypeCode *type);
97 virtual DataNode* createInDataNode(const std::string& kind,const std::string& name);
98 virtual DataNode* createOutDataNode(const std::string& kind,const std::string& name);
99 virtual InlineFuncNode* createFuncNode(const std::string& kind,const std::string& name);
100 virtual InlineNode* createScriptNode(const std::string& kind,const std::string& name);
102 virtual ServiceNode* createRefNode(const std::string& kind,const std::string& name);
103 virtual ServiceNode* createCompoNode(const std::string& kind,const std::string& name);
104 virtual ServiceInlineNode *createSInlineNode(const std::string& kind, const std::string& name);
105 virtual ComponentInstance* createComponentInstance(const std::string& name,
106 const std::string& kind="");
107 virtual Container *createContainer(const std::string& kind="");
108 virtual WhileLoop* createWhileLoop(const std::string& name);
109 virtual ForLoop* createForLoop(const std::string& name);
110 virtual OptimizerLoop* createOptimizerLoop(const std::string& name,const std::string& algLib,
111 const std::string& factoryName,bool algInitOnFile,
112 const std::string& kind="", Proc * procForTypes = NULL);
113 virtual Bloc* createBloc(const std::string& name);
114 virtual Proc* createProc(const std::string& name);
116 virtual TypeCode * createInterfaceTc(const std::string& id, const std::string& name,
117 std::list<TypeCodeObjref *> ltc);
118 virtual TypeCode * createSequenceTc(const std::string& id, const std::string& name, TypeCode *content);
119 virtual TypeCodeStruct * createStructTc(const std::string& id, const std::string& name);
121 virtual InputPort* adapt(InputPort* source,
122 const std::string& impl,
123 TypeCode * type,bool init=false) throw (ConversionException);
125 virtual InputPort* adapt(InPropertyPort* source,
126 const std::string& impl,
127 TypeCode * type,bool init=false) throw (ConversionException);
129 virtual InputPort* adaptNeutral(InputPort* source,
130 const std::string& impl,
131 TypeCode * type,bool init) throw (ConversionException);
133 virtual InputPort* adapt(InputCorbaPort* source,
134 const std::string& impl,
135 TypeCode * type,bool init) throw (ConversionException);
137 virtual InputPort* adaptCorbaToCorba(InputCorbaPort* source,
138 TypeCode * type) throw (ConversionException);
140 virtual InputPort* adaptCorbaToNeutral(InputCorbaPort* source,
141 TypeCode * type) throw (ConversionException);
143 virtual InputPort* adaptCorbaToPython(InputCorbaPort* source,
144 TypeCode * type) throw (ConversionException);
146 virtual InputPort* adaptCorbaToCpp(InputCorbaPort* source,
147 TypeCode * type) throw (ConversionException);
149 virtual InputPort* adaptCorbaToXml(InputCorbaPort* source,
150 TypeCode * type) throw (ConversionException);
152 virtual InputPort* adapt(InputPyPort* source,
153 const std::string& impl,
154 TypeCode * type,bool init) throw (ConversionException);
156 virtual InputPort* adaptPythonToCorba(InputPyPort* source,
157 TypeCode * type) throw (ConversionException);
159 virtual InputPort* adaptPythonToNeutral(InputPyPort* source,
160 TypeCode * type) throw (ConversionException);
162 virtual InputPort* adaptPythonToPython(InputPyPort* source,
163 TypeCode * type,bool init) throw (ConversionException);
165 virtual InputPort* adaptPythonToXml(InputPyPort* source,
166 TypeCode * type) throw (ConversionException);
168 virtual InputPort* adaptPythonToCpp(InputPyPort* source,
169 TypeCode * type) throw (ConversionException);
171 virtual InputPort* adapt(InputCppPort* source,
172 const std::string& impl,
173 TypeCode * type,bool init) throw (ConversionException);
175 virtual InputPort* adaptCppToCorba(InputCppPort* source,
176 TypeCode * type) throw (ConversionException);
178 virtual InputPort* adaptCppToNeutral(InputCppPort* source,
179 TypeCode * type) throw (ConversionException);
181 virtual InputPort* adaptCppToPython(InputCppPort* source,
182 TypeCode * type) throw (ConversionException);
184 virtual InputPort* adaptCppToXml(InputCppPort* source,
185 TypeCode * type) throw (ConversionException);
187 virtual InputPort* adaptCppToCpp(InputCppPort* source,
188 TypeCode * type) throw (ConversionException);
190 virtual InputPort* adapt(InputXmlPort* source,
191 const std::string& impl,
192 TypeCode * type,bool init) throw (ConversionException);
194 virtual InputPort* adaptXmlToCorba(InputXmlPort* source,
195 TypeCode * type) throw (ConversionException);
197 virtual InputPort* adaptXmlToPython(InputXmlPort* inport,
198 TypeCode * type) throw (ConversionException);
200 virtual InputPort* adaptXmlToCpp(InputXmlPort* inport,
201 TypeCode * type) throw (ConversionException);
203 virtual InputPort* adaptXmlToNeutral(InputXmlPort* inport,
204 TypeCode * type) throw (ConversionException);
205 virtual InputPort* adaptXmlToXml(InputXmlPort* inport,
206 TypeCode * type,bool init) throw (ConversionException);
209 virtual InputPort* adaptNeutralToXml(InputPort* inport,
210 TypeCode * type) throw (ConversionException);
212 virtual InputPort* adaptNeutralToPython(InputPort* inport,
213 TypeCode * type) throw (ConversionException);
215 virtual InputPort* adaptNeutralToCorba(InputPort* inport,
216 TypeCode * type) throw (ConversionException);
218 virtual InputPort* adaptNeutralToCpp(InputPort* inport,
219 TypeCode * type) throw (ConversionException);
221 virtual void* convertNeutral(TypeCode * type, Any *data);
222 virtual std::string convertNeutralAsString(TypeCode * type, Any *data);
223 virtual std::string convertPyObjectToString(PyObject* ob);
224 virtual PyObject* convertStringToPyObject(const std::string& s);
226 virtual ~RuntimeSALOME();
228 CORBA::ORB_ptr getOrb();
229 PyObject * getPyOrb();
230 PyObject * getBuiltins();
231 DynamicAny::DynAnyFactory_ptr getDynFactory();
232 omniORBpyAPI* getApi();
233 PyObject * get_omnipy();
236 RuntimeSALOME(); // singleton
237 RuntimeSALOME(long flags, int argc, char* argv[]); // singleton
242 DynamicAny::DynAnyFactory_var _dynFactory;
246 bool _usePython, _useCorba, _useCpp, _useXml;