Back to index

salome-kernel  6.5.0
SALOME_Component_i.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  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.5.2.1 2012-04-12 14:05:03 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   virtual void  SetOption(const char*, const char*);
00091   virtual char* GetOption(const char*);
00092 
00093         void Names( const char * graphName , const char * nodeName ) ;
00094   bool Kill_impl();
00095   bool Stop_impl();
00096   bool Suspend_impl();
00097   bool Resume_impl();
00098   CORBA::Long CpuUsed_impl() ;
00099 
00100   virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
00101                                        CORBA::Boolean isPublished,
00102                                        CORBA::Boolean isMultiFile,
00103                                        CORBA::Boolean& isValidScript);
00104 
00105   // CORBA operations for Salome_file
00106   virtual Engines::Salome_file_ptr getInputFileToService(const char* service_name, 
00107                                                          const char* Salome_file_name);
00108   virtual Engines::Salome_file_ptr getOutputFileToService(const char* service_name, 
00109                                                           const char* Salome_file_name);
00110 
00111   virtual void checkInputFilesToService(const char* service_name);
00112   virtual Engines::Salome_file_ptr setInputFileToService(const char* service_name, 
00113                                                          const char* Salome_file_name);
00114 
00115   virtual void checkOutputFilesToService(const char* service_name);
00116   virtual Engines::Salome_file_ptr setOutputFileToService(const char* service_name, 
00117                                                           const char* Salome_file_name);
00118 
00119   // Object information
00120   virtual bool hasObjectInfo() { return false; }
00121   virtual char* getObjectInfo(CORBA::Long studyId, const char* entry) { return CORBA::string_dup(""); }
00122   
00123   // --- local C++ methods
00124 
00125   PortableServer::ObjectId * getId(); 
00126   Engines_Container_i *GetContainerPtr();
00127   std::string getContainerName();
00128   void setContainerName();
00129 
00130   virtual bool setStudyId(CORBA::Long studyId);
00131   static bool isMultiStudy();
00132   static bool isMultiInstance();
00133   static std::string GetDynLibraryName(const char *componentName);
00134 
00135   void beginService(const char *serviceName);
00136   void endService(const char *serviceName);
00137   void sendMessage(const char *event_type, const char *message);
00138   char * graphName() ;
00139   char * nodeName() ;
00140   bool Killer( pthread_t ThreadId , int signum );
00141   void SetCurCpu() ;
00142   long CpuUsed() ;
00143   void CancelThread() ;
00144 
00145   virtual void configureSalome_file(std::string service_name,
00146                                     std::string file_port_name,
00147                                     Salome_file_i * file);
00148 
00149 
00150 protected:
00151   int _studyId; // -1: not initialised; 0: multiStudy; >0: study
00152   static bool _isMultiStudy;
00153   static bool _isMultiInstance;
00154 
00155   std::string _instanceName ;
00156   std::string _interfaceName ;
00157   std::string _containerName ;
00158 
00159   CORBA::ORB_var _orb;
00160   PortableServer::POA_var _poa;
00161   PortableServer::ObjectId * _id;
00162   PortableServer::ObjectId * _contId;
00163   Engines::Container_var _container;
00164   Engines_Component_i * _thisObj ;
00165   RegistryConnexion *_myConnexionToRegistry;
00166   NOTIFICATION_Supplier* _notifSupplier;
00167   std::map<std::string,CORBA::Any>_fieldsDict;
00168 
00169   // Map Salome_file_name to Salome_file*
00170   typedef std::map<std::string, Salome_file_i*> _t_Salome_file_map;
00171   // Map Service_name to  _Salome_file_map
00172   typedef std::map<std::string, Engines_Component_i::_t_Salome_file_map*> _t_Service_file_map;
00173   
00174   _t_Service_file_map _Input_Service_file_map;
00175   _t_Service_file_map _Output_Service_file_map;
00176   _t_Service_file_map::iterator _Service_file_map_it;
00177   _t_Salome_file_map::iterator _Salome_file_map_it;
00178 
00179   std::string _serviceName ;
00180   std::string _graphName ;
00181   std::string _nodeName ;
00182 
00183 private:
00184 #ifndef WIN32
00185   pthread_t _ThreadId ;
00186 #else
00187   pthread_t* _ThreadId ;
00188 #endif
00189   long      _StartUsed ;
00190   long      _ThreadCpuUsed ;
00191   bool      _Executed ;
00192   bool      _CanceledThread ;
00193 };
00194 
00195 #endif