]> SALOME platform Git repositories - modules/kernel.git/blob - src/Container/SALOME_Component_i.hxx
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/kernel.git] / src / Container / SALOME_Component_i.hxx
1 //  SALOME Container : implementation of container and engine for Kernel
2 //
3 //  Copyright (C) 2003  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. 
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 //
24 //  File   : SALOME_Component_i.hxx
25 //  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef _SALOME_COMPONENT_I_HXX_
30 #define _SALOME_COMPONENT_I_HXX_
31
32 #include <SALOMEconfig.h>
33
34 #include <SALOME_Container.hxx>
35
36 #include <iostream>
37 #include <signal.h>
38 #include <stdlib.h>
39 #ifndef WNT
40 #include <unistd.h>
41 #endif
42 #include <sys/types.h>
43 #include <string>
44 #include <map>
45 #include CORBA_SERVER_HEADER(SALOME_Component)
46 #include "NOTIFICATION.hxx"
47 #include "Salome_file_i.hxx"
48
49 class RegistryConnexion;
50 class Engines_Container_i;
51
52 class CONTAINER_EXPORT Engines_Component_i: 
53   public virtual POA_Engines::Component,
54   public virtual PortableServer::ServantBase
55 {
56 public:
57   Engines_Component_i();
58   Engines_Component_i(CORBA::ORB_ptr orb,
59                       PortableServer::POA_ptr poa,
60                       PortableServer::ObjectId * contId, 
61                       const char *instanceName, 
62                       const char *interfaceName,
63                       bool notif = false);
64   // Consructeur pour composant parallele: ne pas faire appel au registry
65   Engines_Component_i(CORBA::ORB_ptr orb,
66                       PortableServer::POA_ptr poa,
67                       PortableServer::ObjectId * contId, 
68                       const char *instanceName, 
69                       const char *interfaceName,
70                       int flag,
71                       bool notif = false);
72
73   virtual ~Engines_Component_i();
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& isValidScript);
99
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);
105
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);
109
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);
113   // --- local C++ methods
114
115   PortableServer::ObjectId * getId(); 
116   Engines_Container_i *GetContainerPtr();
117
118   bool setStudyId(CORBA::Long studyId);
119   static bool isMultiStudy();
120   static bool isMultiInstance();
121   static std::string GetDynLibraryName(const char *componentName);
122
123   void beginService(const char *serviceName);
124   void endService(const char *serviceName);
125   void sendMessage(const char *event_type, const char *message);
126   char * graphName() ;
127   char * nodeName() ;
128   bool Killer( pthread_t ThreadId , int signum );
129   void SetCurCpu() ;
130   long CpuUsed() ;
131   void CancelThread() ;
132
133   virtual void configureSalome_file(std::string service_name,
134                                     std::string file_port_name,
135                                     Salome_file_i * file);
136
137
138 protected:
139   int _studyId; // -1: not initialised; 0: multiStudy; >0: study
140   static bool _isMultiStudy;
141   static bool _isMultiInstance;
142
143   std::string _instanceName ;
144   std::string _interfaceName ;
145
146   CORBA::ORB_var _orb;
147   PortableServer::POA_var _poa;
148   PortableServer::ObjectId * _id;
149   PortableServer::ObjectId * _contId;
150   Engines_Component_i * _thisObj ;
151   RegistryConnexion *_myConnexionToRegistry;
152   NOTIFICATION_Supplier* _notifSupplier;
153   std::map<std::string,CORBA::Any>_fieldsDict;
154
155   // Map Salome_file_name to Salome_file*
156   typedef std::map<std::string, Salome_file_i*> _t_Salome_file_map;
157   // Map Service_name to  _Salome_file_map
158   typedef std::map<std::string, Engines_Component_i::_t_Salome_file_map*> _t_Service_file_map;
159   
160   _t_Service_file_map _Input_Service_file_map;
161   _t_Service_file_map _Output_Service_file_map;
162   _t_Service_file_map::iterator _Service_file_map_it;
163   _t_Salome_file_map::iterator _Salome_file_map_it;
164
165   std::string _serviceName ;
166   std::string _graphName ;
167   std::string _nodeName ;
168
169 private:
170 #ifndef WNT
171   pthread_t _ThreadId ;
172 #else
173   pthread_t* _ThreadId ;
174 #endif
175   long      _StartUsed ;
176   long      _ThreadCpuUsed ;
177   bool      _Executed ;
178   bool      _CanceledThread ;
179 };
180
181 #endif