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