Version: 9.15.0
RuntimeSALOME.hxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2025 CEA, EDF
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef _RUNTIMESALOME_HXX_
21 #define _RUNTIMESALOME_HXX_
22 #include <Python.h>
23 
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
29 #endif
30 
31 #ifdef _XOPEN_SOURCE
32 #undef _XOPEN_SOURCE
33 #endif
34 
35 #include <omniORB4/CORBA.h>
36 #include <omniORBpy.h>
37 #include "Runtime.hxx"
38 
39 #include <memory>
40 #include <string>
41 #include <set>
42 
43 class SALOME_NamingService_Container_Abstract;
44 
45 namespace YACS
46 {
47  namespace ENGINE
48  {
49 
50  class RuntimeSALOME;
52 
53  class InputCorbaPort;
54  class InputPyPort;
55  class InputXmlPort;
56  class InputCppPort;
57 
59  {
61 
62  public:
63 
64  enum
65  {
66  IsPyExt = 1,
67  UsePython = 2,
68  UseCorba = 4,
69  UseXml = 8,
70  UseCpp = 16,
71  UseSalome = 32
72  } FLAGS;
73 
74 #ifndef SWIG
75  std::unique_ptr<SALOME_NamingService_Container_Abstract> getNS();
76 #endif
77  // singleton creation
78  static void setRuntime(long flags = UsePython+UseCorba+UseXml+UseCpp+UseSalome,
79  int argc = 0, char* argv[] = NULL);
80 
82 
83  virtual std::string getVersion() const;
84 
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,
91  Node * node,
92  TypeCode * type);
93 
94  virtual OutputPort* createOutputPort(const std::string& name,
95  const std::string& impl,
96  Node * node,
97  TypeCode * type);
98  virtual InputDataStreamPort* createInputDataStreamPort(const std::string& name,
99  Node *node,TypeCode *type);
100 
101  virtual OutputDataStreamPort* createOutputDataStreamPort(const std::string& name,
102  Node *node,TypeCode *type);
103 
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);
108 
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="");
114 #ifndef SWIG
115  virtual Container *createContainer(const std::string& kind="");
116 #endif
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);
124 
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);
129 
130  virtual InputPort* adapt(InputPort* source,
131  const std::string& impl,
132  TypeCode * type,bool init=false);
133 
134  virtual InputPort* adapt(InPropertyPort* source,
135  const std::string& impl,
136  TypeCode * type,bool init=false);
137 
138  virtual InputPort* adaptNeutral(InputPort* source,
139  const std::string& impl,
140  TypeCode * type,bool init);
141 
142  virtual InputPort* adapt(InputCorbaPort* source,
143  const std::string& impl,
144  TypeCode * type,bool init);
145 
146  virtual InputPort* adaptCorbaToCorba(InputCorbaPort* source,
147  TypeCode * type);
148 
149  virtual InputPort* adaptCorbaToNeutral(InputCorbaPort* source,
150  TypeCode * type);
151 
152  virtual InputPort* adaptCorbaToPython(InputCorbaPort* source,
153  TypeCode * type);
154 
155  virtual InputPort* adaptCorbaToCpp(InputCorbaPort* source,
156  TypeCode * type);
157 
158  virtual InputPort* adaptCorbaToXml(InputCorbaPort* source,
159  TypeCode * type);
160 
161  virtual InputPort* adapt(InputPyPort* source,
162  const std::string& impl,
163  TypeCode * type,bool init);
164 
165  virtual InputPort* adaptPythonToCorba(InputPyPort* source,
166  TypeCode * type);
167 
168  virtual InputPort* adaptPythonToNeutral(InputPyPort* source,
169  TypeCode * type);
170 
171  virtual InputPort* adaptPythonToPython(InputPyPort* source,
172  TypeCode * type,bool init);
173 
174  virtual InputPort* adaptPythonToXml(InputPyPort* source,
175  TypeCode * type);
176 
177  virtual InputPort* adaptPythonToCpp(InputPyPort* source,
178  TypeCode * type);
179 
180  virtual InputPort* adapt(InputCppPort* source,
181  const std::string& impl,
182  TypeCode * type,bool init);
183 
184  virtual InputPort* adaptCppToCorba(InputCppPort* source,
185  TypeCode * type);
186 
187  virtual InputPort* adaptCppToNeutral(InputCppPort* source,
188  TypeCode * type);
189 
190  virtual InputPort* adaptCppToPython(InputCppPort* source,
191  TypeCode * type);
192 
193  virtual InputPort* adaptCppToXml(InputCppPort* source,
194  TypeCode * type);
195 
196  virtual InputPort* adaptCppToCpp(InputCppPort* source,
197  TypeCode * type);
198 
199  virtual InputPort* adapt(InputXmlPort* source,
200  const std::string& impl,
201  TypeCode * type,bool init);
202 
203  virtual InputPort* adaptXmlToCorba(InputXmlPort* source,
204  TypeCode * type);
205 
206  virtual InputPort* adaptXmlToPython(InputXmlPort* inport,
207  TypeCode * type);
208 
209  virtual InputPort* adaptXmlToCpp(InputXmlPort* inport,
210  TypeCode * type);
211 
212  virtual InputPort* adaptXmlToNeutral(InputXmlPort* inport,
213  TypeCode * type);
214  virtual InputPort* adaptXmlToXml(InputXmlPort* inport,
215  TypeCode * type,bool init);
216 
217 
218  virtual InputPort* adaptNeutralToXml(InputPort* inport,
219  TypeCode * type);
220 
221  virtual InputPort* adaptNeutralToPython(InputPort* inport,
222  TypeCode * type);
223 
224  virtual InputPort* adaptNeutralToCorba(InputPort* inport,
225  TypeCode * type);
226 
227  virtual InputPort* adaptNeutralToCpp(InputPort* inport,
228  TypeCode * type);
229 
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);
234 
235  virtual ~RuntimeSALOME();
236 
237  void loadModulCatalog();
238 
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;}
247 
248  protected:
249  RuntimeSALOME(); // singleton
250  RuntimeSALOME(long flags, int argc, char* argv[]); // singleton
251  void initBuiltins();
252  CORBA::ORB_var _orb;
253  PyObject * _pyorb;
254  PyObject * _bltins;
255  DynamicAny::DynAnyFactory_var _dynFactory;
256  omniORBpyAPI* _api;
257  PyObject* _omnipy;
258  long _flags;
259  bool _usePython, _useCorba, _useCpp, _useXml;
260 
261  private:
263  };
264  }
265 }
266 
267 #endif
#define YACSRUNTIMESALOME_EXPORT
This class implements the interface Engines::ConnectionManager. It is used to make connections betwee...
: Interface for management of storage of data formated dynamically in its TypeCode....
Definition: Any.hxx:79
Composed node to group elementary and composed nodes.
Definition: Bloc.hxx:36
Base class for all component instances.
Class for data parameters specification.
Definition: DataNode.hxx:38
Class for for loop node.
Definition: ForLoop.hxx:33
class for Input Property Ports
Class for calculation node (function) inlined (and executed) in the schema.
Definition: InlineNode.hxx:93
Class for calculation node (script) inlined (and executed) in the schema.
Definition: InlineNode.hxx:44
Class for CORBA Input Ports.
Definition: CORBAPorts.hxx:45
Class for C++ Ports.
Definition: CppPorts.hxx:40
Base class for Input Ports.
Definition: InputPort.hxx:44
Class for Python Ports.
Definition: PythonPorts.hxx:74
Class for XML Input Ports.
Definition: XMLPorts.hxx:38
Base class for all nodes.
Definition: Node.hxx:70
class to build optimization loops
Base class for all schema objects.
Definition: Proc.hxx:44
DynamicAny::DynAnyFactory_var _dynFactory
static Runtime * getSingleton()
ConnectionManager & getConnectionManager()
friend RuntimeSALOME * getSALOMERuntime()
ConnectionManager _connectionManager
static Runtime * _singleton
Definition: Runtime.hxx:150
Class for calculation node associated with a component service.
Definition: ServiceNode.hxx:35
Class for struct type.
Definition: TypeCode.hxx:228
Base class for all type objects.
Definition: TypeCode.hxx:68
Class for a while loop.
Definition: WhileLoop.hxx:39
std::string convertPyObjectToString(PyObject *ob)
YACSRUNTIMESALOME_EXPORT RuntimeSALOME * getSALOMERuntime()
def adapt(obj, protocol, alternate=AdaptationError)
Definition: adapt.py:45