1 // Copyright (C) 2006-2024 CEA, EDF
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[]);
86 virtual void fini(bool isFinalizingPython = true);
87 PyObject *launchSubProcess(const std::vector<std::string>& cmds);
88 virtual std::vector< std::pair<std::string,int> > getCatalogOfComputeNodes() const;
89 virtual InputPort* createInputPort(const std::string& name,
90 const std::string& impl,
94 virtual OutputPort* createOutputPort(const std::string& name,
95 const std::string& impl,
98 virtual InputDataStreamPort* createInputDataStreamPort(const std::string& name,
99 Node *node,TypeCode *type);
101 virtual OutputDataStreamPort* createOutputDataStreamPort(const std::string& name,
102 Node *node,TypeCode *type);
104 virtual DataNode* createInDataNode(const std::string& kind,const std::string& name);
105 virtual DataNode* createOutDataNode(const std::string& kind,const std::string& name);
106 virtual InlineFuncNode* createFuncNode(const std::string& kind,const std::string& name);
107 virtual InlineNode* createScriptNode(const std::string& kind,const std::string& name);
109 virtual ServiceNode* createRefNode(const std::string& kind,const std::string& name);
110 virtual ServiceNode* createCompoNode(const std::string& kind,const std::string& name);
111 virtual ServiceInlineNode *createSInlineNode(const std::string& kind, const std::string& name);
112 virtual ComponentInstance* createComponentInstance(const std::string& name,
113 const std::string& kind="");
115 virtual Container *createContainer(const std::string& kind="");
117 virtual WhileLoop* createWhileLoop(const std::string& name);
118 virtual ForLoop* createForLoop(const std::string& name);
119 virtual OptimizerLoop* createOptimizerLoop(const std::string& name,const std::string& algLib,
120 const std::string& factoryName,bool algInitOnFile,
121 const std::string& kind="", Proc * procForTypes = NULL);
122 virtual Bloc* createBloc(const std::string& name);
123 virtual Proc* createProc(const std::string& name);
125 virtual TypeCode * createInterfaceTc(const std::string& id, const std::string& name,
126 std::list<TypeCodeObjref *> ltc);
127 virtual TypeCode * createSequenceTc(const std::string& id, const std::string& name, TypeCode *content);
128 virtual TypeCodeStruct * createStructTc(const std::string& id, const std::string& name);
130 virtual InputPort* adapt(InputPort* source,
131 const std::string& impl,
132 TypeCode * type,bool init=false);
134 virtual InputPort* adapt(InPropertyPort* source,
135 const std::string& impl,
136 TypeCode * type,bool init=false);
138 virtual InputPort* adaptNeutral(InputPort* source,
139 const std::string& impl,
140 TypeCode * type,bool init);
142 virtual InputPort* adapt(InputCorbaPort* source,
143 const std::string& impl,
144 TypeCode * type,bool init);
146 virtual InputPort* adaptCorbaToCorba(InputCorbaPort* source,
149 virtual InputPort* adaptCorbaToNeutral(InputCorbaPort* source,
152 virtual InputPort* adaptCorbaToPython(InputCorbaPort* source,
155 virtual InputPort* adaptCorbaToCpp(InputCorbaPort* source,
158 virtual InputPort* adaptCorbaToXml(InputCorbaPort* source,
161 virtual InputPort* adapt(InputPyPort* source,
162 const std::string& impl,
163 TypeCode * type,bool init);
165 virtual InputPort* adaptPythonToCorba(InputPyPort* source,
168 virtual InputPort* adaptPythonToNeutral(InputPyPort* source,
171 virtual InputPort* adaptPythonToPython(InputPyPort* source,
172 TypeCode * type,bool init);
174 virtual InputPort* adaptPythonToXml(InputPyPort* source,
177 virtual InputPort* adaptPythonToCpp(InputPyPort* source,
180 virtual InputPort* adapt(InputCppPort* source,
181 const std::string& impl,
182 TypeCode * type,bool init);
184 virtual InputPort* adaptCppToCorba(InputCppPort* source,
187 virtual InputPort* adaptCppToNeutral(InputCppPort* source,
190 virtual InputPort* adaptCppToPython(InputCppPort* source,
193 virtual InputPort* adaptCppToXml(InputCppPort* source,
196 virtual InputPort* adaptCppToCpp(InputCppPort* source,
199 virtual InputPort* adapt(InputXmlPort* source,
200 const std::string& impl,
201 TypeCode * type,bool init);
203 virtual InputPort* adaptXmlToCorba(InputXmlPort* source,
206 virtual InputPort* adaptXmlToPython(InputXmlPort* inport,
209 virtual InputPort* adaptXmlToCpp(InputXmlPort* inport,
212 virtual InputPort* adaptXmlToNeutral(InputXmlPort* inport,
214 virtual InputPort* adaptXmlToXml(InputXmlPort* inport,
215 TypeCode * type,bool init);
218 virtual InputPort* adaptNeutralToXml(InputPort* inport,
221 virtual InputPort* adaptNeutralToPython(InputPort* inport,
224 virtual InputPort* adaptNeutralToCorba(InputPort* inport,
227 virtual InputPort* adaptNeutralToCpp(InputPort* inport,
230 virtual void* convertNeutral(TypeCode * type, Any *data);
231 virtual std::string convertNeutralAsString(TypeCode * type, Any *data);
232 virtual std::string convertPyObjectToString(PyObject* ob);
233 virtual PyObject* convertStringToPyObject(const std::string& s);
235 virtual ~RuntimeSALOME();
237 void loadModulCatalog();
239 CORBA::ORB_ptr getOrb() const;
240 CORBA::Object_var getFromNS(const char *entry) const;
241 PyObject * getPyOrb() const;
242 PyObject * getBuiltins() const;
243 DynamicAny::DynAnyFactory_ptr getDynFactory() const;
244 omniORBpyAPI* getApi();
245 PyObject * get_omnipy();
246 ConnectionManager& getConnectionManager(){return _connectionManager;}
249 RuntimeSALOME(); // singleton
250 RuntimeSALOME(long flags, int argc, char* argv[]); // singleton
255 DynamicAny::DynAnyFactory_var _dynFactory;
259 bool _usePython, _useCorba, _useCpp, _useXml;
262 ConnectionManager _connectionManager;