1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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 // File : SALOME_ParallelContainer_i.hxx
23 // Author : André RIBES, EDF
25 #ifndef _SALOME_PARALLEL_CONTAINER_I_HXX_
26 #define _SALOME_PARALLEL_CONTAINER_I_HXX_
28 #include <SALOMEconfig.h>
30 #include "SALOME_PACOExtensionPaCO_Engines_PACO_Container_server.hxx"
31 #include "SALOME_ParallelGlobalProcessVar_i.hxx"
39 #include <sys/types.h>
40 #include <omnithread.h>
44 class SALOME_NamingService;
47 # if defined CONTAINER_EXPORTS || defined SalomeParallelContainer_EXPORTS
48 # define CONTAINER_EXPORT __declspec( dllexport )
50 # define CONTAINER_EXPORT __declspec( dllimport )
53 # define CONTAINER_EXPORT
56 class CONTAINER_EXPORT Engines_Parallel_Container_i:
57 virtual public Engines::PACO_Container_serv,
58 virtual public ParallelGlobalProcessVar_i,
59 virtual public PortableServer::RefCountServantBase
62 Engines_Parallel_Container_i(CORBA::ORB_ptr orb,
65 PortableServer::POA_ptr poa,
66 std::string containerName ,
67 bool isServantAloneInProcess = true);
69 virtual ~Engines_Parallel_Container_i();
73 virtual bool load_component_Library(const char* componentName, CORBA::String_out reason);
75 virtual Engines::EngineComponent_ptr
76 create_component_instance( const char* componentName,
77 CORBA::Long studyId); // 0 for multiStudy
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);
85 Engines::EngineComponent_ptr
86 find_component_instance( const char* registeredName,
87 CORBA::Long studyId); // 0 for multiStudy
89 Engines::EngineComponent_ptr
90 load_impl(const char* nameToRegister,
91 const char* componentName);
94 create_paco_component_node_instance(const char* componentName,
95 const char* proxy_containerName,
96 CORBA::Long studyId); // 0 for multiStudy
98 void updateInstanceNumber();
100 void remove_impl(Engines::EngineComponent_ptr component_i);
101 void finalize_removal();
107 void logfilename(const char* name);
109 virtual void Shutdown();
111 CORBA::Long getPID();
113 //! Kill current container
116 // --- local C++ methods
117 Engines::EngineComponent_ptr
118 find_or_create_instance(std::string genericRegisterName);
120 Engines::EngineComponent_ptr
121 createCPPInstance(std::string genericRegisterName,
125 Engines::EngineComponent_ptr
126 createPythonInstance(std::string genericRegisterName,
129 static bool isPythonContainer(const char* ContainerName);
130 static void decInstanceCnt(std::string genericRegisterName);
132 // --- needed for parallel components, Numerical Platon
133 void set_id(PortableServer::ObjectId * id) { _id = id;}
135 Engines::fileRef_ptr createFileRef(const char* origFileName);
136 Engines::fileTransfer_ptr getFileTransfer();
138 virtual Engines::Salome_file_ptr createSalome_file(const char* origFileName);
139 void copyFile(Engines::Container_ptr container, const char* remoteFile, const char* localFile);
140 Engines::PyNode_ptr createPyNode(const char* nodeName, const char* code);
141 Engines::PyNode_ptr getDefaultPyNode();
142 Engines::PyScriptNode_ptr createPyScriptNode(const char* nodeName, const char* code);
143 Engines::PyScriptNode_ptr getDefaultPyScriptNode();
146 SALOME_NamingService *_NS;
147 std::string _hostname;
148 std::string _library_path;
149 std::string _containerName;
150 std::string _logfilename;
152 PortableServer::POA_var _poa;
153 PortableServer::ObjectId * _id;
156 bool _isServantAloneInProcess;
157 Engines::fileTransfer_var _fileTransfer;
159 typedef std::map<std::string,Engines::EngineComponent_var> _listInstances_map_t;
160 typedef std::map<std::string,Engines::fileRef_var> _fileRef_map_t;
161 typedef std::map<std::string,Engines::Salome_file_var> _Salome_file_map_t;
162 _listInstances_map_t _listInstances_map;
163 _fileRef_map_t _fileRef_map;
164 _Salome_file_map_t _Salome_file_map;
166 // Cette map contient les references vers les différentes
167 // instances d'objets parallèles.
168 std::map<std::string, PortableServer::ObjectId *> _par_obj_inst_map;
170 typedef PortableServer::ObjectId * (*FACTORY_FUNCTION) (CORBA::ORB_ptr, char *, int,
171 PortableServer::POA_ptr,
172 PortableServer::ObjectId *,