Version: 9.12.0
SALOME_Component_i.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, 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 Container : implementation of container and engine for Kernel
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 WIN32
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;
52 
54  public virtual POA_Engines::EngineComponent,
55  public virtual PortableServer::ServantBase
56 {
57 public:
59  Engines_Component_i(CORBA::ORB_ptr orb,
60  PortableServer::POA_ptr poa,
61  PortableServer::ObjectId * contId,
62  const char *instanceName,
63  const char *interfaceName,
64  bool notif = false,
65  bool regist = true);
66  //Constructor for standalone component
67  Engines_Component_i(CORBA::ORB_ptr orb,
68  PortableServer::POA_ptr poa,
69  Engines::Container_ptr container,
70  const char *instanceName,
71  const char *interfaceName,
72  bool notif = false,
73  bool regist = true);
74 
75  CORBA::Boolean isSSLMode() override;
76 
77  virtual ~Engines_Component_i();
78 
79  // --- CORBA methods
80 
81  char* instanceName();
82  char* interfaceName();
83 
84  void ping();
85  void destroy();
86 
87  Engines::Container_ptr GetContainerRef();
88 
89  void setProperties(const Engines::FieldsDict& dico);
90  Engines::FieldsDict* getProperties();
91 
92  virtual void SetOption(const char*, const char*);
93  virtual char* GetOption(const char*);
94 
95  void Names( const char * graphName , const char * nodeName ) ;
96  bool Kill_impl();
97  bool Stop_impl();
98  bool Suspend_impl();
99  bool Resume_impl();
100  CORBA::Long CpuUsed_impl() ;
101 
102  virtual Engines::TMPFile* DumpPython(CORBA::Boolean isPublished,
103  CORBA::Boolean isMultiFile,
104  CORBA::Boolean& isValidScript);
105 
106  // CORBA operations for Salome_file
107  virtual Engines::Salome_file_ptr getInputFileToService(const char* service_name,
108  const char* Salome_file_name);
109  virtual Engines::Salome_file_ptr getOutputFileToService(const char* service_name,
110  const char* Salome_file_name);
111 
112  virtual void checkInputFilesToService(const char* service_name);
113  virtual Engines::Salome_file_ptr setInputFileToService(const char* service_name,
114  const char* Salome_file_name);
115 
116  virtual void checkOutputFilesToService(const char* service_name);
117  virtual Engines::Salome_file_ptr setOutputFileToService(const char* service_name,
118  const char* Salome_file_name);
119 
120  // Object information
121  virtual bool hasObjectInfo();
122  virtual char* getObjectInfo(const char* entry);
123 
124  // Version information
125  virtual char* getVersion();
126 
127  // --- local C++ methods
128 
129  PortableServer::ObjectId * getId();
130  Engines_Container_i *GetContainerPtr();
131  std::string getContainerName();
132  void setContainerName();
133 
134  static bool isMultiInstance();
135  static std::string GetDynLibraryName(const char *componentName);
136 
137  void beginService(const char *serviceName);
138  void endService(const char *serviceName);
139  void sendMessage(const char *event_type, const char *message);
140  char * graphName() ;
141  char * nodeName() ;
142  bool Killer( pthread_t ThreadId , int signum );
143  void SetCurCpu() ;
144  long CpuUsed() ;
145  void CancelThread() ;
146 
147  virtual void configureSalome_file(std::string service_name,
148  std::string file_port_name,
149  Salome_file_i * file);
150 
151 protected:
152 
154 
155 protected:
156  static bool _isMultiInstance;
157 
158  std::string _instanceName ;
159  std::string _interfaceName ;
160  std::string _containerName ;
161 
162  CORBA::ORB_var _orb;
163  PortableServer::POA_var _poa;
164  PortableServer::ObjectId * _id;
165  PortableServer::ObjectId * _contId;
166  Engines::Container_var _container;
170  std::map<std::string,CORBA::Any>_fieldsDict;
171 
172  // Map Salome_file_name to Salome_file*
173  typedef std::map<std::string, Salome_file_i*> _t_Salome_file_map;
174  // Map Service_name to _Salome_file_map
175  typedef std::map<std::string, Engines_Component_i::_t_Salome_file_map*> _t_Service_file_map;
176 
179  _t_Service_file_map::iterator _Service_file_map_it;
180  _t_Salome_file_map::iterator _Salome_file_map_it;
181 
182  std::string _serviceName ;
183  std::string _graphName ;
184  std::string _nodeName ;
185 
186 private:
187 #ifndef WIN32
188  pthread_t _ThreadId ;
189 #else
190  pthread_t* _ThreadId ;
191 #endif
192  long _StartUsed ;
194  bool _Executed ;
196 };
197 
198 #endif
#define CONTAINER_EXPORT
Definition: SALOME_Container.hxx:37
C++ implementation of Engines::Component interface.
Definition: SALOME_Component_i.hxx:56
std::string _instanceName
Definition: SALOME_Component_i.hxx:158
std::string _serviceName
Definition: SALOME_Component_i.hxx:182
pthread_t _ThreadId
Definition: SALOME_Component_i.hxx:188
std::string _nodeName
Definition: SALOME_Component_i.hxx:184
PortableServer::ObjectId * _id
Definition: SALOME_Component_i.hxx:164
long _ThreadCpuUsed
Definition: SALOME_Component_i.hxx:193
std::string _interfaceName
Definition: SALOME_Component_i.hxx:159
_t_Service_file_map _Input_Service_file_map
Definition: SALOME_Component_i.hxx:177
_t_Service_file_map::iterator _Service_file_map_it
Definition: SALOME_Component_i.hxx:179
Engines_Component_i * _thisObj
Definition: SALOME_Component_i.hxx:167
NOTIFICATION_Supplier * _notifSupplier
Definition: SALOME_Component_i.hxx:169
PortableServer::POA_var _poa
Definition: SALOME_Component_i.hxx:163
RegistryConnexion * _myConnexionToRegistry
Definition: SALOME_Component_i.hxx:168
bool _CanceledThread
Definition: SALOME_Component_i.hxx:195
std::string _containerName
Definition: SALOME_Component_i.hxx:160
CORBA::ORB_var _orb
Definition: SALOME_Component_i.hxx:162
static bool _isMultiInstance
Definition: SALOME_Component_i.hxx:156
_t_Service_file_map _Output_Service_file_map
Definition: SALOME_Component_i.hxx:178
std::map< std::string, CORBA::Any > _fieldsDict
Definition: SALOME_Component_i.hxx:170
std::string _graphName
Definition: SALOME_Component_i.hxx:183
std::map< std::string, Salome_file_i * > _t_Salome_file_map
Definition: SALOME_Component_i.hxx:173
Engines::Container_var _container
Definition: SALOME_Component_i.hxx:166
std::map< std::string, Engines_Component_i::_t_Salome_file_map * > _t_Service_file_map
Definition: SALOME_Component_i.hxx:175
bool _Executed
Definition: SALOME_Component_i.hxx:194
PortableServer::ObjectId * _contId
Definition: SALOME_Component_i.hxx:165
long _StartUsed
Definition: SALOME_Component_i.hxx:192
_t_Salome_file_map::iterator _Salome_file_map_it
Definition: SALOME_Component_i.hxx:180
static bool isMultiInstance()
C++ implementation of Engines::Container interface.
Definition: SALOME_Container_i.hxx:199
Definition: NOTIFICATION_Supplier.hxx:37
Definition: RegistryConnexion.hxx:45
Definition: SALOME_NamingService_Abstract.hxx:46
A class to manage file transfer in SALOME.
Definition: Salome_file_i.hxx:42
sequence< KeyValuePair > FieldsDict
Definition: SALOME_Component.idl:64
sequence< octet > TMPFile
A byte stream which is used for binary data transfer between different components.
Definition: SALOME_Component.idl:49
def getVersion(mod="KERNEL", full=False)
Definition: salome_version.py:40
poa
Definition: SALOME_ContainerPy.py:377
container
Definition: TestComponentPy.py:63
orb
Definition: salome.py:122