Back to index

salome-kernel  6.5.0
Salome_file_i.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 //  File   : Salome_file_i.hxx
00021 //  Author : André RIBES, EDF
00022 //  Module : SALOME
00023 //  $Header: 
00024 //
00025 #ifndef _SALOME_FILE_I_HXX_
00026 #define _SALOME_FILE_I_HXX_
00027 
00028 #include <SALOMEconfig.h>
00029 
00030 #include CORBA_SERVER_HEADER(SALOME_Component)
00031 #include CORBA_SERVER_HEADER(SALOME_Exception)
00032 
00033 #include "SALOME_Container.hxx"
00034 #include "SALOME_FileTransfer_i.hxx"
00035 
00036 #include <map>
00037 #include <cstdio>
00038 #include <string>
00039 
00040 class CONTAINER_EXPORT Salome_file_i:
00041   public virtual POA_Engines::Salome_file,public virtual fileTransfer_i
00042 {
00043   public:
00044     Salome_file_i();
00045     virtual ~Salome_file_i();
00046 
00047     // Import and export methods
00048     virtual void load(const char* hdf5_file);
00049     virtual void save(const char* hdf5_file);
00050     virtual void save_all(const char* hdf5_file);
00051 
00052     // Adding files
00053     virtual void setLocalFile(const char* comp_file_name);
00054     virtual void setDistributedFile(const char* comp_file_name);
00055 
00056     // Configure DistributedFile
00057     virtual void connect(Engines::Salome_file_ptr source_Salome_file);
00058     virtual void connectDistributedFile(const char * file_name,
00059                                         Engines::Salome_file_ptr source_Salome_file);
00060     virtual void setDistributedSourceFile(const char* file_name,
00061                                           const char * source_file_name);
00062 
00063     // Recv and check files
00064     virtual void recvFiles();
00065 
00066     // Removing or deleting files
00067     virtual void removeFile(const char* file_name);
00068     virtual void removeFiles();
00069 
00070     // Informations methods:
00071     virtual void setContainer(Engines::Container_ptr container);
00072     virtual Engines::files* getFilesInfos();
00073     virtual Engines::file* getFileInfos(const char* file_name);
00074     virtual Engines::SfState* getSalome_fileState();
00075 
00076     // ---------------- fileTransfert Methods -----------------------
00077     virtual CORBA::Long open(const char* file_name);
00078     virtual void close(CORBA::Long fileId);
00079     virtual Engines::fileBlock* getBlock(CORBA::Long fileId);
00080 
00081   protected:    
00082     // ---------------- local C++ methods ---------------------------
00083     virtual bool checkLocalFile(std::string file_name);
00084     virtual bool getDistributedFile(std::string file_name);
00085 
00086   protected:
00087 
00088     // Contains a relation between a file ID (int) with
00089     // a fd descriptor (FILE*) open on the file.
00090     typedef std::map<int, FILE*> _t_fileAccess;
00091 
00092     // Contains the informations of the files managed by the Salome_file.
00093     typedef std::map<std::string, Engines::file> _t_fileManaged;
00094 
00095     // Contains the CORBA reference for each distributed file managed.
00096     typedef std::map<std::string, Engines::Salome_file_var> _t_fileDistributedSource;
00097 
00098     int _fileId;
00099     long _path_max;
00100     _t_fileAccess _fileAccess;
00101     _t_fileManaged _fileManaged;
00102     _t_fileDistributedSource _fileDistributedSource;
00103     Engines::SfState _state;
00104     Engines::Container_ptr _container;
00105     Engines::Salome_file_var _default_source_Salome_file;
00106 };
00107 
00108 #endif