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