Version: 6.3.1

src/Container/SALOME_Component_i.hxx

00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME Container : implementation of container and engine for Kernel
00024 //  File   : SALOME_Component_i.hxx
00025 //  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
00026 //  Module : SALOME
00027 //  $Header: /home/server/cvs/KERNEL/KERNEL_SRC/src/Container/SALOME_Component_i.hxx,v 1.13.2.6.10.3.2.1 2011-06-01 13:51:39 vsr Exp $
00028 //
00029 #ifndef _SALOME_COMPONENT_I_HXX_
00030 #define _SALOME_COMPONENT_I_HXX_
00031 
00032 #include <SALOMEconfig.h>
00033 
00034 #include "SALOME_Container.hxx"
00035 
00036 #include <iostream>
00037 #include <signal.h>
00038 #include <stdlib.h>
00039 #ifndef WIN32
00040 #include <unistd.h>
00041 #endif
00042 #include <sys/types.h>
00043 #include <string>
00044 #include <map>
00045 #include CORBA_SERVER_HEADER(SALOME_Component)
00046 #include "NOTIFICATION.hxx"
00047 #include "Salome_file_i.hxx"
00048 
00049 class RegistryConnexion;
00050 class Engines_Container_i;
00051 
00052 class CONTAINER_EXPORT Engines_Component_i: 
00053   public virtual POA_Engines::EngineComponent,
00054   public virtual PortableServer::ServantBase
00055 {
00056 public:
00057   Engines_Component_i();
00058   Engines_Component_i(CORBA::ORB_ptr orb,
00059                       PortableServer::POA_ptr poa,
00060                       PortableServer::ObjectId * contId, 
00061                       const char *instanceName, 
00062                       const char *interfaceName,
00063                       bool notif = false,
00064                       bool regist = true);
00065   //Constructor for standalone component
00066   Engines_Component_i(CORBA::ORB_ptr orb,
00067                       PortableServer::POA_ptr poa,
00068                       Engines::Container_ptr container, 
00069                       const char *instanceName, 
00070                       const char *interfaceName,
00071                       bool notif = false,
00072                       bool regist = true);
00073 
00074   virtual ~Engines_Component_i();
00075 
00076   // --- CORBA methods
00077 
00078   char* instanceName();
00079   char* interfaceName();
00080 
00081   void ping();
00082   void destroy();
00083 
00084   CORBA::Long getStudyId();
00085   Engines::Container_ptr GetContainerRef();
00086 
00087   void setProperties(const Engines::FieldsDict& dico);
00088   Engines::FieldsDict* getProperties();
00089 
00090   void Names( const char * graphName , const char * nodeName ) ;
00091   bool Kill_impl();
00092   bool Stop_impl();
00093   bool Suspend_impl();
00094   bool Resume_impl();
00095   CORBA::Long CpuUsed_impl() ;
00096 
00097   virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
00098                                        CORBA::Boolean isPublished,
00099                                        CORBA::Boolean isMultiFile,
00100                                        CORBA::Boolean& isValidScript);
00101 
00102   // CORBA operations for Salome_file
00103   virtual Engines::Salome_file_ptr getInputFileToService(const char* service_name, 
00104                                                          const char* Salome_file_name);
00105   virtual Engines::Salome_file_ptr getOutputFileToService(const char* service_name, 
00106                                                           const char* Salome_file_name);
00107 
00108   virtual void checkInputFilesToService(const char* service_name);
00109   virtual Engines::Salome_file_ptr setInputFileToService(const char* service_name, 
00110                                                          const char* Salome_file_name);
00111 
00112   virtual void checkOutputFilesToService(const char* service_name);
00113   virtual Engines::Salome_file_ptr setOutputFileToService(const char* service_name, 
00114                                                           const char* Salome_file_name);
00115 
00116   // Object information
00117   virtual bool hasObjectInfo() { return false; }
00118   virtual char* getObjectInfo(CORBA::Long studyId, const char* entry) { return CORBA::string_dup(""); }
00119   
00120   // --- local C++ methods
00121 
00122   PortableServer::ObjectId * getId(); 
00123   Engines_Container_i *GetContainerPtr();
00124   std::string getContainerName();
00125   void setContainerName();
00126 
00127   virtual bool setStudyId(CORBA::Long studyId);
00128   static bool isMultiStudy();
00129   static bool isMultiInstance();
00130   static std::string GetDynLibraryName(const char *componentName);
00131 
00132   void beginService(const char *serviceName);
00133   void endService(const char *serviceName);
00134   void sendMessage(const char *event_type, const char *message);
00135   char * graphName() ;
00136   char * nodeName() ;
00137   bool Killer( pthread_t ThreadId , int signum );
00138   void SetCurCpu() ;
00139   long CpuUsed() ;
00140   void CancelThread() ;
00141 
00142   virtual void configureSalome_file(std::string service_name,
00143                                     std::string file_port_name,
00144                                     Salome_file_i * file);
00145 
00146 
00147 protected:
00148   int _studyId; // -1: not initialised; 0: multiStudy; >0: study
00149   static bool _isMultiStudy;
00150   static bool _isMultiInstance;
00151 
00152   std::string _instanceName ;
00153   std::string _interfaceName ;
00154   std::string _containerName ;
00155 
00156   CORBA::ORB_var _orb;
00157   PortableServer::POA_var _poa;
00158   PortableServer::ObjectId * _id;
00159   PortableServer::ObjectId * _contId;
00160   Engines::Container_var _container;
00161   Engines_Component_i * _thisObj ;
00162   RegistryConnexion *_myConnexionToRegistry;
00163   NOTIFICATION_Supplier* _notifSupplier;
00164   std::map<std::string,CORBA::Any>_fieldsDict;
00165 
00166   // Map Salome_file_name to Salome_file*
00167   typedef std::map<std::string, Salome_file_i*> _t_Salome_file_map;
00168   // Map Service_name to  _Salome_file_map
00169   typedef std::map<std::string, Engines_Component_i::_t_Salome_file_map*> _t_Service_file_map;
00170   
00171   _t_Service_file_map _Input_Service_file_map;
00172   _t_Service_file_map _Output_Service_file_map;
00173   _t_Service_file_map::iterator _Service_file_map_it;
00174   _t_Salome_file_map::iterator _Salome_file_map_it;
00175 
00176   std::string _serviceName ;
00177   std::string _graphName ;
00178   std::string _nodeName ;
00179 
00180 private:
00181 #ifndef WIN32
00182   pthread_t _ThreadId ;
00183 #else
00184   pthread_t* _ThreadId ;
00185 #endif
00186   long      _StartUsed ;
00187   long      _ThreadCpuUsed ;
00188   bool      _Executed ;
00189   bool      _CanceledThread ;
00190 };
00191 
00192 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS