SALOME documentation central

src/Container/Salome_file_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 //  File   : Salome_file_i.hxx
00023 //  Author : André RIBES, EDF
00024 //  Module : SALOME
00025 //  $Header: 
00026 //
00027 #ifndef _SALOME_FILE_I_HXX_
00028 #define _SALOME_FILE_I_HXX_
00029 
00030 #include <SALOMEconfig.h>
00031 
00032 #include CORBA_SERVER_HEADER(SALOME_Component)
00033 #include CORBA_SERVER_HEADER(SALOME_Exception)
00034 
00035 #include "SALOME_Container.hxx"
00036 #include "SALOME_FileTransfer_i.hxx"
00037 
00038 #include <map>
00039 #include <cstdio>
00040 #include <string>
00041 
00042 class CONTAINER_EXPORT Salome_file_i:
00043   public virtual POA_Engines::Salome_file,public virtual fileTransfer_i
00044 {
00045   public:
00046     Salome_file_i();
00047     virtual ~Salome_file_i();
00048 
00049     // Import and export methods
00050     virtual void load(const char* hdf5_file);
00051     virtual void save(const char* hdf5_file);
00052     virtual void save_all(const char* hdf5_file);
00053 
00054     // Adding files
00055     virtual void setLocalFile(const char* comp_file_name);
00056     virtual void setDistributedFile(const char* comp_file_name);
00057 
00058     // Configure DistributedFile
00059     virtual void connect(Engines::Salome_file_ptr source_Salome_file);
00060     virtual void connectDistributedFile(const char * file_name,
00061                                         Engines::Salome_file_ptr source_Salome_file);
00062     virtual void setDistributedSourceFile(const char* file_name,
00063                                           const char * source_file_name);
00064 
00065     // Recv and check files
00066     virtual void recvFiles();
00067 
00068     // Removing or deleting files
00069     virtual void removeFile(const char* file_name);
00070     virtual void removeFiles();
00071 
00072     // Informations methods:
00073     virtual void setContainer(Engines::Container_ptr container);
00074     virtual Engines::files* getFilesInfos();
00075     virtual Engines::file* getFileInfos(const char* file_name);
00076     virtual Engines::SfState* getSalome_fileState();
00077 
00078     // ---------------- fileTransfert Methods -----------------------
00079     virtual CORBA::Long open(const char* file_name);
00080     virtual void close(CORBA::Long fileId);
00081     virtual Engines::fileBlock* getBlock(CORBA::Long fileId);
00082 
00083   protected:    
00084     // ---------------- local C++ methods ---------------------------
00085     virtual bool checkLocalFile(std::string file_name);
00086     virtual bool getDistributedFile(std::string file_name);
00087 
00088   protected:
00089 
00090     // Contains a relation between a file ID (int) with
00091     // a fd descriptor (FILE*) open on the file.
00092     typedef std::map<int, FILE*> _t_fileAccess;
00093 
00094     // Contains the informations of the files managed by the Salome_file.
00095     typedef std::map<std::string, Engines::file> _t_fileManaged;
00096 
00097     // Contains the CORBA reference for each distributed file managed.
00098     typedef std::map<std::string, Engines::Salome_file_var> _t_fileDistributedSource;
00099 
00100     int _fileId;
00101     long _path_max;
00102     _t_fileAccess _fileAccess;
00103     _t_fileManaged _fileManaged;
00104     _t_fileDistributedSource _fileDistributedSource;
00105     Engines::SfState _state;
00106     Engines::Container_ptr _container;
00107     Engines::Salome_file_var _default_source_Salome_file;
00108 };
00109 
00110 #endif