SALOME documentation central

src/Container/SALOME_Container_i.hxx

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