1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SALOME Container : implementation of container and engine for Kernel
23 // File : SALOME_Component_i.hxx
24 // Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
28 #ifndef _SALOME_COMPONENT_I_HXX_
29 #define _SALOME_COMPONENT_I_HXX_
31 #include <SALOMEconfig.h>
33 #include "SALOME_Container.hxx"
41 #include <sys/types.h>
44 #include CORBA_SERVER_HEADER(SALOME_Component)
45 #include "NOTIFICATION.hxx"
46 #include "Salome_file_i.hxx"
48 class RegistryConnexion;
49 class Engines_Container_i;
51 class CONTAINER_EXPORT Engines_Component_i:
52 public virtual POA_Engines::Component,
53 public virtual PortableServer::ServantBase
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,
63 //Constructor for standalone component
64 Engines_Component_i(CORBA::ORB_ptr orb,
65 PortableServer::POA_ptr poa,
66 Engines::Container_ptr container,
67 const char *instanceName,
68 const char *interfaceName,
71 // Constructor for parallel component : don't call registry
72 Engines_Component_i(CORBA::ORB_ptr orb,
73 PortableServer::POA_ptr poa,
74 PortableServer::ObjectId * contId,
75 const char *instanceName,
76 const char *interfaceName,
80 virtual ~Engines_Component_i();
85 char* interfaceName();
90 CORBA::Long getStudyId();
91 Engines::Container_ptr GetContainerRef();
93 void setProperties(const Engines::FieldsDict& dico);
94 Engines::FieldsDict* getProperties();
96 void Names( const char * graphName , const char * nodeName ) ;
101 CORBA::Long CpuUsed_impl() ;
103 virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
104 CORBA::Boolean isPublished,
105 CORBA::Boolean& isValidScript);
107 // CORBA operations for Salome_file
108 virtual Engines::Salome_file_ptr getInputFileToService(const char* service_name,
109 const char* Salome_file_name);
110 virtual Engines::Salome_file_ptr getOutputFileToService(const char* service_name,
111 const char* Salome_file_name);
113 virtual void checkInputFilesToService(const char* service_name);
114 virtual Engines::Salome_file_ptr setInputFileToService(const char* service_name,
115 const char* Salome_file_name);
117 virtual void checkOutputFilesToService(const char* service_name);
118 virtual Engines::Salome_file_ptr setOutputFileToService(const char* service_name,
119 const char* Salome_file_name);
121 // Object information
122 virtual bool hasObjectInfo() { return false; }
123 virtual char* getObjectInfo(CORBA::Long studyId, const char* entry) { return ""; }
125 // --- local C++ methods
127 PortableServer::ObjectId * getId();
128 Engines_Container_i *GetContainerPtr();
130 bool setStudyId(CORBA::Long studyId);
131 static bool isMultiStudy();
132 static bool isMultiInstance();
133 static std::string GetDynLibraryName(const char *componentName);
135 void beginService(const char *serviceName);
136 void endService(const char *serviceName);
137 void sendMessage(const char *event_type, const char *message);
140 bool Killer( pthread_t ThreadId , int signum );
143 void CancelThread() ;
145 virtual void configureSalome_file(std::string service_name,
146 std::string file_port_name,
147 Salome_file_i * file);
151 int _studyId; // -1: not initialised; 0: multiStudy; >0: study
152 static bool _isMultiStudy;
153 static bool _isMultiInstance;
155 std::string _instanceName ;
156 std::string _interfaceName ;
159 PortableServer::POA_var _poa;
160 PortableServer::ObjectId * _id;
161 PortableServer::ObjectId * _contId;
162 Engines::Container_var _container;
163 Engines_Component_i * _thisObj ;
164 RegistryConnexion *_myConnexionToRegistry;
165 NOTIFICATION_Supplier* _notifSupplier;
166 std::map<std::string,CORBA::Any>_fieldsDict;
168 // Map Salome_file_name to Salome_file*
169 typedef std::map<std::string, Salome_file_i*> _t_Salome_file_map;
170 // Map Service_name to _Salome_file_map
171 typedef std::map<std::string, Engines_Component_i::_t_Salome_file_map*> _t_Service_file_map;
173 _t_Service_file_map _Input_Service_file_map;
174 _t_Service_file_map _Output_Service_file_map;
175 _t_Service_file_map::iterator _Service_file_map_it;
176 _t_Salome_file_map::iterator _Salome_file_map_it;
178 std::string _serviceName ;
179 std::string _graphName ;
180 std::string _nodeName ;
184 pthread_t _ThreadId ;
186 pthread_t* _ThreadId ;
189 long _ThreadCpuUsed ;
191 bool _CanceledThread ;