1 // Copyright (C) 2007-2010 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
23 // SALOME_ParallelComponent : implementation of container and engine for Parallel Kernel
24 // File : SALOME_ParallelComponent_i.hxx
25 // Author : André RIBES, EDF
26 // Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
28 #ifndef _SALOME_PARALLEL_COMPONENT_I_HXX_
29 #define _SALOME_PARALLEL_COMPONENT_I_HXX_
37 #include <sys/types.h>
40 #include <SALOMEconfig.h>
42 #include "SALOME_PACOExtensionPaCO_Engines_Parallel_Component_server.hxx"
44 #include "NOTIFICATION.hxx"
45 #include "RegistryConnexion.hxx"
46 #include "Parallel_Salome_file_i.hxx"
48 class Engines_Parallel_Container_i;
51 # if defined CONTAINER_EXPORTS || defined SalomeParallelContainer_EXPORTS
52 # define CONTAINER_EXPORT __declspec( dllexport )
54 # define CONTAINER_EXPORT __declspec( dllimport )
57 # define CONTAINER_EXPORT
60 class CONTAINER_EXPORT Engines_Parallel_Component_i:
61 public virtual Engines::Parallel_Component_serv,
62 public virtual PortableServer::RefCountServantBase
65 Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, int rank,
66 PortableServer::POA_ptr poa,
67 PortableServer::ObjectId * contId,
68 const char *instanceName,
69 const char *interfaceName,
73 virtual ~Engines_Parallel_Component_i();
78 char* interfaceName();
83 CORBA::Long getStudyId();
84 Engines::Container_ptr GetContainerRef();
86 void setProperties(const Engines::FieldsDict& dico);
87 Engines::FieldsDict* getProperties();
89 void Names( const char * graphName , const char * nodeName ) ;
94 CORBA::Long CpuUsed_impl() ;
96 virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
97 CORBA::Boolean isPublished,
98 CORBA::Boolean& isValidScript);
100 // CORBA operations for Salome_file
101 virtual Engines::Salome_file_ptr getInputFileToService(const char* service_name,
102 const char* Salome_file_name);
103 virtual Engines::Salome_file_ptr getOutputFileToService(const char* service_name,
104 const char* Salome_file_name);
106 virtual void checkInputFilesToService(const char* service_name);
107 virtual Engines::Salome_file_ptr setInputFileToService(const char* service_name,
108 const char* Salome_file_name);
110 virtual void checkOutputFilesToService(const char* service_name);
111 virtual Engines::Salome_file_ptr setOutputFileToService(const char* service_name,
112 const char* Salome_file_name);
114 void send_parallel_proxy_object(CORBA::Object_ptr proxy_ref);
116 // Object information
117 virtual bool hasObjectInfo() { return false; }
118 virtual char* getObjectInfo(CORBA::Long studyId, const char* entry) { return ""; }
120 // --- local C++ methods
122 PortableServer::ObjectId * getId();
123 Engines_Parallel_Container_i *GetContainerPtr();
125 bool setStudyId(CORBA::Long studyId);
126 static bool isMultiStudy();
127 static bool isMultiInstance();
128 static std::string GetDynLibraryName(const char *componentName);
130 void beginService(const char *serviceName);
131 void endService(const char *serviceName);
132 void sendMessage(const char *event_type, const char *message);
135 bool Killer( pthread_t ThreadId , int signum );
140 void wait_parallel_object_proxy();
141 char * get_parallel_proxy_object();
143 virtual void configureSalome_file(std::string service_name,
144 std::string file_port_name,
145 Engines::Parallel_Salome_file_proxy_impl * file);
148 int _studyId; // -1: not initialised; 0: multiStudy; >0: study
149 static bool _isMultiStudy;
150 static bool _isMultiInstance;
152 std::string _instanceName ;
153 std::string _interfaceName ;
156 PortableServer::POA_var _poa;
157 PortableServer::ObjectId * _id;
158 PortableServer::ObjectId * _contId;
159 Engines_Parallel_Component_i * _thisObj ;
160 RegistryConnexion *_myConnexionToRegistry;
161 NOTIFICATION_Supplier* _notifSupplier;
162 std::map<std::string,CORBA::Any>_fieldsDict;
164 // Map Salome_file_name to Parallel_Salome_file*
165 typedef std::map<std::string, Parallel_Salome_file_i*> _t_Salome_file_map;
166 typedef std::map<std::string, Engines::Parallel_Salome_file_proxy_impl*> _t_Proxy_Salome_file_map;
167 typedef std::map<std::string, std::string> _t_IOR_Proxy_Salome_file_map;
169 // Map Service_name to _Salome_file_map
170 typedef std::map<std::string, Engines_Parallel_Component_i::_t_Salome_file_map*> _t_Service_file_map;
171 typedef std::map<std::string, Engines_Parallel_Component_i::_t_Proxy_Salome_file_map*> _t_Proxy_Service_file_map;
172 typedef std::map<std::string, Engines_Parallel_Component_i::_t_IOR_Proxy_Salome_file_map*> _t_IOR_Proxy_Service_file_map;
174 _t_Service_file_map _Input_Service_file_map;
175 _t_Service_file_map _Output_Service_file_map;
176 _t_Service_file_map::iterator _Service_file_map_it;
177 _t_Salome_file_map::iterator _Salome_file_map_it;
179 _t_Proxy_Service_file_map _Proxy_Input_Service_file_map;
180 _t_Proxy_Service_file_map _Proxy_Output_Service_file_map;
181 _t_Proxy_Service_file_map::iterator _Proxy_Service_file_map_it;
182 _t_Proxy_Salome_file_map::iterator _Proxy_Salome_file_map_it;
184 _t_IOR_Proxy_Service_file_map _IOR_Proxy_Input_Service_file_map;
185 _t_IOR_Proxy_Service_file_map _IOR_Proxy_Output_Service_file_map;
186 _t_IOR_Proxy_Service_file_map::iterator _IOR_Proxy_Service_file_map_it;
187 _t_IOR_Proxy_Salome_file_map::iterator _IOR_Proxy_Salome_file_map_it;
189 std::string _serviceName ;
190 std::string _graphName ;
191 std::string _nodeName ;
193 pthread_mutex_t * deploy_mutex;
198 pthread_t _ThreadId ;
200 pthread_t* _ThreadId ;
203 long _ThreadCpuUsed ;
205 bool _CanceledThread ;