Version: 7.8.0
SALOME_ParallelContainer_i.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File : SALOME_ParallelContainer_i.hxx
23 // Author : André RIBES, EDF
24 
25 #ifndef _SALOME_PARALLEL_CONTAINER_I_HXX_
26 #define _SALOME_PARALLEL_CONTAINER_I_HXX_
27 
28 #include <SALOMEconfig.h>
29 
30 #include "SALOME_PACOExtensionPaCO_Engines_PACO_Container_server.hxx"
32 
33 #include <iostream>
34 #include <signal.h>
35 #include <stdlib.h>
36 #ifndef WIN32
37 #include <unistd.h>
38 #endif
39 #include <sys/types.h>
40 #include <omnithread.h>
41 #include <map>
42 #include <string>
43 
45 
46 #ifdef WIN32
47 # if defined CONTAINER_EXPORTS || defined SalomeParallelContainer_EXPORTS
48 # define CONTAINER_EXPORT __declspec( dllexport )
49 # else
50 # define CONTAINER_EXPORT __declspec( dllimport )
51 # endif
52 #else
53 # define CONTAINER_EXPORT
54 #endif
55 
57  virtual public Engines::PACO_Container_serv,
58  virtual public ParallelGlobalProcessVar_i,
59  virtual public PortableServer::RefCountServantBase
60 {
61 public:
62  Engines_Parallel_Container_i(CORBA::ORB_ptr orb,
63  char * ior,
64  int rank,
65  PortableServer::POA_ptr poa,
66  std::string containerName ,
67  bool isServantAloneInProcess = true);
68 
70 
71  // --- CORBA methods
72 
73  virtual bool load_component_Library(const char* componentName, CORBA::String_out reason);
74 
75  virtual Engines::EngineComponent_ptr
76  create_component_instance( const char* componentName,
77  CORBA::Long studyId); // 0 for multiStudy
78 
79  virtual Engines::EngineComponent_ptr
80  create_component_instance_env( const char* componentName,
81  CORBA::Long studyId, // 0 for multiStudy
82  const Engines::FieldsDict& env,
83  CORBA::String_out reason);
84 
85  virtual char*
86  create_python_service_instance(const char* CompName,
87  CORBA::String_out reason);
88 
89  Engines::EngineComponent_ptr
90  find_component_instance( const char* registeredName,
91  CORBA::Long studyId); // 0 for multiStudy
92 
93  Engines::EngineComponent_ptr
94  load_impl(const char* nameToRegister,
95  const char* componentName);
96 
97  void
98  create_paco_component_node_instance(const char* componentName,
99  const char* proxy_containerName,
100  CORBA::Long studyId); // 0 for multiStudy
101 
102  void updateInstanceNumber();
103 
104  void remove_impl(Engines::EngineComponent_ptr component_i);
105  void finalize_removal();
106 
107  virtual void ping();
108  char* name();
109  char* workingdir();
110  char* logfilename();
111  void logfilename(const char* name);
112 
113  virtual void Shutdown();
114  char* getHostName();
115  CORBA::Long getPID();
116 
118  bool Kill_impl() ;
119 
120  // --- local C++ methods
121  Engines::EngineComponent_ptr
122  find_or_create_instance(std::string genericRegisterName);
123 
124  Engines::EngineComponent_ptr
125  createCPPInstance(std::string genericRegisterName,
126  void *handle,
127  int studyId);
128 
129  Engines::EngineComponent_ptr
130  createPythonInstance(std::string genericRegisterName,
131  int studyId);
132 
133  static bool isPythonContainer(const char* ContainerName);
134  static void decInstanceCnt(std::string genericRegisterName);
135 
136  // --- needed for parallel components, Numerical Platon
137  void set_id(PortableServer::ObjectId * id) { _id = id;}
138 
139  Engines::fileRef_ptr createFileRef(const char* origFileName);
140  Engines::fileTransfer_ptr getFileTransfer();
141 
142  virtual Engines::Salome_file_ptr createSalome_file(const char* origFileName);
143  void copyFile(Engines::Container_ptr container, const char* remoteFile, const char* localFile);
144  Engines::PyNode_ptr createPyNode(const char* nodeName, const char* code);
145  Engines::PyNode_ptr getDefaultPyNode(const char *nodeName);
146  Engines::PyScriptNode_ptr createPyScriptNode(const char* nodeName, const char* code);
147  Engines::PyScriptNode_ptr getDefaultPyScriptNode(const char *nodeName);
148 protected:
149 
151  std::string _hostname;
152  std::string _library_path;
153  std::string _containerName;
154  std::string _logfilename;
155  CORBA::ORB_var _orb;
156  PortableServer::POA_var _poa;
157  PortableServer::ObjectId * _id;
159  CORBA::Long _pid;
161  Engines::fileTransfer_var _fileTransfer;
162 
163  typedef std::map<std::string,Engines::EngineComponent_var> _listInstances_map_t;
164  typedef std::map<std::string,Engines::fileRef_var> _fileRef_map_t;
165  typedef std::map<std::string,Engines::Salome_file_var> _Salome_file_map_t;
169 
170  // Cette map contient les references vers les différentes
171  // instances d'objets parallèles.
172  std::map<std::string, PortableServer::ObjectId *> _par_obj_inst_map;
173 
174  typedef PortableServer::ObjectId * (*FACTORY_FUNCTION) (CORBA::ORB_ptr, char *, int,
175  PortableServer::POA_ptr,
176  PortableServer::ObjectId *,
177  const char *,
178  const char *);
179 };
180 
181 #endif