]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
- Adding Salome_file to Kernel for file support into supervisor schema
authorribes <ribes>
Thu, 28 Jun 2007 10:16:48 +0000 (10:16 +0000)
committerribes <ribes>
Thu, 28 Jun 2007 10:16:48 +0000 (10:16 +0000)
15 files changed:
idl/Makefile.am
idl/SALOME_Component.idl
idl/SALOME_Exception.xml [new file with mode: 0644]
src/Container/Component_i.cxx
src/Container/Container_i.cxx
src/Container/Makefile.am
src/Container/SALOME_Component_i.hxx
src/Container/SALOME_Container_i.hxx
src/Container/Salome_file_i.cxx [new file with mode: 0644]
src/Container/Salome_file_i.hxx [new file with mode: 0644]
src/Container/TestSalome_file.cxx [new file with mode: 0644]
src/ParallelContainer/Makefile.am
src/ParallelContainer/SALOME_ParallelContainerNodeMpi.cxx
src/ParallelContainer/SALOME_ParallelContainer_i.cxx
src/ParallelContainer/SALOME_ParallelContainer_i.hxx

index fe38030415ee8ddadeeb9a3720142cece51132f9..21300235c3096f1a40861470c6f6bdf5642cd5b0 100644 (file)
@@ -119,13 +119,14 @@ IDL_SOURCES += $(DYNIDL_SOURCES)
 salomeinclude_DATA= $(STATIDL_SOURCES:%SK.cc=%.hh)
 
 if WITH_PACO_PARALLEL
-PAR = SALOME_ComponentPaCO.h SALOME_ComponentPaCO.cc \
+PAR = SALOME_ExceptionPaCO.h SALOME_ExceptionPaCO.cc \
+      SALOME_ComponentPaCO.h SALOME_ComponentPaCO.cc \
       SALOME_PortsPaCO.h SALOME_PortsPaCO.cc \
       DSC_EnginesPaCO.h DSC_EnginesPaCO.cc 
 
 PAR_LIB = libSalomeParallelIDLKernel.la
 
-IDL_PACO      = SALOME_ComponentPaCO.idl SALOME_PortsPaCO.idl DSC_EnginesPaCO.idl
+IDL_PACO      = SALOME_ExceptionPaCO.idl SALOME_ComponentPaCO.idl SALOME_PortsPaCO.idl DSC_EnginesPaCO.idl
 
 GEN_PACO = SALOME_ComponentPaCO_Engines_Container_server.cc \
           SALOME_ComponentPaCO_Engines_Container_client.cc \
@@ -144,7 +145,9 @@ INCLUDES_PACO = SALOME_ComponentPaCO_Engines_Container_server.h \
                SALOME_ComponentPaCO_Engines_Container_client.h \
                 SALOME_ComponentPaCO_Engines_Component_server.h \
                SALOME_ComponentPaCO_Engines_Component_client.h \
+               SALOME_ExceptionPaCO.h \
                SALOME_ComponentPaCO.h \
+               SALOME_Exception.h \
                SALOME_Component.h \
                SALOME_PortsPaCO_Ports_Port_server.h \
                SALOME_PortsPaCO_Ports_Port_client.h \
@@ -159,7 +162,7 @@ INCLUDES_PACO = SALOME_ComponentPaCO_Engines_Container_server.h \
                DSC_EnginesPaCO.h \
                DSC_Engines.h
 
-XML           = SALOME_Component.xml DSC_Engines.xml SALOME_Ports.xml
+XML           = SALOME_Exception.xml SALOME_Component.xml DSC_Engines.xml SALOME_Ports.xml
 endif
 
 idldir = $(prefix)/idl/salome
@@ -168,6 +171,7 @@ nodist_salomeinclude_HEADERS = ${INCLUDES_PACO}
 
 BUILT_SOURCES = $(IDL_SOURCES) $(PAR)
 
+SALOME_ExceptionPaCO.h SALOME_ExceptionPaCO.cc : SALOME_Exception.idl SALOME_Exception.xml
 SALOME_ComponentPaCO.h SALOME_ComponentPaCO.cc : SALOME_Component.idl SALOME_Component.xml
 SALOME_PortsPaCO.h SALOME_PortsPaCO.cc : SALOME_Ports.idl SALOME_Ports.xml
 DSC_EnginesPaCO.h DSC_EnginesPaCO.cc : DSC_Engines.idl DSC_Engines.xml
index d750af3776b2e88499f9c1be1a82e1089ab086dc..788db4bb47b1c81b12be1989d5aba2e33877691f 100644 (file)
@@ -26,6 +26,8 @@
 #ifndef _SALOME_COMPONENT_IDL_
 #define _SALOME_COMPONENT_IDL_
 
+#include "SALOME_Exception.idl"
+
 /*! \brief
 This is a package of interfaces used for connecting new components to %SALOME
 application. It also contains a set of interfaces used for management of %MED
@@ -53,6 +55,7 @@ module Engines
   interface Component ;
   interface fileRef ;
   interface fileTransfer ;
+  interface Salome_file;
 
   /*! \brief Interface of the %Container.
   This interface defines the process of loading and registration
@@ -159,6 +162,16 @@ module Engines
     */
     fileRef createFileRef(in string origFileName);
 
+    /*!
+      returns a Salome_file object if origFileName exists and is readable
+      else returns null object. 
+
+      \param origFileName name of the file to be managed (can contain the path).
+
+      \return Salome_file CORBA reference.
+    */
+    Salome_file createSalome_file(in string origFileName);
+
     /*!
       returns a fileTransfer object used to copy files from the container
       machine to the clients machines. Only one fileTransfer instance is
@@ -168,8 +181,6 @@ module Engines
 
   };
 
-
-
   /*! \brief Interface of the %component.
   This interface is used for interaction between the %container and the
   %component and between the components inside the container.
@@ -275,8 +286,98 @@ module Engines
     */    
     TMPFile DumpPython(in Object theStudy,
                       in boolean isPublished, 
-                      out boolean isValidScript); 
+                      out boolean isValidScript);
+
+    
+    /*!
+      Returns a CORBA Ref of a input Salome_file managed by a service.
+
+      \param service_name service's name.
+      \param file_name name of the requested file.
+
+      \return CORBA Ref of the requested file.
+
+      \exception contains informations of what if the component cannot 
+      sends the file's reference.
+    */
+    Engines::Salome_file getInputServiceSalome_file(in string service_name, 
+                                                   in string Salome_file_name)  raises(SALOME::SALOME_Exception);
+
+    /*!
+      This method is used before the activation of the service. It calls
+      recvFiles() on all the input Salome_file files of the service. 
+      
+      Before each recvFiles(), it uses the callback method named configureSalome_file.
+      This method allows the user to configure the files managed by the Salome_file.
+
+      By default, there is no files managed when a Salome_file is created, 
+      but the supervisor set some files managed by the Salome_file from the information contained
+      into the schema file.
+
+      \param service_name service's name.
+
+      \exception contains informations about files that are not in a good state.
+    */
+    void checkInputServiceFiles(in string service_name)                                raises(SALOME::SALOME_Exception);
+
+    /*!
+      This method adds a input Salome_file to a service of the component.
+
+      \param service_name service's name.
+      \param Salome_file_name name of the Salome_file
+
+      \return a reference of the Salome_file
+
+      \exception raises an exception if there is already
+      a Salome_file with this name for the service.
+    */
+    Engines::Salome_file setInputFileToService(in string service_name,
+                                              in string Salome_file_name)      raises(SALOME::SALOME_Exception);
+
+    /*!
+      Returns a CORBA Ref of a output Salome_file managed by a service.
+
+      \param service_name service's name.
+      \param file_name name of the requested file.
+
+      \return CORBA Ref of the requested file.
 
+      \exception contains informations of what if the component cannot 
+      sends the file's reference.
+    */
+    Engines::Salome_file getOutputServiceSalome_file(in string service_name, 
+                                                    in string Salome_file_name) raises(SALOME::SALOME_Exception);
+
+    /*!
+      This method is used at the end of the service. It calls
+      recvFiles() on all the output Salome_file files of the service. 
+      
+      Before each recvFiles(), it uses the callback method named configureSalome_file.
+      This method allows the user to configure the files managed by the Salome_file.
+
+      By default, there is no files managed when a Salome_file is created, 
+      but the supervisor set some files managed by the Salome_file from the information contained
+      into the schema file.
+
+      \param service_name service's name.
+
+      \exception contains informations about files that are not in a good state.
+    */
+    void checkOutputServiceFiles(in string service_name)                        raises(SALOME::SALOME_Exception);
+
+    /*!
+      This method adds an output Salome_file to a service of the component.
+
+      \param service_name service's name.
+      \param Salome_file_name name of the Salome_file
+
+      \return a reference of the Salome_file
+
+      \exception raises an exception if there is already
+      a Salome_file with this name for the service.
+    */
+    Engines::Salome_file setOutputFileToService(in string service_name,
+                                               in string Salome_file_name)      raises(SALOME::SALOME_Exception);
   } ;
 
   /*!
@@ -314,7 +415,161 @@ module Engines
     fileBlock getBlock(in long fileId);
   };
 
-  /*! \brief Interface of fileTransfer.
+  /*!
+    This is a file managed by a Salome_file. It contains file's name, path and status.
+    The status is : "present" or "notpresent".
+  */
+  struct file {
+    string file_name;
+    string path;
+    string type;
+    string source_file_name;
+    string status;
+  };
+
+  /*!
+    A sequence of Engines::file.
+  */
+  typedef sequence<Engines::file> files;
+
+
+  /*!
+    It is the state of a Salome_file. It contains the Salome_file's name, the name
+    of the hdf5 file where it can be saved, the number of files managed and the information
+    if all the files are received.
+  */
+  struct SfState {
+    string  name;
+    string  hdf5_file_name;
+    long    number_of_files;
+    boolean files_ok;
+  };
+
+  /*! \brief Interface of a Salome_file managed
+    This file is independent of a Salome module. It can managed one or more
+    real files. It's useful for parallel files. Currently Salome_file cannot manage
+    two files that have the same name but not the same path.
+  */
+  interface Salome_file : Engines::fileTransfer
+  {
+    /*!
+      Load a Salome_file from a hdf5 file.
+
+      \param hdf5_file name (with path) of the hdf5_file.
+
+      \exception contains informations of errors if the loading doesn't succeed.
+     */
+    void load(in string hdf5_file)                         raises (SALOME::SALOME_Exception);
+
+    /*!
+      Save a Salome_file into a hdf5_file.
+
+      \param  hdf5_file name (with path) of the hdf5_file.
+
+      \exception contains informations of errors if the save doesn't succeed.
+
+    */
+    void save(in string hdf5_file)                         raises (SALOME::SALOME_Exception);
+
+/**************/
+
+    /*!
+      Add a Local file to the Salome_file.
+
+      \param file_name name of the file with the path.
+
+      \exception raised if the file is already added into the Salome_file.
+    */
+    void setLocalFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
+
+    /*!
+      Add a Distributed file to the Salome_file.
+
+      \param comp_file_name name of the file with the path.
+      \param source_Salome_file Salome_file that managed the distributed version of the file.
+
+      \exception raised if the file is already added into the Salome_file.
+    */
+    void setDistributedFile(in string comp_file_name,
+                           in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
+
+    /*!
+      Connect the file_name with a Distributed file_name.
+
+      \param file_name name of the file without the path.
+      \param source_file_name Salome_file that managed the distributed version of the file.
+
+      \exception raised if the file doesn't exist.
+    */
+    void setDistributedSourceFile(in string file_name,
+                                 in string source_file_name) raises (SALOME::SALOME_Exception);
+
+/**************/
+
+    /*!
+      Get all the distributed files managed by the Salome_file and
+      check all the local files.
+
+      \exception raised if some of the files are not ok.
+    */
+    void recvFiles()                                       raises (SALOME::SALOME_Exception) ;
+
+/**************/
+
+    /*!
+      Remove a file of the Salome_file.
+
+      \param file_name name of the file.
+
+      \exception raised if the file doesn't exist.
+    */
+    void removeFile(in string file_name)                   raises (SALOME::SALOME_Exception);
+
+    /*!
+      Remove all the files of the Salome_file.
+    */
+    void removeFiles();
+
+    /*!
+      Delete a file managed by the Salome_file. File is removed too.
+
+      \param file_name the name of the file.
+
+      \exception raised if the file doesn't exist.
+    */
+    void deleteFile(in string file_name)                   raises (SALOME::SALOME_Exception);
+
+    /*!
+      Delete all the files managed by the Salome_file. Files are removed too.
+    */
+    void deleteFiles();
+
+/**************/
+
+    /*!
+      Get the list of the files managed by the Salome_file.
+      The list can be empty.
+    */
+    Engines::files getFilesInfos();
+
+    /*!
+      Get a file managed by the Salome_file.
+
+      \param file_name the name of the file.
+
+      \return CORBA file reference.
+
+      \exception raised if the file doesn't exist.
+    */
+    Engines::file  getFileInfos(in string file_name)       raises (SALOME::SALOME_Exception);
+
+    /*!
+      Return the state of the Salome_file.
+    */
+    Engines::SfState getSalome_fileState();
+  };
+
+  /*! \brief Interface of fileRef.
      The fileTransfer and fileRef interfaces provide a file transfer service
      between different computers.
 
diff --git a/idl/SALOME_Exception.xml b/idl/SALOME_Exception.xml
new file mode 100644 (file)
index 0000000..33d5653
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+//  Copyright (C) 2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  File   : SALOME_Exception.xml
+//  Author : Andre RIBES, EDF
+-->
+<GridCCM_Interface_description
+      xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+      xsi:noNamespaceSchemaLocation='$PACOPATH/IDL2Tool/interface.xsd'
+>
+
+
+</GridCCM_Interface_description>
index 558275659710684373c57a65df5668f7d1c0771a..630413497a2864140d9d7ddfd5772f7d535adacf 100644 (file)
@@ -833,3 +833,156 @@ Engines::TMPFile* Engines_Component_i::DumpPython(CORBA::Object_ptr theStudy,
   isValidScript = true;
   return aStreamFile._retn(); 
 }
+
+Engines::Salome_file_ptr 
+Engines_Component_i::getInputServiceSalome_file(const char* service_name, 
+                                               const char* Salome_file_name) 
+{
+  // Try to find the service, if it doesn't exist, we throw an exception.
+  _Service_file_map_it = _Input_Service_file_map.find(service_name);
+  if (_Service_file_map_it ==  _Input_Service_file_map.end()) {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::INTERNAL_ERROR;
+    es.text = "service doesn't have salome files";
+    throw SALOME::SALOME_Exception(es);
+  }
+  _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
+
+  // Try to find the Salome_file ...
+  _Salome_file_map_it = _map->find(Salome_file_name);
+  if (_Salome_file_map_it ==  _map->end()) {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::INTERNAL_ERROR;
+    es.text = "service doesn't have this Salome_file";
+    throw SALOME::SALOME_Exception(es);
+  }
+  Salome_file_i * Sfile = (*_map)[Salome_file_name];
+
+  return Sfile->_this();
+}
+
+Engines::Salome_file_ptr 
+Engines_Component_i::setInputFileToService(const char* service_name, 
+                                          const char* Salome_file_name) 
+{
+  // Try to find the service, if it doesn't exist, we add it.
+  _Service_file_map_it = _Input_Service_file_map.find(service_name);
+  if (_Service_file_map_it ==  _Input_Service_file_map.end()) {
+    _t_Salome_file_map * _map = new _t_Salome_file_map();
+    _Input_Service_file_map[service_name] = _map;
+  }
+  _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
+  
+  // Try to find the Salome_file ...
+  _Salome_file_map_it = _map->find(Salome_file_name);
+  if (_Salome_file_map_it ==  _map->end()) {
+    Salome_file_i * Sfile = new Salome_file_i();
+    (*_map)[Salome_file_name] = Sfile;
+  }
+  else {
+    // Salome_file_name already added into the service
+    // throw Exception
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::INTERNAL_ERROR;
+    es.text = "Salome_file_name already added";
+    throw SALOME::SALOME_Exception(es);
+  }
+  Salome_file_i * Sfile = (*_map)[Salome_file_name];
+
+  return Sfile->_this();
+}
+
+void 
+Engines_Component_i::checkInputServiceFiles(const char* service_name) 
+{
+  // Try to find the service, if it doesn't exist, nothing to do.
+  _Service_file_map_it = _Input_Service_file_map.find(service_name);
+  if (_Service_file_map_it !=  _Input_Service_file_map.end()) {
+    _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
+    _t_Salome_file_map::iterator begin = _map->begin();
+    _t_Salome_file_map::iterator end = _map->end();
+
+    for(;begin!=end;begin++) {
+      Salome_file_i * file = begin->second;
+      file->recvFiles();
+    }
+  }
+
+}
+
+Engines::Salome_file_ptr 
+Engines_Component_i::getOutputServiceSalome_file(const char* service_name, 
+                                               const char* Salome_file_name) 
+{
+  // Try to find the service, if it doesn't exist, we throw an exception.
+  _Service_file_map_it = _Output_Service_file_map.find(service_name);
+  if (_Service_file_map_it ==  _Output_Service_file_map.end()) {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::INTERNAL_ERROR;
+    es.text = "service doesn't have salome files";
+    throw SALOME::SALOME_Exception(es);
+  }
+  _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
+
+  // Try to find the Salome_file ...
+  _Salome_file_map_it = _map->find(Salome_file_name);
+  if (_Salome_file_map_it ==  _map->end()) {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::INTERNAL_ERROR;
+    es.text = "service doesn't have this Salome_file";
+    throw SALOME::SALOME_Exception(es);
+  }
+  Salome_file_i * Sfile = (*_map)[Salome_file_name];
+
+  return Sfile->_this();
+}
+
+Engines::Salome_file_ptr 
+Engines_Component_i::setOutputFileToService(const char* service_name, 
+                                          const char* Salome_file_name) 
+{
+  // Try to find the service, if it doesn't exist, we add it.
+  _Service_file_map_it = _Output_Service_file_map.find(service_name);
+  if (_Service_file_map_it ==  _Output_Service_file_map.end()) {
+    _t_Salome_file_map * _map = new _t_Salome_file_map();
+    _Output_Service_file_map[service_name] = _map;
+  }
+  _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
+  
+  // Try to find the Salome_file ...
+  _Salome_file_map_it = _map->find(Salome_file_name);
+  if (_Salome_file_map_it ==  _map->end()) {
+    Salome_file_i * Sfile = new Salome_file_i();
+    (*_map)[Salome_file_name] = Sfile;
+  }
+  else {
+    // Salome_file_name already added into the service
+    // throw Exception
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::INTERNAL_ERROR;
+    es.text = "Salome_file_name already added";
+    throw SALOME::SALOME_Exception(es);
+  }
+  Salome_file_i * Sfile = (*_map)[Salome_file_name];
+
+  return Sfile->_this();
+}
+
+void 
+Engines_Component_i::checkOutputServiceFiles(const char* service_name) 
+{
+  // Try to find the service, if it doesn't exist, nothing to do.
+  _Service_file_map_it = _Output_Service_file_map.find(service_name);
+  if (_Service_file_map_it !=  _Output_Service_file_map.end()) {
+    _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
+    _t_Salome_file_map::iterator begin = _map->begin();
+    _t_Salome_file_map::iterator end = _map->end();
+
+    for(;begin!=end;begin++) {
+      Salome_file_i * file = begin->second;
+      file->recvFiles();
+    }
+  }
+
+}
+
index 6e58840bc11fb2cacddcaf01a3cfda11838afe6a..799a396d7f1289ad85e1e8b19db9c5cb2362ef21 100644 (file)
@@ -44,6 +44,7 @@ int SIGUSR1 = 1000;
 #include <SALOMEconfig.h>
 //#ifndef WNT
 #include CORBA_SERVER_HEADER(SALOME_Component)
+#include CORBA_SERVER_HEADER(SALOME_Exception)
 //#else
 //#include <SALOME_Component.hh>
 //#endif
@@ -52,6 +53,7 @@ int SIGUSR1 = 1000;
 #include "SALOME_Component_i.hxx"
 #include "SALOME_FileRef_i.hxx"
 #include "SALOME_FileTransfer_i.hxx"
+#include "Salome_file_i.hxx"
 #include "SALOME_NamingService.hxx"
 #include "OpUtil.hxx"
 
@@ -667,6 +669,35 @@ Engines_Container_i::getFileTransfer()
 }
 
 
+Engines::Salome_file_ptr 
+Engines_Container_i::createSalome_file(const char* origFileName) 
+{
+  string origName(origFileName);
+  if (CORBA::is_nil(_Salome_file_map[origName]))
+    {
+      Salome_file_i* aSalome_file = new Salome_file_i();
+      try 
+      {
+       aSalome_file->setLocalFile(origFileName);
+       aSalome_file->recvFiles();
+      }
+      catch (const SALOME::SALOME_Exception& e)
+      {
+       return Engines::Salome_file::_nil();
+      }
+
+      Engines::Salome_file_var theSalome_file = Engines::Salome_file::_nil();
+      theSalome_file = Engines::Salome_file::_narrow(aSalome_file->_this());
+      _numInstanceMutex.lock() ; // lock to be alone (stl container write)
+      _Salome_file_map[origName] = theSalome_file;
+      _numInstanceMutex.unlock() ;
+    }
+  
+  Engines::Salome_file_ptr theSalome_file =  
+    Engines::Salome_file::_duplicate(_Salome_file_map[origName]);
+  ASSERT(!CORBA::is_nil(theSalome_file));
+  return theSalome_file;
+}
 //=============================================================================
 /*! 
  *  C++ method: Finds an already existing servant instance of a component, or
index d4b30879b2d86382e64b9a3c631d7c9ae0a71f15..8bcfdd45c3c3ac0d7c94763e21db56ef7485c71c 100644 (file)
@@ -42,7 +42,8 @@ salomeinclude_HEADERS = \
        SALOME_FileRef_i.hxx \
        SALOME_ContainerManager.hxx \
        Container_init_python.hxx \
-       SALOME_Container.hxx
+       SALOME_Container.hxx \
+       Salome_file_i.hxx
 
 # Scripts to be installed
 dist_salomescript_DATA =\
@@ -103,7 +104,8 @@ libSalomeContainer_la_SOURCES=\
        SALOME_FileTransfer_i.cxx \
        SALOME_FileRef_i.cxx \
        Container_init_python.cxx \
-       SALOME_ContainerManager.cxx
+       SALOME_ContainerManager.cxx \
+       Salome_file_i.cxx
 
 libSalomeContainer_la_CPPFLAGS =\
        $(COMMON_CPPFLAGS)
@@ -127,6 +129,8 @@ endif
 # ===============================================================
 #
 bin_PROGRAMS = SALOME_Container SALOME_ContainerManagerServer
+noinst_PROGRAMS = TestSalome_file
+
 SALOME_Container_SOURCES =\
        SALOME_Container.cxx \
        SALOME_Container_SignalsHandler.cxx
@@ -152,3 +156,14 @@ SALOME_ContainerManagerServer_LDADD =\
        libSalomeContainer.la \
        $(COMMON_LIBS) \
        ../Basics/libSALOMEBasics.la
+
+TestSalome_file_SOURCES =\
+       TestSalome_file.cxx
+
+TestSalome_file_CPPFLAGS =\
+       $(COMMON_CPPFLAGS)
+
+TestSalome_file_LDADD =\
+       libSalomeContainer.la \
+       $(COMMON_LIBS) \
+       ../Basics/libSALOMEBasics.la
index 3bd3f85d09dee9bd6bcba10adfa6b61116cb0989..28674d07e25876b0da24e1e01f18c3d4a1c2e333 100644 (file)
@@ -43,6 +43,7 @@
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOME_Component)
 #include "NOTIFICATION.hxx"
+#include "Salome_file_i.hxx"
 
 class RegistryConnexion;
 class Engines_Container_i;
@@ -95,7 +96,18 @@ public:
                                      CORBA::Boolean isPublished,
                                      CORBA::Boolean& isValidScript);
 
+ virtual Engines::Salome_file_ptr getInputServiceSalome_file(const char* service_name, 
+                                                            const char* Salome_file_name);
+ virtual Engines::Salome_file_ptr getOutputServiceSalome_file(const char* service_name, 
+                                                             const char* Salome_file_name);
 
+ virtual void checkInputServiceFiles(const char* service_name);
+ virtual Engines::Salome_file_ptr setInputFileToService(const char* service_name, 
+                                                       const char* Salome_file_name);
+
+ virtual void checkOutputServiceFiles(const char* service_name);
+ virtual Engines::Salome_file_ptr setOutputFileToService(const char* service_name, 
+                                                        const char* Salome_file_name);
   // --- local C++ methods
 
   PortableServer::ObjectId * getId(); 
@@ -133,6 +145,16 @@ protected:
   NOTIFICATION_Supplier* _notifSupplier;
   std::map<std::string,CORBA::Any>_fieldsDict;
 
+  // Map Salome_file_name to Salome_file*
+  typedef std::map<std::string, Salome_file_i*> _t_Salome_file_map;
+  // Map Service_name to  _Salome_file_map
+  typedef std::map<std::string, Engines_Component_i::_t_Salome_file_map*> _t_Service_file_map;
+  
+  _t_Service_file_map _Input_Service_file_map;
+  _t_Service_file_map _Output_Service_file_map;
+  _t_Service_file_map::iterator _Service_file_map_it;
+  _t_Salome_file_map::iterator _Salome_file_map_it;
+
   std::string _serviceName ;
   std::string _graphName ;
   std::string _nodeName ;
index fe32eba833a6861eff225314225f5a4aee6706a3..03c27e0d5b0bb6d642ae04b3394504cce458ecb2 100644 (file)
@@ -92,7 +92,7 @@ public:
   Engines::fileRef_ptr createFileRef(const char* origFileName);
   Engines::fileTransfer_ptr getFileTransfer();
 
-
+  virtual Engines::Salome_file_ptr createSalome_file(const char* origFileName);
   // --- local C++ methods
 
   Engines::Component_ptr
@@ -131,6 +131,7 @@ protected:
   int _numInstance ;
   std::map<std::string,Engines::Component_var> _listInstances_map;
   std::map<std::string,Engines::fileRef_var> _fileRef_map;
+  std::map<std::string,Engines::Salome_file_var> _Salome_file_map;
   Engines::fileTransfer_var _fileTransfer;
 
   int    _argc ;
diff --git a/src/Container/Salome_file_i.cxx b/src/Container/Salome_file_i.cxx
new file mode 100644 (file)
index 0000000..2636f37
--- /dev/null
@@ -0,0 +1,468 @@
+// Copyright (C) 2007  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+//  File   : Salome_file_i.cxx
+//  Author : André RIBES, EDF
+//  Module : SALOME
+//  $Header: 
+
+#include "Salome_file_i.hxx"
+#include "utilities.h"
+#include <stdlib.h>
+#include <unistd.h>
+
+//=============================================================================
+/*! 
+ *  Default constructor,
+ */
+//=============================================================================
+
+Salome_file_i::Salome_file_i()
+{
+  _fileId = 0;
+  _path_max = 1 + pathconf("/", _PC_PATH_MAX);
+  _state.name = CORBA::string_dup("");
+  _state.hdf5_file_name = CORBA::string_dup("");
+  _state.number_of_files = 0;
+  _state.files_ok = true;
+}
+
+//=============================================================================
+/*! 
+ *  Destructor
+ */
+//=============================================================================
+
+Salome_file_i::~Salome_file_i()
+{
+}
+
+void 
+Salome_file_i::load(const char* hdf5_file) {
+  MESSAGE("Salome_file_i::load : NOT YET IMPLEMENTED");
+  _state.hdf5_file_name = CORBA::string_dup(hdf5_file);
+}
+
+void 
+Salome_file_i::save(const char* hdf5_file) {
+  MESSAGE("Salome_file_i::save : NOT YET IMPLEMENTED");
+  _state.hdf5_file_name = CORBA::string_dup(hdf5_file);
+}
+
+void 
+Salome_file_i::setLocalFile(const char* comp_file_name)
+{
+  std::string file_name("");
+  std::string path("");
+  std::string type("local");
+  std::string source_file_name("");
+  std::string status("not_ok");
+
+  std::string cp_file_name(comp_file_name);
+  std::size_t index = cp_file_name.rfind("/");
+  if (index != -1)
+  {
+    file_name = cp_file_name.substr(index+1);
+    path =  cp_file_name.substr(0,index+1);
+  }
+  else
+  {
+    file_name = comp_file_name;
+    char CurrentPath[_path_max];
+    getcwd(CurrentPath, _path_max);
+    path = CurrentPath;
+  }
+
+  // Test if this file is already added
+  _t_fileManaged::iterator it = _fileManaged.find(file_name);
+  if (it != _fileManaged.end()) 
+  {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::INTERNAL_ERROR;
+    std::string text = "file already added";
+    es.text = CORBA::string_dup(text.c_str());
+    throw SALOME::SALOME_Exception(es);
+  }
+
+  // Test if the file is ok
+  if(fopen(comp_file_name,"rb") != NULL)
+    status = "ok";
+
+  // Adding file with is informations
+  Engines::file infos;
+  infos.file_name = CORBA::string_dup(file_name.c_str());
+  infos.path = CORBA::string_dup(path.c_str());
+  infos.type = CORBA::string_dup(type.c_str());
+  infos.source_file_name = CORBA::string_dup(source_file_name.c_str());
+  infos.status = CORBA::string_dup(status.c_str());
+
+  _fileManaged[file_name] = infos;
+
+  // Update Salome_file state
+  _state.number_of_files++;
+  if (status != "ok")
+    _state.files_ok = false;
+}
+
+void 
+Salome_file_i::setDistributedFile(const char* comp_file_name, 
+                                 Engines::Salome_file_ptr source_Salome_file)
+{
+  std::string file_name("");
+  std::string path("");
+  std::string type("distributed");
+  std::string source_file_name("");
+  std::string status("not_ok");
+
+  std::string cp_file_name(comp_file_name);
+  std::size_t index = cp_file_name.rfind("/");
+  if (index != -1)
+  {
+    file_name = cp_file_name.substr(index+1);
+    path =  cp_file_name.substr(0,index+1);
+  }
+  else
+  {
+    file_name = comp_file_name;
+    char CurrentPath[_path_max];
+    getcwd(CurrentPath, _path_max);
+    path = CurrentPath;
+  }
+
+  // Test if this file is already added
+  _t_fileManaged::iterator it = _fileManaged.find(file_name);
+  if (it != _fileManaged.end()) 
+  {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::INTERNAL_ERROR;
+    std::string text = "file already added";
+    es.text = CORBA::string_dup(text.c_str());
+    throw SALOME::SALOME_Exception(es);
+  }
+
+  // Adding file with is informations
+  Engines::file infos;
+  infos.file_name = CORBA::string_dup(file_name.c_str());
+  infos.path = CORBA::string_dup(path.c_str());
+  infos.type = CORBA::string_dup(type.c_str());
+  infos.source_file_name = CORBA::string_dup(source_file_name.c_str());
+  infos.status = CORBA::string_dup(status.c_str());
+
+  _fileManaged[file_name] = infos;
+  _fileDistributedSource[file_name] = Engines::Salome_file::_duplicate(source_Salome_file);
+
+  // Update Salome_file state
+  _state.number_of_files++;
+  _state.files_ok = false;
+}
+
+void 
+Salome_file_i::setDistributedSourceFile(const char* file_name,
+                                       const char * source_file_name)
+{
+  std::string fname(file_name);
+
+  // Test if this file is managed
+  _t_fileManaged::iterator it = _fileManaged.find(fname);
+  if (it == _fileManaged.end()) 
+  {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::INTERNAL_ERROR;
+    std::string text = "file is not managed";
+    es.text = CORBA::string_dup(text.c_str());
+    throw SALOME::SALOME_Exception(es);
+  }
+
+  _fileManaged[fname].source_file_name = CORBA::string_dup(source_file_name);
+}
+
+void 
+Salome_file_i::recvFiles() {
+  
+  std::string files_not_ok("");
+
+  _t_fileManaged::iterator begin = _fileManaged.begin();
+  _t_fileManaged::iterator end = _fileManaged.end();
+  for(;begin!=end;begin++) 
+  {
+    bool result = true;
+    Engines::file file_infos = begin->second;
+    if (std::string(file_infos.type.in()) == "local")
+    {
+      if (std::string(file_infos.status.in()) == "not_ok")
+       result = checkLocalFile(file_infos.file_name.in());
+    }
+    else
+    {
+      if (std::string(file_infos.status.in()) == "not_ok")
+       result = getDistributedFile(file_infos.file_name.in());
+    }
+    if (!result) 
+    {
+      files_not_ok.append(" ");
+      files_not_ok.append(file_infos.file_name.in());
+    }
+  }
+
+  if (files_not_ok != "")
+  {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::INTERNAL_ERROR;
+    std::string text = "files not ready : " + files_not_ok;
+    es.text = CORBA::string_dup(text.c_str());
+    throw SALOME::SALOME_Exception(es);
+  }
+
+  // We change the state of the Salome_file
+  _state.files_ok = true;
+}
+
+bool
+Salome_file_i::checkLocalFile(std::string file_name)
+{
+  bool result = true;
+
+  std::string comp_file_name(_fileManaged[file_name].path.in());
+  comp_file_name.append(_fileManaged[file_name].file_name.in());
+  if(fopen(comp_file_name.c_str(),"rb") == NULL)
+  {
+    INFOS("file " << comp_file_name << " cannot be open for reading");
+    _fileManaged[file_name].status = CORBA::string_dup("not_ok");
+    result = false;
+  }
+
+  if (result)
+  {
+    _fileManaged[file_name].status = CORBA::string_dup("ok");
+  }
+  return result;
+}
+
+bool
+Salome_file_i::getDistributedFile(std::string file_name)
+{
+  bool result = true;
+  const char * source_file_name = _fileManaged[file_name].source_file_name.in();
+  int fileId;
+  FILE* fp;
+  std::string comp_file_name(_fileManaged[file_name].path.in());
+  comp_file_name.append(_fileManaged[file_name].file_name.in());
+
+  if ((fp = fopen(comp_file_name.c_str(),"wb")) == NULL)
+  {
+    INFOS("file " << comp_file_name << " cannot be open for writing");
+    _fileManaged[file_name].status = CORBA::string_dup("not_ok");
+    result = false;
+    return result;
+  }
+
+  try 
+  {
+    fileId = _fileDistributedSource[file_name]->open(source_file_name);
+  }
+  catch (...) 
+  {
+    _fileManaged[file_name].status = CORBA::string_dup("not_ok");
+    fclose(fp);
+    result = false;
+    return result;
+  }
+
+  if (fileId > 0)
+  {
+    Engines::fileBlock* aBlock;
+    int toFollow = 1;
+    int ctr=0;
+    MESSAGE("begin of transfer of " << comp_file_name);
+    while (toFollow)
+    {
+      ctr++;
+      aBlock = _fileDistributedSource[file_name]->getBlock(fileId);
+      toFollow = aBlock->length();
+      CORBA::Octet *buf = aBlock->get_buffer();
+      int nbWri = fwrite(buf, sizeof(CORBA::Octet), toFollow, fp);
+      ASSERT(nbWri == toFollow);
+    }
+    fclose(fp);
+    MESSAGE("end of transfer of " << comp_file_name);
+    _fileDistributedSource[file_name]->close(fileId);
+  }
+  else
+  {
+    INFOS("open reference file for copy impossible");
+    result = false;
+    fclose(fp);
+    _fileManaged[file_name].status = CORBA::string_dup("not_ok");
+    return result;
+  }
+
+  _fileManaged[file_name].status = CORBA::string_dup("ok");
+  return result;
+}
+
+void 
+Salome_file_i::removeFile(const char* file_name) 
+{
+  MESSAGE("Salome_file_i::removeFile : NOT YET IMPLEMENTED");
+}
+    
+void 
+Salome_file_i::deleteFile(const char* file_name) {
+  MESSAGE("Salome_file_i::deleteFile : NOT YET IMPLEMENTED");
+}
+
+void 
+Salome_file_i::removeFiles() {
+  MESSAGE("Salome_file_i::removeFiles : NOT YET IMPLEMENTED");
+}
+
+void 
+Salome_file_i::deleteFiles() {
+  MESSAGE("Salome_file_i::deleteFiles : NOT YET IMPLEMENTED");
+}
+
+Engines::files* 
+Salome_file_i::getFilesInfos() {
+
+  Engines::files * infos = new Engines::files();
+  infos->length(_fileManaged.size());
+
+  _t_fileManaged::iterator begin = _fileManaged.begin();
+  _t_fileManaged::iterator end = _fileManaged.end();
+  int i = 0;
+  for(;begin!=end;begin++) {
+    (*infos)[i] = *(new Engines::file(begin->second));
+    i++;
+  }
+  return infos;
+}
+
+Engines::file* 
+Salome_file_i::getFileInfos(const char* file_name) {
+
+  std::string fname(file_name);
+
+  // Test if this file is managed
+  _t_fileManaged::iterator it = _fileManaged.find(fname);
+  if (it == _fileManaged.end()) 
+  {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::INTERNAL_ERROR;
+    es.text = "file is not managed";
+    throw SALOME::SALOME_Exception(es);
+  }
+
+  Engines::file * infos = new Engines::file(_fileManaged[fname]);
+  return infos;
+}
+
+Engines::SfState* 
+Salome_file_i::getSalome_fileState() 
+{
+  return new Engines::SfState(_state);
+}
+
+//=============================================================================
+/*! 
+ *  CORBA method: try to open the file given. If the file is readable, return
+ *  a positive integer else return 0;
+ *  \param  fileName path to the file to be transfered
+ *  \return fileId = positive integer > 0 if open OK.
+ */
+//=============================================================================
+
+CORBA::Long 
+Salome_file_i::open(const char* file_name)
+{
+  int aKey = 0;
+
+  std::string fname(file_name);
+  _t_fileManaged::iterator it = _fileManaged.find(fname);
+  if (it == _fileManaged.end())
+  {
+    return aKey;
+  }
+  
+  std::string comp_file_name(_fileManaged[file_name].path.in());
+  comp_file_name.append(_fileManaged[file_name].file_name.in());
+  MESSAGE("Salome_file_i::open " << comp_file_name);
+  FILE* fp;
+  if ((fp = fopen(comp_file_name.c_str(),"rb")) == NULL)
+    {
+      INFOS("file " << comp_file_name << " is not readable");
+      return aKey;
+    }
+
+  aKey = ++_fileId;
+  _fileAccess[aKey] = fp;
+  return aKey;
+}
+
+//=============================================================================
+/*! 
+ *  CORBA method: close the file associated to the fileId given at open.
+ *  \param fileId got in return from open method
+ */
+//=============================================================================
+
+void 
+Salome_file_i::close(CORBA::Long fileId)
+{
+  MESSAGE("Salome_file_i::close");
+  FILE* fp;
+  if (!(fp = _fileAccess[fileId]) )
+    {
+      INFOS(" no FILE structure associated to fileId " << fileId);
+    }
+  else fclose(fp);
+}
+
+//=============================================================================
+/*! 
+ *  CORBA method: get a block of data from the file associated to the fileId
+ *  given at open.
+ *  \param fileId got in return from open method
+ *  \return an octet sequence. Last one is empty.
+ */
+//=============================================================================
+
+#define FILEBLOCK_SIZE 256*1024
+
+Engines::fileBlock* 
+Salome_file_i::getBlock(CORBA::Long fileId)
+{
+  Engines::fileBlock* aBlock = new Engines::fileBlock;
+
+  FILE* fp;
+  if (! (fp = _fileAccess[fileId]) )
+  {
+    INFOS(" no FILE structure associated to fileId " <<fileId);
+    return aBlock;
+  }
+
+  // use replace member function for sequence to avoid copy
+  // see Advanced CORBA Programming with C++ pp 187-194
+  CORBA::Octet *buf;
+  buf = Engines::fileBlock::allocbuf(FILEBLOCK_SIZE);
+  int nbRed = fread(buf, sizeof(CORBA::Octet), FILEBLOCK_SIZE, fp);
+  aBlock->replace(nbRed, nbRed, buf, 1); // 1 means give ownership
+  return aBlock;
+}
+
diff --git a/src/Container/Salome_file_i.hxx b/src/Container/Salome_file_i.hxx
new file mode 100644 (file)
index 0000000..51652a2
--- /dev/null
@@ -0,0 +1,94 @@
+// Copyright (C) 2007  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+//  File   : Salome_file_i.hxx
+//  Author : André RIBES, EDF
+//  Module : SALOME
+//  $Header: 
+
+#ifndef _SALOME_FILE_I_HXX_
+#define _SALOME_FILE_I_HXX_
+
+#include <SALOMEconfig.h>
+
+#include CORBA_SERVER_HEADER(SALOME_Component)
+#include CORBA_SERVER_HEADER(SALOME_Exception)
+
+#include <SALOME_Container.hxx>
+#include <map>
+#include <cstdio>
+
+class CONTAINER_EXPORT Salome_file_i:
+  public virtual POA_Engines::Salome_file
+{
+  public:
+    Salome_file_i();
+    virtual ~Salome_file_i();
+
+    // Import and export methods
+    virtual void load(const char* hdf5_file);
+    virtual void save(const char* hdf5_file);
+
+    // Adding files
+    virtual void setLocalFile(const char* comp_file_name);
+    virtual void setDistributedFile(const char* comp_file_name, 
+                                   Engines::Salome_file_ptr source_Salome_file);
+    virtual void setDistributedSourceFile(const char* file_name,
+                                         const char * source_file_name);
+
+    // Recv and check files
+    virtual void recvFiles();
+
+    // Removing or deleting files
+    virtual void removeFile(const char* file_name);
+    virtual void deleteFile(const char* file_name);
+    virtual void removeFiles();
+    virtual void deleteFiles();
+
+
+    // Informations methods
+    virtual Engines::files* getFilesInfos();
+    virtual Engines::file* getFileInfos(const char* file_name);
+    virtual Engines::SfState* getSalome_fileState();
+
+    // ---------------- fileTransfert Methods -----------------------
+    virtual CORBA::Long open(const char* file_name);
+    virtual void close(CORBA::Long fileId);
+    virtual Engines::fileBlock* getBlock(CORBA::Long fileId);
+
+  protected:    
+    // ---------------- local C++ methods ---------------------------
+    virtual bool checkLocalFile(std::string file_name);
+    virtual bool getDistributedFile(std::string file_name);
+
+  protected:
+    typedef std::map<int, FILE*> _t_fileAccess;
+    typedef std::map<std::string, Engines::file> _t_fileManaged;
+    typedef std::map<std::string, Engines::Salome_file_var> _t_fileDistributedSource;
+
+    int _fileId;
+    long _path_max;
+    _t_fileAccess _fileAccess;
+    _t_fileManaged _fileManaged;
+    _t_fileDistributedSource _fileDistributedSource;
+    Engines::SfState _state;
+};
+
+#endif
diff --git a/src/Container/TestSalome_file.cxx b/src/Container/TestSalome_file.cxx
new file mode 100644 (file)
index 0000000..69a6d36
--- /dev/null
@@ -0,0 +1,112 @@
+#include "Salome_file_i.hxx"
+#include <iostream>
+#include <fstream>
+#include <sstream>
+
+using namespace std;
+
+void print_infos(Engines::file * infos) 
+{
+  cerr << "-------------------------------------------------------------------" << endl;
+  cerr << "file_name = " << infos->file_name << endl;
+  cerr << "path = " << infos->path << endl;
+  cerr << "type = " << infos->type << endl;
+  cerr << "source_file_name = " << infos->source_file_name << endl;
+  cerr << "status = " << infos->status << endl;
+}
+
+void print_state(Engines::SfState * state) 
+{
+  cerr << "-------------------------------------------------------------------" << endl;
+  cerr << "name = " << state->name << endl;
+  cerr << "hdf5_file_name = " <<  state->name << endl;
+  cerr << "number_of_files = " <<  state->number_of_files << endl;
+  cerr << "files_ok = " <<  state->files_ok << endl;
+}
+
+
+int main (int argc, char * argv[])
+{
+  Salome_file_i file;
+  Salome_file_i file2;
+  Engines::file * infos;
+  Engines::SfState * state;
+  Engines::files * all_infos;
+  PortableServer::POA_var root_poa;
+  PortableServer::POAManager_var pman;
+  CORBA::Object_var obj;
+
+  cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
+  cerr << "Test of setLocalFile()" << endl;
+  file.setLocalFile("/tmp/toto");
+  infos = file.getFileInfos("toto");
+  print_infos(infos);
+
+
+  cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
+  cerr << "Test of getFilesInfos()" << endl;
+  all_infos = file.getFilesInfos();
+  for (int i = 0; i < all_infos->length(); i++)
+  {
+    print_infos(&((*all_infos)[i]));
+  }
+
+  cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
+  cerr << "Test of getSalome_fileState()" << endl;
+  state = file.getSalome_fileState();
+  print_state(state);
+
+  // We start CORBA ...
+  CORBA::ORB_ptr orb = CORBA::ORB_init(argc , argv);
+  obj = orb->resolve_initial_references("RootPOA");
+  root_poa = PortableServer::POA::_narrow(obj);
+  pman = root_poa->the_POAManager();
+  pman->activate();
+
+  file2.setLocalFile("/tmp/toto_distributed_source");
+  Engines::Salome_file_ptr file2_ref = file2._this();
+
+  cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
+  cerr << "Test of setDistributedFile()" << endl;
+  file.setDistributedFile("/tmp/toto_distributed", file2_ref);
+  file.setDistributedSourceFile("toto_distributed", "toto_distributed_source");
+  infos = file.getFileInfos("toto_distributed");
+  print_infos(infos);
+
+  // We create the files ... 
+  std::ostringstream oss;
+  oss << "/tmp/toto";
+  std::ofstream f(oss.str().c_str());
+  if (f) 
+    f << "blablabla" << std::endl;
+  std::ostringstream oss2;
+  oss2 << "/tmp/toto_distributed_source";
+  std::ofstream f2(oss2.str().c_str());
+  if (f2) 
+    f2 << "bliblibli" << std::endl;
+
+  try 
+  {
+    file.recvFiles();
+  }
+  catch (SALOME::SALOME_Exception & e)
+  {
+    cerr << "Exception : " << e.details.text << endl;
+  }
+
+  cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
+  cerr << "Test of getFilesInfos()" << endl;
+  all_infos = file.getFilesInfos();
+  for (int i = 0; i < all_infos->length(); i++)
+  {
+    print_infos(&((*all_infos)[i]));
+  }
+
+  cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
+  cerr << "Test of getSalome_fileState()" << endl;
+  state = file.getSalome_fileState();
+  print_state(state);
+
+  orb->destroy();
+}
index 0e04b8a165bb5237f2d383cb3715dd296793f080..3f8655e9b58055f2a5725830e4b48766943f960a 100644 (file)
@@ -59,6 +59,7 @@ COMMON_CPPFLAGS= -I$(top_srcdir)/src/Container \
 # This local variable defines the list of dependant libraries common to all target in this package.
 COMMON_LIBS = $(top_builddir)/src/Container/libSalomeContainer.la \
              $(top_builddir)/idl/libSalomeParallelIDLKernel.la \
+             $(top_builddir)/idl/libSalomeIDLKernel.la \
              @CORBA_LIBS@ \
              @PACO_LIBS@
 
@@ -70,7 +71,8 @@ COMMON_LIBS = $(top_builddir)/src/Container/libSalomeContainer.la \
 lib_LTLIBRARIES = libSalomeParallelContainer.la 
 
 libSalomeParallelContainer_la_SOURCES  = SALOME_ParallelComponent_i.cxx \
-                                        SALOME_ParallelContainer_i.cxx 
+                                        SALOME_ParallelContainer_i.cxx \
+                                        $(top_srcdir)/src/Container/Salome_file_i.cxx
 
 libSalomeParallelContainer_la_CXXFLAGS = $(COMMON_CPPFLAGS)
 
@@ -96,22 +98,28 @@ bin_PROGRAMS = SALOME_ParallelContainerProxyDummy \
 SALOME_ParallelContainerProxyDummy_SOURCES  = SALOME_ParallelContainerProxyDummy.cxx
 SALOME_ParallelContainerProxyDummy_CXXFLAGS = $(COMMON_CPPFLAGS)
 SALOME_ParallelContainerProxyDummy_LDADD    = libSalomeParallelContainer.la \
-                                             -L@PACOPATH@/lib -lPaCO_dummy -lPaCO_omnithread
+                                             -L@PACOPATH@/lib -lPaCO_dummy -lPaCO_omnithread \
+                                             $(COMMON_LIBS)
 
 SALOME_ParallelContainerNodeDummy_SOURCES  = SALOME_ParallelContainerNodeDummy.cxx
 SALOME_ParallelContainerNodeDummy_CXXFLAGS = $(COMMON_CPPFLAGS)
 SALOME_ParallelContainerNodeDummy_LDADD    = libSalomeParallelContainer.la \
-                                            -L@PACOPATH@/lib -lPaCO_dummy -lPaCO_omnithread
+                                            -L@PACOPATH@/lib -lPaCO_dummy -lPaCO_omnithread \
+                                             $(COMMON_LIBS)
 
 SALOME_ParallelContainerProxyMpi_SOURCES  = SALOME_ParallelContainerProxyMpi.cxx
 SALOME_ParallelContainerProxyMpi_CXXFLAGS = $(COMMON_CPPFLAGS) @MPI_INCLUDES@
 SALOME_ParallelContainerProxyMpi_LDADD    = libSalomeParallelContainer.la \
                                            -L@PACOPATH@/lib -lPaCO_dummy -lPaCO_mpi -lPaCO_omnithread \
-                                           @MPI_LIBS@
+                                           @MPI_LIBS@ \
+                                           $(COMMON_LIBS)
+
 
 SALOME_ParallelContainerNodeMpi_SOURCES  = SALOME_ParallelContainerNodeMpi.cxx
 SALOME_ParallelContainerNodeMpi_CXXFLAGS = $(COMMON_CPPFLAGS) @MPI_INCLUDES@
 SALOME_ParallelContainerNodeMpi_LDADD    = libSalomeParallelContainer.la \
                                           -L@PACOPATH@/lib -lPaCO_dummy -lPaCO_mpi -lPaCO_omnithread \
-                                          @MPI_LIBS@
+                                          @MPI_LIBS@\
+                                          $(COMMON_LIBS)
+
 
index ce7b79f0f090fcd5c06e7bbcd3146d65d278bd6c..c046a2c9f413dbc1ffb8824608c056805d8b66e7 100644 (file)
 
 using namespace std;
 
-#ifdef DEBUG_PARALLEL
+#ifdef _DEBUG_
 #include <signal.h>
 
+void test(int sigval) {
+       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+       cerr << "SIGSEGV in :" << getpid() << endl;
+       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+       while (1) {}
+}
+
 void handler(int t) {
        cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
        cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
@@ -70,15 +79,17 @@ int main(int argc, char* argv[])
 {
        INFOS("Launching a parallel Mpi container node");
 
-#ifdef DEBUG_PARALLEL
-       signal(SIGSEGV, handler);
+#ifdef _DEBUG_
+       struct sigaction action;
+       action.sa_handler = &test;
+       sigaction(SIGSEGV, &action, NULL);
 #endif
        
        // MPI Init
        int provided;
        MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE ,&provided);
 
-#ifdef DEBUG_PARALLEL
+#ifdef _DEBUG_
        cerr << "Level MPI_THREAD_SINGLE : " << MPI_THREAD_SINGLE << endl;
        cerr << "Level MPI_THREAD_SERIALIZED : " << MPI_THREAD_SERIALIZED << endl;
        cerr << "Level MPI_THREAD_FUNNELED : " << MPI_THREAD_FUNNELED << endl;
index f9f22e483567bd09157ecebbd2e4284579dfb624..b2b81b7b5fd4eddcbf2805bdd8751778c963808b 100644 (file)
@@ -991,4 +991,33 @@ Engines_Parallel_Container_i::getFileTransfer()
 }
 
 
+Engines::Salome_file_ptr 
+Engines_Parallel_Container_i::createSalome_file(const char* origFileName) 
+{
+  string origName(origFileName);
+  if (CORBA::is_nil(_Salome_file_map[origName]))
+    {
+      Salome_file_i* aSalome_file = new Salome_file_i();
+      try 
+      {
+       aSalome_file->setLocalFile(origFileName);
+       aSalome_file->recvFiles();
+      }
+      catch (const SALOME::SALOME_Exception& e)
+      {
+       return Engines::Salome_file::_nil();
+      }
+
+      Engines::Salome_file_var theSalome_file = Engines::Salome_file::_nil();
+      theSalome_file = Engines::Salome_file::_narrow(aSalome_file->_this());
+      _numInstanceMutex.lock() ; // lock to be alone (stl container write)
+      _Salome_file_map[origName] = theSalome_file;
+      _numInstanceMutex.unlock() ;
+    }
+  
+  Engines::Salome_file_ptr theSalome_file =  
+    Engines::Salome_file::_duplicate(_Salome_file_map[origName]);
+  ASSERT(!CORBA::is_nil(theSalome_file));
+  return theSalome_file;
+}
 
index 254d607401776a8ac931ca867691ebd4d019de21..962bc9a1dc2f84604269d412b9e7db6023568301 100644 (file)
@@ -129,6 +129,8 @@ public:
 
   Engines::fileRef_ptr createFileRef(const char* origFileName);
   Engines::fileTransfer_ptr getFileTransfer();
+
+  virtual Engines::Salome_file_ptr createSalome_file(const char* origFileName);
 protected:
 
   static std::map<std::string, int> _cntInstances_map;
@@ -147,6 +149,7 @@ protected:
   int _numInstance ;
   std::map<std::string,Engines::Component_var> _listInstances_map;
   std::map<std::string,Engines::fileRef_var> _fileRef_map;
+  std::map<std::string,Engines::Salome_file_var> _Salome_file_map;
   Engines::fileTransfer_var _fileTransfer;
 
   int    _argc ;