1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SALOME_ParallelContainer : implementation of container and engine for Parallel Kernel
23 // File : SALOME_ParallelContainer_i.hxx
24 // Author : André RIBES, EDF
26 #ifndef _SALOME_PARALLEL_CONTAINER_I_HXX_
27 #define _SALOME_PARALLEL_CONTAINER_I_HXX_
29 #include <SALOMEconfig.h>
31 #include "SALOME_PACOExtensionPaCO_Engines_PACO_Container_server.hxx"
32 #include "SALOME_ParallelGlobalProcessVar_i.hxx"
40 #include <sys/types.h>
41 #include <omnithread.h>
45 class SALOME_NamingService;
48 # if defined CONTAINER_EXPORTS || defined SalomeParallelContainer_EXPORTS
49 # define CONTAINER_EXPORT __declspec( dllexport )
51 # define CONTAINER_EXPORT __declspec( dllimport )
54 # define CONTAINER_EXPORT
57 class CONTAINER_EXPORT Engines_Parallel_Container_i:
58 virtual public Engines::PACO_Container_serv,
59 virtual public ParallelGlobalProcessVar_i,
60 virtual public PortableServer::RefCountServantBase
63 Engines_Parallel_Container_i(CORBA::ORB_ptr orb,
66 PortableServer::POA_ptr poa,
67 std::string containerName ,
68 bool isServantAloneInProcess = true);
70 virtual ~Engines_Parallel_Container_i();
74 virtual bool load_component_Library(const char* componentName);
76 virtual Engines::Component_ptr
77 create_component_instance( const char* componentName,
78 CORBA::Long studyId); // 0 for multiStudy
80 Engines::Component_ptr
81 find_component_instance( const char* registeredName,
82 CORBA::Long studyId); // 0 for multiStudy
84 Engines::Component_ptr
85 load_impl(const char* nameToRegister,
86 const char* componentName);
89 create_paco_component_node_instance(const char* componentName,
90 const char* proxy_containerName,
91 CORBA::Long studyId); // 0 for multiStudy
93 void updateInstanceNumber();
95 void remove_impl(Engines::Component_ptr component_i);
96 void finalize_removal();
102 void logfilename(const char* name);
104 virtual void Shutdown();
106 CORBA::Long getPID();
108 //! Kill current container
111 // --- local C++ methods
112 Engines::Component_ptr
113 find_or_create_instance(std::string genericRegisterName);
115 Engines::Component_ptr
116 createCPPInstance(std::string genericRegisterName,
120 Engines::Component_ptr
121 createPythonInstance(std::string genericRegisterName,
124 static bool isPythonContainer(const char* ContainerName);
125 static void decInstanceCnt(std::string genericRegisterName);
127 // --- needed for parallel components, Numerical Platon
128 void set_id(PortableServer::ObjectId * id) { _id = id;}
130 Engines::fileRef_ptr createFileRef(const char* origFileName);
131 Engines::fileTransfer_ptr getFileTransfer();
133 virtual Engines::Salome_file_ptr createSalome_file(const char* origFileName);
134 void copyFile(Engines::Container_ptr container, const char* remoteFile, const char* localFile);
138 SALOME_NamingService *_NS;
139 std::string _hostname;
140 std::string _library_path;
141 std::string _containerName;
142 std::string _logfilename;
144 PortableServer::POA_var _poa;
145 PortableServer::ObjectId * _id;
148 bool _isServantAloneInProcess;
149 Engines::fileTransfer_var _fileTransfer;
151 typedef std::map<std::string,Engines::Component_var> _listInstances_map_t;
152 typedef std::map<std::string,Engines::fileRef_var> _fileRef_map_t;
153 typedef std::map<std::string,Engines::Salome_file_var> _Salome_file_map_t;
154 _listInstances_map_t _listInstances_map;
155 _fileRef_map_t _fileRef_map;
156 _Salome_file_map_t _Salome_file_map;
158 // Cette map contient les references vers les différentes
159 // instances d'objets parallèles.
160 std::map<std::string, PortableServer::ObjectId *> _par_obj_inst_map;
162 typedef PortableServer::ObjectId * (*FACTORY_FUNCTION) (CORBA::ORB_ptr, char *, int,
163 PortableServer::POA_ptr,
164 PortableServer::ObjectId *,