1 // Copyright (C) 2006-2022 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_
24 #include "YACSRuntimeSALOMEExport.hxx"
25 #include "ConnectionManager.hxx"
26 // rnv: avoid compilation warning on Linux : "_POSIX_C_SOURCE" and "_XOPEN_SOURCE" are redefined
27 #ifdef _POSIX_C_SOURCE
28 #undef _POSIX_C_SOURCE
35 #include <omniORB4/CORBA.h>
36 #include <omniORBpy.h>
37 #include "Runtime.hxx"
43 class SALOME_NamingService_Container_Abstract;
51 YACSRUNTIMESALOME_EXPORT RuntimeSALOME* getSALOMERuntime();
58 class YACSRUNTIMESALOME_EXPORT RuntimeSALOME: public Runtime
60 static Runtime* getSingleton() { return Runtime::_singleton; }
75 std::unique_ptr<SALOME_NamingService_Container_Abstract> getNS();
78 static void setRuntime(long flags = UsePython+UseCorba+UseXml+UseCpp+UseSalome,
79 int argc = 0, char* argv[] = NULL);
81 friend RuntimeSALOME* getSALOMERuntime();
83 virtual std::string getVersion() const;
85 virtual void init(long flags, int argc, char* argv[]);
87 virtual std::vector< std::pair<std::string,int> > getCatalogOfComputeNodes() const;
88 virtual InputPort* createInputPort(const std::string& name,
89 const std::string& impl,
93 virtual OutputPort* createOutputPort(const std::string& name,
94 const std::string& impl,
97 virtual InputDataStreamPort* createInputDataStreamPort(const std::string& name,
98 Node *node,TypeCode *type);
100 virtual OutputDataStreamPort* createOutputDataStreamPort(const std::string& name,
101 Node *node,TypeCode *type);
103 virtual DataNode* createInDataNode(const std::string& kind,const std::string& name);
104 virtual DataNode* createOutDataNode(const std::string& kind,const std::string& name);
105 virtual InlineFuncNode* createFuncNode(const std::string& kind,const std::string& name);
106 virtual InlineNode* createScriptNode(const std::string& kind,const std::string& name);
108 virtual ServiceNode* createRefNode(const std::string& kind,const std::string& name);
109 virtual ServiceNode* createCompoNode(const std::string& kind,const std::string& name);
110 virtual ServiceInlineNode *createSInlineNode(const std::string& kind, const std::string& name);
111 virtual ComponentInstance* createComponentInstance(const std::string& name,
112 const std::string& kind="");
114 virtual Container *createContainer(const std::string& kind="");
116 virtual WhileLoop* createWhileLoop(const std::string& name);
117 virtual ForLoop* createForLoop(const std::string& name);
118 virtual OptimizerLoop* createOptimizerLoop(const std::string& name,const std::string& algLib,
119 const std::string& factoryName,bool algInitOnFile,
120 const std::string& kind="", Proc * procForTypes = NULL);
121 virtual Bloc* createBloc(const std::string& name);
122 virtual Proc* createProc(const std::string& name);
124 virtual TypeCode * createInterfaceTc(const std::string& id, const std::string& name,
125 std::list<TypeCodeObjref *> ltc);
126 virtual TypeCode * createSequenceTc(const std::string& id, const std::string& name, TypeCode *content);
127 virtual TypeCodeStruct * createStructTc(const std::string& id, const std::string& name);
129 virtual InputPort* adapt(InputPort* source,
130 const std::string& impl,
131 TypeCode * type,bool init=false);
133 virtual InputPort* adapt(InPropertyPort* source,
134 const std::string& impl,
135 TypeCode * type,bool init=false);
137 virtual InputPort* adaptNeutral(InputPort* source,
138 const std::string& impl,
139 TypeCode * type,bool init);
141 virtual InputPort* adapt(InputCorbaPort* source,
142 const std::string& impl,
143 TypeCode * type,bool init);
145 virtual InputPort* adaptCorbaToCorba(InputCorbaPort* source,
148 virtual InputPort* adaptCorbaToNeutral(InputCorbaPort* source,
151 virtual InputPort* adaptCorbaToPython(InputCorbaPort* source,
154 virtual InputPort* adaptCorbaToCpp(InputCorbaPort* source,
157 virtual InputPort* adaptCorbaToXml(InputCorbaPort* source,
160 virtual InputPort* adapt(InputPyPort* source,
161 const std::string& impl,
162 TypeCode * type,bool init);
164 virtual InputPort* adaptPythonToCorba(InputPyPort* source,
167 virtual InputPort* adaptPythonToNeutral(InputPyPort* source,
170 virtual InputPort* adaptPythonToPython(InputPyPort* source,
171 TypeCode * type,bool init);
173 virtual InputPort* adaptPythonToXml(InputPyPort* source,
176 virtual InputPort* adaptPythonToCpp(InputPyPort* source,
179 virtual InputPort* adapt(InputCppPort* source,
180 const std::string& impl,
181 TypeCode * type,bool init);
183 virtual InputPort* adaptCppToCorba(InputCppPort* source,
186 virtual InputPort* adaptCppToNeutral(InputCppPort* source,
189 virtual InputPort* adaptCppToPython(InputCppPort* source,
192 virtual InputPort* adaptCppToXml(InputCppPort* source,
195 virtual InputPort* adaptCppToCpp(InputCppPort* source,
198 virtual InputPort* adapt(InputXmlPort* source,
199 const std::string& impl,
200 TypeCode * type,bool init);
202 virtual InputPort* adaptXmlToCorba(InputXmlPort* source,
205 virtual InputPort* adaptXmlToPython(InputXmlPort* inport,
208 virtual InputPort* adaptXmlToCpp(InputXmlPort* inport,
211 virtual InputPort* adaptXmlToNeutral(InputXmlPort* inport,
213 virtual InputPort* adaptXmlToXml(InputXmlPort* inport,
214 TypeCode * type,bool init);
217 virtual InputPort* adaptNeutralToXml(InputPort* inport,
220 virtual InputPort* adaptNeutralToPython(InputPort* inport,
223 virtual InputPort* adaptNeutralToCorba(InputPort* inport,
226 virtual InputPort* adaptNeutralToCpp(InputPort* inport,
229 virtual void* convertNeutral(TypeCode * type, Any *data);
230 virtual std::string convertNeutralAsString(TypeCode * type, Any *data);
231 virtual std::string convertPyObjectToString(PyObject* ob);
232 virtual PyObject* convertStringToPyObject(const std::string& s);
234 virtual ~RuntimeSALOME();
236 void loadModulCatalog();
238 CORBA::ORB_ptr getOrb() const;
239 PyObject * getPyOrb() const;
240 PyObject * getBuiltins() const;
241 DynamicAny::DynAnyFactory_ptr getDynFactory() const;
242 omniORBpyAPI* getApi();
243 PyObject * get_omnipy();
244 ConnectionManager& getConnectionManager(){return _connectionManager;}
247 RuntimeSALOME(); // singleton
248 RuntimeSALOME(long flags, int argc, char* argv[]); // singleton
253 DynamicAny::DynAnyFactory_var _dynFactory;
257 bool _usePython, _useCorba, _useCpp, _useXml;
260 ConnectionManager _connectionManager;