General KERNEL Documentation     End User KERNEL Services  


src/Container/SALOME_Container_i.hxx

Go to the documentation of this file.
00001 //  SALOME Container : implementation of container and engine for Kernel
00002 //
00003 //  Copyright (C) 2003  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 //
00024 //  File   : SALOME_Container_i.hxx
00025 //  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
00026 //  Module : SALOME
00027 //  $Header: /home/server/cvs/KERNEL/KERNEL_SRC/src/Container/SALOME_Container_i.hxx,v 1.15 2006/06/01 11:15:16 jfa Exp $
00028 
00029 #ifndef _SALOME_CONTAINER_I_HXX_
00030 #define _SALOME_CONTAINER_I_HXX_
00031 
00032 #include <SALOMEconfig.h>
00033 #include CORBA_SERVER_HEADER(SALOME_Component)
00034 
00035 #include <iostream>
00036 #include <signal.h>
00037 #include <stdlib.h>
00038 #ifndef WNT
00039 #include <unistd.h>
00040 #endif
00041 #include <sys/types.h>
00042 #include <omnithread.h>
00043 #include <map>
00044 #include <string>
00045 
00046 class SALOME_NamingService;
00047 
00048 
00049 #if defined CONTAINER_EXPORTS
00050 #if defined WIN32
00051 #define CONTAINER_EXPORT __declspec( dllexport )
00052 #else
00053 #define CONTAINER_EXPORT
00054 #endif
00055 #else
00056 #if defined WNT
00057 #define CONTAINER_EXPORT __declspec( dllimport )
00058 #else
00059 #define CONTAINER_EXPORT
00060 #endif
00061 #endif
00062 
00063 class CONTAINER_EXPORT Engines_Container_i:
00064   public virtual POA_Engines::Container,
00065   public virtual PortableServer::RefCountServantBase
00066 {
00067 public:
00068   Engines_Container_i();
00069   Engines_Container_i(CORBA::ORB_ptr orb, 
00070                 PortableServer::POA_var poa,
00071                 char * containerName ,
00072                       int argc, char* argv[],
00073                 bool activAndRegist = true,
00074                 bool isServantAloneInProcess = true);
00075   virtual ~Engines_Container_i();
00076 
00077   // --- CORBA methods
00078 
00079   virtual bool load_component_Library(const char* componentName);
00080 
00081   virtual Engines::Component_ptr
00082   create_component_instance( const char* componentName,
00083                     CORBA::Long studyId); // 0 for multiStudy
00084 
00085   Engines::Component_ptr
00086   find_component_instance( const char* registeredName,
00087                   CORBA::Long studyId); // 0 for multiStudy
00088 
00089   Engines::Component_ptr
00090   load_impl(const char* nameToRegister,
00091          const char* componentName);
00092 
00093 
00094   void remove_impl(Engines::Component_ptr component_i);
00095   void finalize_removal();
00096 
00097   virtual void ping();
00098   char* name();
00099   virtual void Shutdown();
00100   char* getHostName();
00101   CORBA::Long getPID();
00103   bool Kill_impl();
00104 
00105   Engines::fileRef_ptr createFileRef(const char* origFileName);
00106   Engines::fileTransfer_ptr getFileTransfer();
00107 
00108 
00109   // --- local C++ methods
00110 
00111   Engines::Component_ptr
00112   find_or_create_instance( std::string genericRegisterName,
00113                   std::string componentLibraryName);
00114 
00115   Engines::Component_ptr
00116   createInstance(std::string genericRegisterName,
00117            void *handle,
00118            int studyId);
00119 
00120   static bool isPythonContainer(const char* ContainerName);
00121   static void decInstanceCnt(std::string genericRegisterName);
00122   //??? char* machineName();
00123 
00124   // --- needed for parallel components, Numerical Platon
00125 
00126   int getArgc() { return _argc; }
00127   char **getArgv() { return _argv; }
00128 
00129 protected:
00130 
00131   static std::map<std::string, int> _cntInstances_map;
00132   static std::map<std::string, void *> _library_map; // library names, loaded
00133   static std::map<std::string, void *> _toRemove_map;// library names to remove
00134   static omni_mutex _numInstanceMutex ; // lib and instance protection
00135 
00136   bool _isSupervContainer;
00137 
00138   SALOME_NamingService *_NS ;
00139   std::string _library_path;
00140   std::string _containerName;
00141   CORBA::ORB_var _orb;
00142   PortableServer::POA_var _poa;
00143   PortableServer::ObjectId * _id ;
00144   int _numInstance ;
00145   std::map<std::string,Engines::Component_var> _listInstances_map;
00146   std::map<std::string,Engines::fileRef_var> _fileRef_map;
00147   Engines::fileTransfer_var _fileTransfer;
00148 
00149   int    _argc ;
00150   char** _argv ;
00151   long   _pid;
00152   bool   _isServantAloneInProcess;
00153 };
00154 
00155 #endif
00156