Salome HOME
First stable version after merging with V3_2_2
[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
47 class RegistryConnexion;
48 class Engines_Container_i;
49
50 class CONTAINER_EXPORT Engines_Component_i: 
51   public virtual POA_Engines::Component,
52   public virtual PortableServer::RefCountServantBase
53 {
54 public:
55   Engines_Component_i();
56   Engines_Component_i(CORBA::ORB_ptr orb,
57                       PortableServer::POA_ptr poa,
58                       PortableServer::ObjectId * contId, 
59                       const char *instanceName, 
60                       const char *interfaceName,
61                       bool notif = false);
62   // Consructeur pour composant parallele: ne pas faire appel au registry
63   Engines_Component_i(CORBA::ORB_ptr orb,
64                       PortableServer::POA_ptr poa,
65                       PortableServer::ObjectId * contId, 
66                       const char *instanceName, 
67                       const char *interfaceName,
68                       int flag,
69                       bool notif = false);
70
71   virtual ~Engines_Component_i();
72
73   // --- CORBA methods
74
75   char* instanceName();
76   char* interfaceName();
77
78   void ping();
79   void destroy();
80
81   CORBA::Long getStudyId();
82   Engines::Container_ptr GetContainerRef();
83
84   void setProperties(const Engines::FieldsDict& dico);
85   Engines::FieldsDict* getProperties();
86
87   void Names( const char * graphName , const char * nodeName ) ;
88   bool Kill_impl();
89   bool Stop_impl();
90   bool Suspend_impl();
91   bool Resume_impl();
92   CORBA::Long CpuUsed_impl() ;
93
94  virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
95                                       CORBA::Boolean isPublished,
96                                       CORBA::Boolean& isValidScript);
97
98
99   // --- local C++ methods
100
101   PortableServer::ObjectId * getId(); 
102   Engines_Container_i *GetContainerPtr();
103
104   bool setStudyId(CORBA::Long studyId);
105   static bool isMultiStudy();
106   static bool isMultiInstance();
107   static std::string GetDynLibraryName(const char *componentName);
108
109   void beginService(const char *serviceName);
110   void endService(const char *serviceName);
111   void sendMessage(const char *event_type, const char *message);
112   char * graphName() ;
113   char * nodeName() ;
114   bool Killer( pthread_t ThreadId , int signum );
115   void SetCurCpu() ;
116   long CpuUsed() ;
117   void CancelThread() ;
118
119 protected:
120   int _studyId; // -1: not initialised; 0: multiStudy; >0: study
121   static bool _isMultiStudy;
122   static bool _isMultiInstance;
123
124   std::string _instanceName ;
125   std::string _interfaceName ;
126
127   CORBA::ORB_ptr _orb;
128   PortableServer::POA_ptr _poa;
129   PortableServer::ObjectId * _id;
130   PortableServer::ObjectId * _contId;
131   Engines_Component_i * _thisObj ;
132   RegistryConnexion *_myConnexionToRegistry;
133   NOTIFICATION_Supplier* _notifSupplier;
134   std::map<std::string,CORBA::Any>_fieldsDict;
135
136   std::string _serviceName ;
137   std::string _graphName ;
138   std::string _nodeName ;
139
140 private:
141 #ifndef WNT
142   pthread_t _ThreadId ;
143 #else
144   pthread_t* _ThreadId ;
145 #endif
146   long      _StartUsed ;
147   long      _ThreadCpuUsed ;
148   bool      _Executed ;
149   bool      _CanceledThread ;
150 };
151
152 #endif