Version: 8.3.0
SALOME_ParallelComponent_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 
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
27 //
28 #ifndef _SALOME_PARALLEL_COMPONENT_I_HXX_
29 #define _SALOME_PARALLEL_COMPONENT_I_HXX_
30 
31 #include <iostream>
32 #include <signal.h>
33 #include <stdlib.h>
34 #ifndef WIN32
35 #include <unistd.h>
36 #endif
37 #include <sys/types.h>
38 #include <string>
39 #include <map>
40 #include <SALOMEconfig.h>
41 
42 #include "SALOME_PACOExtensionPaCO_Engines_Parallel_Component_server.hxx"
43 
44 #include "NOTIFICATION.hxx"
45 #include "RegistryConnexion.hxx"
47 
49 
50 #ifdef WIN32
51 # if defined CONTAINER_EXPORTS || defined SalomeParallelContainer_EXPORTS
52 # define CONTAINER_EXPORT __declspec( dllexport )
53 # else
54 # define CONTAINER_EXPORT __declspec( dllimport )
55 # endif
56 #else
57 # define CONTAINER_EXPORT
58 #endif
59 
61  public virtual Engines::Parallel_Component_serv,
62  public virtual PortableServer::RefCountServantBase
63 {
64 public:
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,
70  bool notif = false,
71  bool regist = true);
72 
74 
75  // --- CORBA methods
76 
77  char* instanceName();
78  char* interfaceName();
79 
80  void ping();
81  void destroy();
82 
83  CORBA::Long getStudyId();
84  Engines::Container_ptr GetContainerRef();
85 
86  void setProperties(const Engines::FieldsDict& dico);
87  Engines::FieldsDict* getProperties();
88 
89  void Names( const char * graphName , const char * nodeName ) ;
90  bool Kill_impl();
91  bool Stop_impl();
92  bool Suspend_impl();
93  bool Resume_impl();
94  CORBA::Long CpuUsed_impl() ;
95 
96  virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
97  CORBA::Boolean isPublished,
98  CORBA::Boolean isMultiFile,
99  CORBA::Boolean& isValidScript);
100 
101  // CORBA operations for Salome_file
102  virtual Engines::Salome_file_ptr getInputFileToService(const char* service_name,
103  const char* Salome_file_name);
104  virtual Engines::Salome_file_ptr getOutputFileToService(const char* service_name,
105  const char* Salome_file_name);
106 
107  virtual void checkInputFilesToService(const char* service_name);
108  virtual Engines::Salome_file_ptr setInputFileToService(const char* service_name,
109  const char* Salome_file_name);
110 
111  virtual void checkOutputFilesToService(const char* service_name);
112  virtual Engines::Salome_file_ptr setOutputFileToService(const char* service_name,
113  const char* Salome_file_name);
114 
115  void send_parallel_proxy_object(CORBA::Object_ptr proxy_ref);
116 
117  // Object information
118  virtual bool hasObjectInfo() { return false; }
119  virtual char* getObjectInfo(CORBA::Long studyId, const char* entry) { return ""; }
120 
121  // --- local C++ methods
122 
123  PortableServer::ObjectId * getId();
124  Engines_Parallel_Container_i *GetContainerPtr();
125 
126  bool setStudyId(CORBA::Long studyId);
127  static bool isMultiStudy();
128  static bool isMultiInstance();
129  static std::string GetDynLibraryName(const char *componentName);
130 
131  void beginService(const char *serviceName);
132  void endService(const char *serviceName);
133  void sendMessage(const char *event_type, const char *message);
134  char * graphName() ;
135  char * nodeName() ;
136  bool Killer( pthread_t ThreadId , int signum );
137  void SetCurCpu() ;
138  long CpuUsed() ;
139  void CancelThread();
140 
141  void wait_parallel_object_proxy();
142  char * get_parallel_proxy_object();
143 
144  virtual void configureSalome_file(std::string service_name,
145  std::string file_port_name,
146  Engines::Parallel_Salome_file_proxy_impl * file);
147 
148 protected:
149  int _studyId; // -1: not initialised; 0: multiStudy; >0: study
150  static bool _isMultiStudy;
151  static bool _isMultiInstance;
152 
153  std::string _instanceName ;
154  std::string _interfaceName ;
155 
156  CORBA::ORB_var _orb;
157  PortableServer::POA_var _poa;
158  PortableServer::ObjectId * _id;
159  PortableServer::ObjectId * _contId;
163  std::map<std::string,CORBA::Any>_fieldsDict;
164 
165  // Map Salome_file_name to Parallel_Salome_file*
166  typedef std::map<std::string, Parallel_Salome_file_i*> _t_Salome_file_map;
167  typedef std::map<std::string, Engines::Parallel_Salome_file_proxy_impl*> _t_Proxy_Salome_file_map;
168  typedef std::map<std::string, std::string> _t_IOR_Proxy_Salome_file_map;
169 
170  // Map Service_name to _Salome_file_map
171  typedef std::map<std::string, Engines_Parallel_Component_i::_t_Salome_file_map*> _t_Service_file_map;
172  typedef std::map<std::string, Engines_Parallel_Component_i::_t_Proxy_Salome_file_map*> _t_Proxy_Service_file_map;
173  typedef std::map<std::string, Engines_Parallel_Component_i::_t_IOR_Proxy_Salome_file_map*> _t_IOR_Proxy_Service_file_map;
174 
177  _t_Service_file_map::iterator _Service_file_map_it;
178  _t_Salome_file_map::iterator _Salome_file_map_it;
179 
182  _t_Proxy_Service_file_map::iterator _Proxy_Service_file_map_it;
183  _t_Proxy_Salome_file_map::iterator _Proxy_Salome_file_map_it;
184 
187  _t_IOR_Proxy_Service_file_map::iterator _IOR_Proxy_Service_file_map_it;
188  _t_IOR_Proxy_Salome_file_map::iterator _IOR_Proxy_Salome_file_map_it;
189 
190  std::string _serviceName ;
191  std::string _graphName ;
192  std::string _nodeName ;
193 
194  pthread_mutex_t * deploy_mutex;
195  char * _proxy;
196 
197 private:
198 #ifndef WIN32
199  pthread_t _ThreadId ;
200 #else
201  pthread_t* _ThreadId ;
202 #endif
203  long _StartUsed ;
205  bool _Executed ;
208 };
209 
210 #endif