Version: 6.3.1

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