Salome HOME
Merging from V4_1_0_maintainance for porting on Win32 Platform
[modules/kernel.git] / src / Container / Salome_file_i.hxx
1 // Copyright (C) 2007  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 //  This library is free software; you can redistribute it and/or 
4 //  modify it under the terms of the GNU Lesser General Public 
5 //  License as published by the Free Software Foundation; either 
6 //  version 2.1 of the License. 
7 // 
8 //  This library is distributed in the hope that it will be useful, 
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 //  Lesser General Public License for more details. 
12 // 
13 //  You should have received a copy of the GNU Lesser General Public 
14 //  License along with this library; if not, write to the Free Software 
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
16 // 
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 //
20 //
21 //  File   : Salome_file_i.hxx
22 //  Author : AndrĂ© RIBES, EDF
23 //  Module : SALOME
24 //  $Header: 
25
26 #ifndef _SALOME_FILE_I_HXX_
27 #define _SALOME_FILE_I_HXX_
28
29 #include <SALOMEconfig.h>
30
31 #include CORBA_SERVER_HEADER(SALOME_Component)
32 #include CORBA_SERVER_HEADER(SALOME_Exception)
33
34 #include "SALOME_Container.hxx"
35 #include <map>
36 #include <cstdio>
37
38 class CONTAINER_EXPORT Salome_file_i:
39   public virtual POA_Engines::Salome_file
40 {
41   public:
42     Salome_file_i();
43     virtual ~Salome_file_i();
44
45     // Import and export methods
46     virtual void load(const char* hdf5_file);
47     virtual void save(const char* hdf5_file);
48     virtual void save_all(const char* hdf5_file);
49
50     // Adding files
51     virtual void setLocalFile(const char* comp_file_name);
52     virtual void setDistributedFile(const char* comp_file_name);
53
54     // Configure DistributedFile
55     virtual void connect(Engines::Salome_file_ptr source_Salome_file);
56     virtual void connectDistributedFile(const char * file_name,
57                                         Engines::Salome_file_ptr source_Salome_file);
58     virtual void setDistributedSourceFile(const char* file_name,
59                                           const char * source_file_name);
60
61     // Recv and check files
62     virtual void recvFiles();
63
64     // Removing or deleting files
65     virtual void removeFile(const char* file_name);
66     virtual void removeFiles();
67
68     // Informations methods:
69     virtual void setContainer(Engines::Container_ptr container);
70     virtual Engines::files* getFilesInfos();
71     virtual Engines::file* getFileInfos(const char* file_name);
72     virtual Engines::SfState* getSalome_fileState();
73
74     // ---------------- fileTransfert Methods -----------------------
75     virtual CORBA::Long open(const char* file_name);
76     virtual void close(CORBA::Long fileId);
77     virtual Engines::fileBlock* getBlock(CORBA::Long fileId);
78
79   protected:    
80     // ---------------- local C++ methods ---------------------------
81     virtual bool checkLocalFile(std::string file_name);
82     virtual bool getDistributedFile(std::string file_name);
83
84   protected:
85
86     // Contains a relation between a file ID (int) with
87     // a fd descriptor (FILE*) open on the file.
88     typedef std::map<int, FILE*> _t_fileAccess;
89
90     // Contains the informations of the files managed by the Salome_file.
91     typedef std::map<std::string, Engines::file> _t_fileManaged;
92
93     // Contains the CORBA reference for each distributed file managed.
94     typedef std::map<std::string, Engines::Salome_file_var> _t_fileDistributedSource;
95
96     int _fileId;
97     long _path_max;
98     _t_fileAccess _fileAccess;
99     _t_fileManaged _fileManaged;
100     _t_fileDistributedSource _fileDistributedSource;
101     Engines::SfState _state;
102     Engines::Container_ptr _container;
103     Engines::Salome_file_var _default_source_Salome_file;
104 };
105
106 #endif