Salome HOME
To avoid compilation pb on RedHat 8.0.
[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 <SALOME_Container.hxx>
33
34 #include <iostream>
35 #include <signal.h>
36 #include <stdlib.h>
37 #ifndef WNT
38 #include <unistd.h>
39 #endif
40 #include <sys/types.h>
41 #include <string>
42 #include <map>
43 #include <SALOMEconfig.h>
44 #include CORBA_SERVER_HEADER(SALOME_Component)
45 #include "NOTIFICATION.hxx"
46 #include "Salome_file_i.hxx"
47
48 class RegistryConnexion;
49 class Engines_Container_i;
50
51 class CONTAINER_EXPORT Engines_Component_i: 
52   public virtual POA_Engines::Component,
53   public virtual PortableServer::ServantBase
54 {
55 public:
56   Engines_Component_i();
57   Engines_Component_i(CORBA::ORB_ptr orb,
58                       PortableServer::POA_ptr poa,
59                       PortableServer::ObjectId * contId, 
60                       const char *instanceName, 
61                       const char *interfaceName,
62                       bool notif = false);
63   // Consructeur pour composant parallele: ne pas faire appel au registry
64   Engines_Component_i(CORBA::ORB_ptr orb,
65                       PortableServer::POA_ptr poa,
66                       PortableServer::ObjectId * contId, 
67                       const char *instanceName, 
68                       const char *interfaceName,
69                       int flag,
70                       bool notif = false);
71
72   virtual ~Engines_Component_i();
73
74   // --- CORBA methods
75
76   char* instanceName();
77   char* interfaceName();
78
79   void ping();
80   void destroy();
81
82   CORBA::Long getStudyId();
83   Engines::Container_ptr GetContainerRef();
84
85   void setProperties(const Engines::FieldsDict& dico);
86   Engines::FieldsDict* getProperties();
87
88   void Names( const char * graphName , const char * nodeName ) ;
89   bool Kill_impl();
90   bool Stop_impl();
91   bool Suspend_impl();
92   bool Resume_impl();
93   CORBA::Long CpuUsed_impl() ;
94
95  virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
96                                       CORBA::Boolean isPublished,
97                                       CORBA::Boolean& isValidScript);
98
99  // CORBA operations for Salome_file
100  virtual Engines::Salome_file_ptr getInputFileToService(const char* service_name, 
101                                                         const char* Salome_file_name);
102  virtual Engines::Salome_file_ptr getOutputFileToService(const char* service_name, 
103                                                               const char* Salome_file_name);
104
105  virtual void checkInputFilesToService(const char* service_name);
106  virtual Engines::Salome_file_ptr setInputFileToService(const char* service_name, 
107                                                         const char* Salome_file_name);
108
109  virtual void checkOutputFilesToService(const char* service_name);
110  virtual Engines::Salome_file_ptr setOutputFileToService(const char* service_name, 
111                                                          const char* Salome_file_name);
112   // --- local C++ methods
113
114   PortableServer::ObjectId * getId(); 
115   Engines_Container_i *GetContainerPtr();
116
117   bool setStudyId(CORBA::Long studyId);
118   static bool isMultiStudy();
119   static bool isMultiInstance();
120   static std::string GetDynLibraryName(const char *componentName);
121
122   void beginService(const char *serviceName);
123   void endService(const char *serviceName);
124   void sendMessage(const char *event_type, const char *message);
125   char * graphName() ;
126   char * nodeName() ;
127   bool Killer( pthread_t ThreadId , int signum );
128   void SetCurCpu() ;
129   long CpuUsed() ;
130   void CancelThread() ;
131
132   virtual void configureSalome_file(std::string service_name,
133                                     std::string file_port_name,
134                                     Salome_file_i * file);
135
136
137 protected:
138   int _studyId; // -1: not initialised; 0: multiStudy; >0: study
139   static bool _isMultiStudy;
140   static bool _isMultiInstance;
141
142   std::string _instanceName ;
143   std::string _interfaceName ;
144
145   CORBA::ORB_ptr _orb;
146   PortableServer::POA_ptr _poa;
147   PortableServer::ObjectId * _id;
148   PortableServer::ObjectId * _contId;
149   Engines_Component_i * _thisObj ;
150   RegistryConnexion *_myConnexionToRegistry;
151   NOTIFICATION_Supplier* _notifSupplier;
152   std::map<std::string,CORBA::Any>_fieldsDict;
153
154   // Map Salome_file_name to Salome_file*
155   typedef std::map<std::string, Salome_file_i*> _t_Salome_file_map;
156   // Map Service_name to  _Salome_file_map
157   typedef std::map<std::string, Engines_Component_i::_t_Salome_file_map*> _t_Service_file_map;
158   
159   _t_Service_file_map _Input_Service_file_map;
160   _t_Service_file_map _Output_Service_file_map;
161   _t_Service_file_map::iterator _Service_file_map_it;
162   _t_Salome_file_map::iterator _Salome_file_map_it;
163
164   std::string _serviceName ;
165   std::string _graphName ;
166   std::string _nodeName ;
167
168 private:
169 #ifndef WNT
170   pthread_t _ThreadId ;
171 #else
172   pthread_t* _ThreadId ;
173 #endif
174   long      _StartUsed ;
175   long      _ThreadCpuUsed ;
176   bool      _Executed ;
177   bool      _CanceledThread ;
178 };
179
180 #endif