Salome HOME
updated copyright message
[modules/kernel.git] / src / Container / Salome_file_i.hxx
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
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, or (at your option) any later version.
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 //  File   : Salome_file_i.hxx
21 //  Author : AndrĂ© RIBES, EDF
22 //  Module : SALOME
23 //  $Header: 
24 //
25 #ifndef _SALOME_FILE_I_HXX_
26 #define _SALOME_FILE_I_HXX_
27
28 #include <SALOMEconfig.h>
29
30 #include CORBA_SERVER_HEADER(SALOME_Component)
31 #include CORBA_SERVER_HEADER(SALOME_Exception)
32
33 #include "SALOME_Container.hxx"
34 #include "SALOME_FileTransfer_i.hxx"
35
36 #include <map>
37 #include <cstdio>
38 #include <string>
39
40 class CONTAINER_EXPORT Salome_file_i:
41   public virtual POA_Engines::Salome_file,public virtual fileTransfer_i
42 {
43   public:
44     Salome_file_i();
45     virtual ~Salome_file_i();
46
47     // Import and export methods
48     virtual void load(const char* hdf5_file);
49     virtual void save(const char* hdf5_file);
50     virtual void save_all(const char* hdf5_file);
51
52     // Adding files
53     virtual void setLocalFile(const char* comp_file_name);
54     virtual void setDistributedFile(const char* comp_file_name);
55
56     // Configure DistributedFile
57     virtual void connect(Engines::Salome_file_ptr source_Salome_file);
58     virtual void connectDistributedFile(const char * file_name,
59                                         Engines::Salome_file_ptr source_Salome_file);
60     virtual void setDistributedSourceFile(const char* file_name,
61                                           const char * source_file_name);
62
63     // Recv and check files
64     virtual void recvFiles();
65
66     // Removing or deleting files
67     virtual void removeFile(const char* file_name);
68     virtual void removeFiles();
69
70     // Information methods:
71     virtual void setContainer(Engines::Container_ptr container);
72     virtual Engines::files* getFilesInfos();
73     virtual Engines::file* getFileInfos(const char* file_name);
74     virtual Engines::SfState* getSalome_fileState();
75
76     // ---------------- fileTransfert Methods -----------------------
77     virtual CORBA::Long open(const char* file_name);
78     virtual void close(CORBA::Long fileId);
79     virtual Engines::fileBlock* getBlock(CORBA::Long fileId);
80
81   protected:    
82     // ---------------- local C++ methods ---------------------------
83     virtual bool checkLocalFile(std::string file_name);
84     virtual bool getDistributedFile(std::string file_name);
85
86   protected:
87
88     // Contains a relation between a file ID (int) with
89     // a fd descriptor (FILE*) open on the file.
90     typedef std::map<int, FILE*> _t_fileAccess;
91
92     // Contains the information of the files managed by the Salome_file.
93     typedef std::map<std::string, Engines::file> _t_fileManaged;
94
95     // Contains the CORBA reference for each distributed file managed.
96     typedef std::map<std::string, Engines::Salome_file_var> _t_fileDistributedSource;
97
98     int _fileId;
99     long _path_max;
100     _t_fileAccess _fileAccess;
101     _t_fileManaged _fileManaged;
102     _t_fileDistributedSource _fileDistributedSource;
103     Engines::SfState _state;
104     Engines::Container_ptr _container;
105     Engines::Salome_file_var _default_source_Salome_file;
106 };
107
108 #endif