Salome HOME
sources v1.2
[modules/med.git] / src / MEDMEM / MEDMEM_MedMedDriver.hxx
1 //  MED MEDMEM : MED files in memory
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : MEDMEM_MedMedDriver.hxx
25 //  Module : MED
26
27 #ifndef MED_MED_DRIVER_HXX
28 #define MED_MED_DRIVER_HXX
29
30 #include <string>
31 #include "MEDMEM_STRING.hxx"
32 #include "utilities.h"
33 #include "MEDMEM_Exception.hxx"
34
35 #include "MEDMEM_GenDriver.hxx"
36
37 #include "MEDMEM_define.hxx"
38
39 //using namaspace MED_FR ;
40
41 class MESH;
42 class FIELD_;
43 class MED;
44
45 /*!
46
47   Driver Med for MED.
48
49   Generic part : implement open and close methods.
50
51 */
52
53 // This driver pilots within a MED class read/write accesses of fields/meshes
54 class MED_MED_DRIVER : public GENDRIVER
55 {
56 protected:
57   
58   MED * const       _ptrMed;         // Store 'MED_DRIVER (0..n)----(1) MED' associations
59   med_idt           _medIdt;         // The _medIdt used to write/read Meshes to ::_filename
60    
61   //private:
62   //  MED_MED_DRIVER();
63
64 public :
65   /*!
66     Constructor.
67   */
68   MED_MED_DRIVER();
69   /*!
70     Constructor.
71   */
72   MED_MED_DRIVER(const string & fileName,  MED * const ptrMed);
73   /*!
74     Constructor.
75   */
76   MED_MED_DRIVER(const string & fileName,  MED * const ptrMed,
77                  MED_EN::med_mode_acces accessMode);
78
79   // OPERATEUR DE RECOPIE AVEC _medIdt ??
80   /*!
81     Copy constructor.
82   */
83   MED_MED_DRIVER(const MED_MED_DRIVER & driver);
84
85   /*!
86     Destructor.
87   */
88   virtual ~MED_MED_DRIVER() ;
89
90   void open() throw (MEDEXCEPTION) ;
91   void close();
92
93   //virtual void write          ( void ) const = 0 ;
94   virtual void write          ( void ) const ;
95   //virtual void writeFrom      ( void ) const = 0 ;
96   virtual void writeFrom      ( void ) const  ;
97   //virtual void read           ( void ) = 0 ;
98   virtual void read           ( void )  ;
99   //virtual void readFileStruct ( void ) = 0 ;
100   virtual void readFileStruct ( void ) ;
101
102 private:
103   //virtual GENDRIVER * copy ( void ) const = 0 ;
104   virtual GENDRIVER * copy ( void ) const  ;
105
106 };
107
108 /*!
109
110   Driver Med for MED : Read only.
111
112   Implement read method.
113
114 */
115
116 class MED_MED_RDONLY_DRIVER : public virtual MED_MED_DRIVER
117 {
118 public :
119   /*!
120     Constructor.
121   */
122   MED_MED_RDONLY_DRIVER();
123   /*!
124     Constructor.
125   */
126   MED_MED_RDONLY_DRIVER(const string & fileName,  MED * const ptrMed);
127   /*!
128     Copy constructor.
129   */
130   MED_MED_RDONLY_DRIVER(const MED_MED_RDONLY_DRIVER & driver);
131
132   /*!
133     Destructor.
134   */
135   virtual ~MED_MED_RDONLY_DRIVER();
136
137   /*!
138     Return a MEDEXCEPTION : it is the read-only driver.
139   */
140   void write          ( void ) const throw (MEDEXCEPTION) ;
141   /*!
142     Return a MEDEXCEPTION : it is the read-only driver.
143   */
144   void writeFrom      ( void ) const throw (MEDEXCEPTION) ;
145   /*!
146     Read all from the file.
147   */
148   void read           ( void ) throw (MEDEXCEPTION);
149   /*!
150     Read only table of contents of the file.
151
152     All objects are created but there values are not read.
153   */
154   void readFileStruct ( void ) throw (MEDEXCEPTION) ;
155
156 private:
157   virtual GENDRIVER * copy ( void ) const ;
158
159 };
160
161 /*!
162
163   Driver Med for MED : Write only.
164
165   Implement write method.
166
167 */
168
169 class MED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER
170 {
171
172 public :
173   /*!
174     Constructor.
175   */
176   MED_MED_WRONLY_DRIVER();
177   /*!
178     Constructor.
179   */
180   MED_MED_WRONLY_DRIVER(const string & fileName,  MED * const ptrMed);
181   /*!
182     Copy constructor.
183   */
184   MED_MED_WRONLY_DRIVER(const MED_MED_WRONLY_DRIVER & driver);
185
186   /*!
187     Destructor.
188   */
189   virtual ~MED_MED_WRONLY_DRIVER();
190
191   /*!
192     Write all in file.
193   */
194   void write          ( void ) const throw (MEDEXCEPTION);
195   /*!
196     Write only objects created from this MED driver in file.
197   */
198   void writeFrom      ( void ) const throw (MEDEXCEPTION);
199   /*!
200     Return a MEDEXCEPTION : it is the write-only driver.
201   */
202   void read           ( void ) throw (MEDEXCEPTION) ;
203   /*!
204     Return a MEDEXCEPTION : it is the write-only driver.
205   */
206   void readFileStruct ( void ) throw (MEDEXCEPTION) ;
207
208 private:
209   virtual GENDRIVER * copy ( void ) const ;
210
211 };
212
213 /*!
214
215   Driver Med for MED : Read write.
216   - Use read method from MED_MED_RDONLY_DRIVER
217   - Use write method from MED_MED_WDONLY_DRIVER
218
219 */
220
221 class MED_MED_RDWR_DRIVER : public virtual MED_MED_RDONLY_DRIVER,
222                             public virtual MED_MED_WRONLY_DRIVER
223 {
224
225 public :
226   /*!
227     Constructor.
228   */
229   MED_MED_RDWR_DRIVER();
230   /*!
231     Constructor.
232   */
233   MED_MED_RDWR_DRIVER(const string & fileName,  MED * const ptrMed);
234   /*!
235     Copy constructor.
236   */
237   MED_MED_RDWR_DRIVER(const MED_MED_RDWR_DRIVER & driver);
238
239   /*!
240     Destructor.
241   */
242   ~MED_MED_RDWR_DRIVER();
243
244   /*!
245     Write all in file.
246   */
247   void write          ( void ) const throw (MEDEXCEPTION);
248   /*!
249     Write only objects created from this MED driver in file.
250   */
251   void writeFrom      ( void ) const throw (MEDEXCEPTION);
252   /*!
253     Read all from the file.
254   */
255   void read           ( void ) throw (MEDEXCEPTION);
256   /*!
257     Read only table of contents of the file.
258
259     All objects are created but there values are not read.
260   */
261   void readFileStruct ( void ) throw (MEDEXCEPTION);
262
263 private:
264   virtual GENDRIVER * copy ( void ) const ;
265
266 };
267
268 #endif /* MED_MED_DRIVER_HXX */