Salome HOME
BugID: IPAL9392, modified methods GetRowUnits.
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
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 <iostream>
33 #include <signal.h>
34 #include <stdlib.h>
35 #ifndef WNT
36 #include <unistd.h>
37 #endif
38 #include <sys/types.h>
39 #include <string>
40 #include <map>
41 #include <SALOMEconfig.h>
42 #include CORBA_SERVER_HEADER(SALOME_Component)
43 #include "NOTIFICATION.hxx"
44
45 class RegistryConnexion;
46
47 #if defined CONTAINER_EXPORTS
48 #if defined WIN32
49 #define CONTAINER_EXPORT __declspec( dllexport )
50 #else
51 #define CONTAINER_EXPORT
52 #endif
53 #else
54 #if defined WNT
55 #define CONTAINER_EXPORT __declspec( dllimport )
56 #else
57 #define CONTAINER_EXPORT
58 #endif
59 #endif
60
61 class CONTAINER_EXPORT Engines_Component_i: public virtual POA_Engines::Component,
62                            public virtual PortableServer::RefCountServantBase
63 {
64 public:
65   Engines_Component_i();
66   Engines_Component_i(CORBA::ORB_ptr orb,
67                       PortableServer::POA_ptr poa,
68                       PortableServer::ObjectId * contId, 
69                       const char *instanceName, 
70                       const char *interfaceName,
71                       bool notif = false);
72   // Consructeur pour composant parallele: ne pas faire appel au registry
73   Engines_Component_i(CORBA::ORB_ptr orb,
74                       PortableServer::POA_ptr poa,
75                       PortableServer::ObjectId * contId, 
76                       const char *instanceName, 
77                       const char *interfaceName,
78                       int flag,
79                       bool notif = false);
80
81   virtual ~Engines_Component_i();
82
83   char* instanceName();
84   char* interfaceName();
85
86   void destroy();
87   void ping();
88
89   Engines::Container_ptr GetContainerRef();
90   PortableServer::ObjectId * getId(); 
91
92   void setProperties(const Engines::FieldsDict& dico);
93   Engines::FieldsDict* getProperties();
94
95   void beginService(const char *serviceName);
96   void endService(const char *serviceName);
97   void sendMessage(const char *event_type, const char *message);
98
99   void Names( const char * graphName , const char * nodeName ) ;
100   char * graphName() ;
101   char * nodeName() ;
102   bool Killer( pthread_t ThreadId , int signum );
103   bool Kill_impl();
104   bool Stop_impl();
105   bool Suspend_impl();
106   bool Resume_impl();
107   void SetCurCpu() ;
108   long CpuUsed() ;
109   CORBA::Long CpuUsed_impl() ;
110   CORBA::Long getStudyId();
111
112  virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy, CORBA::Boolean isPublished, CORBA::Boolean& isValidScript);
113
114   bool setStudyId(CORBA::Long studyId);
115   static bool isMultiStudy();
116   static bool isMultiInstance();
117   static std::string GetDynLibraryName(const char *componentName);
118   static std::string BuildComponentNameForNS(const char *ComponentName,
119                                              const char *ContainerName,
120                                              const char *hostname);
121 protected:
122   static bool _isMultiStudy;
123   static bool _isMultiInstance;
124   std::string _instanceName ;
125   std::string _interfaceName ;
126   std::string _serviceName ;
127   std::string _graphName ;
128   std::string _nodeName ;
129   int _studyId; // -1: not initialised; 0: multiStudy; >0: study
130   CORBA::ORB_ptr _orb;
131   PortableServer::POA_ptr _poa;
132   PortableServer::ObjectId * _id;
133   PortableServer::ObjectId * _contId;
134   Engines_Component_i * _thisObj ;
135   RegistryConnexion *_myConnexionToRegistry;
136   NOTIFICATION_Supplier* _notifSupplier;
137   std::map<std::string,CORBA::Any>_fieldsDict;
138
139 private:
140 #ifndef WNT
141   pthread_t _ThreadId ;
142 #else
143   pthread_t* _ThreadId ;
144 #endif
145   long      _StartUsed ;
146   long      _ThreadCpuUsed ;
147   bool      _Executed ;
148 };
149
150 #endif