Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / MEDMEM / MEDMEM_MedMedDriver.cxx
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 #include "MEDMEM_MedMedDriver.hxx"
23 #include "MEDMEM_Compatibility21_22.hxx"
24 #include "MEDMEM_MedMedDriver21.hxx"
25 #include "MEDMEM_MedMedDriver22.hxx"
26 #include "MEDMEM_DriverFactory.hxx" 
27 #include "MEDMEM_define.hxx"
28
29 using namespace std;
30 using namespace MED_EN;
31 using namespace MEDMEM;
32
33 MED_MED_DRIVER::MED_MED_DRIVER(): GENDRIVER(MED_DRIVER), 
34                                   _ptrMed(0),
35                                   _concreteMedDrv(0)
36 {}
37
38 MED_MED_DRIVER::MED_MED_DRIVER(const string & fileName,  MED * const ptrMed):
39   GENDRIVER(fileName, MED_EN::RDWR, MED_DRIVER),
40   _ptrMed(ptrMed),
41   _concreteMedDrv(0)
42 {
43   //_ptrMed->addDriver(*this); // The specific MED driver id is set within the addDriver method.
44 }
45
46 MED_MED_DRIVER::MED_MED_DRIVER(const string & fileName,
47                                MED * const ptrMed,
48                                MED_EN::med_mode_acces accessMode):
49   GENDRIVER(fileName, accessMode, MED_DRIVER),
50   _ptrMed(ptrMed),
51   _concreteMedDrv(0)
52 {
53 }
54 //REM :  As t'on besoin du champ _status :  _medIdt <-> _status  ?  Oui
55
56 MED_MED_DRIVER::MED_MED_DRIVER(const MED_MED_DRIVER & driver):
57   GENDRIVER(driver),
58   _ptrMed(driver._ptrMed)
59   //  _concreteMedDrv(driver._concreteMedDrv->copy())
60 {
61   if ( driver._concreteMedDrv )
62     _concreteMedDrv = driver._concreteMedDrv->copy();
63   else 
64     _concreteMedDrv=0;
65 }
66
67 MED_MED_DRIVER::~MED_MED_DRIVER()
68 {
69   MESSAGE_MED("MED_MED_DRIVER::~MED_MED_DRIVER() has been destroyed");
70   if (_concreteMedDrv) delete _concreteMedDrv;
71   _concreteMedDrv=0;
72 }
73
74 // ------------- Read Only Part --------------
75
76 IMED_MED_RDONLY_DRIVER::IMED_MED_RDONLY_DRIVER():MED_MED_DRIVER(),_fileStructIsRead(false)
77 {
78 }
79
80 IMED_MED_RDONLY_DRIVER::IMED_MED_RDONLY_DRIVER(const string & fileName,  MED * const ptrMed):
81   MED_MED_DRIVER(fileName,ptrMed,MED_EN::RDONLY),_fileStructIsRead(false)
82 {
83   MESSAGE_MED("MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName,  MED * const ptrMed) Constructeur read only");
84 }
85
86 IMED_MED_RDONLY_DRIVER::IMED_MED_RDONLY_DRIVER(const IMED_MED_RDONLY_DRIVER & driver):
87   MED_MED_DRIVER(driver),_fileStructIsRead(false)
88 {
89 }
90
91 IMED_MED_RDONLY_DRIVER::~IMED_MED_RDONLY_DRIVER()
92 {
93   MESSAGE_MED("MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER() has been destroyed");
94
95
96 void IMED_MED_RDONLY_DRIVER::write(void) const
97   throw (MEDEXCEPTION)
98 {
99   throw MEDEXCEPTION("MED_MED_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
100 }
101
102 void IMED_MED_RDONLY_DRIVER::writeFrom(void) const
103   throw (MEDEXCEPTION)
104 {
105   throw MEDEXCEPTION("MED_MED_RDONLY_DRIVER::writeFrom : Can't write with a RDONLY driver !");
106 }
107
108 // ------------- Write Only Part --------------
109
110 IMED_MED_WRONLY_DRIVER::IMED_MED_WRONLY_DRIVER()
111 {
112 }
113
114 IMED_MED_WRONLY_DRIVER::IMED_MED_WRONLY_DRIVER(const string & fileName,  MED * const ptrMed):
115   MED_MED_DRIVER(fileName,ptrMed,MED_EN::WRONLY)
116 {}
117
118 IMED_MED_WRONLY_DRIVER::IMED_MED_WRONLY_DRIVER(const IMED_MED_WRONLY_DRIVER & driver):
119   MED_MED_DRIVER(driver)
120 {}
121
122 IMED_MED_WRONLY_DRIVER::~IMED_MED_WRONLY_DRIVER()
123 {
124   MESSAGE_MED("MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER() has been destroyed");
125
126
127 void IMED_MED_WRONLY_DRIVER::read(void)
128   throw (MEDEXCEPTION)
129 {
130   throw MEDEXCEPTION("MED_MED_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
131 }
132
133 void IMED_MED_WRONLY_DRIVER::readFileStruct(void)
134   throw (MEDEXCEPTION)
135 {
136   throw MEDEXCEPTION("MED_MED_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
137 }
138
139 // ------------- Read Write Part --------------
140
141 IMED_MED_RDWR_DRIVER::IMED_MED_RDWR_DRIVER()
142 {}
143
144 IMED_MED_RDWR_DRIVER::IMED_MED_RDWR_DRIVER(const string & fileName,  MED * const ptrMed):
145   IMED_MED_RDONLY_DRIVER(fileName,ptrMed),IMED_MED_WRONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER(fileName,ptrMed,RDWR)
146 {}
147
148 IMED_MED_RDWR_DRIVER::IMED_MED_RDWR_DRIVER(const IMED_MED_RDWR_DRIVER & driver):
149   IMED_MED_RDONLY_DRIVER(driver),IMED_MED_WRONLY_DRIVER(driver),MED_MED_DRIVER(driver)
150 {}
151
152 IMED_MED_RDWR_DRIVER::~IMED_MED_RDWR_DRIVER() { 
153   MESSAGE_MED("MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() has been destroyed");
154 }
155
156 MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER()
157 {
158   MESSAGE_MED("You are using the default constructor of the Med read only Driver and it is 2.1 one");
159   _concreteMedDrv = new MED_MED_RDONLY_DRIVER21();
160 }
161
162 MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName,  MED * const ptrMed):IMED_MED_RDONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER(fileName,ptrMed,RDONLY)
163 {
164   _concreteMedDrv = DRIVERFACTORY::buildMedDriverFromFile(fileName,ptrMed,RDONLY);
165 }
166
167 MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const MED_MED_RDONLY_DRIVER & driver):MED_MED_DRIVER(driver)
168 {
169 }
170
171 MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER()
172 {
173 }
174
175 void MED_MED_RDONLY_DRIVER::write          ( void ) const throw (MEDEXCEPTION)
176 {
177   _concreteMedDrv->write();
178 }
179
180 void MED_MED_RDONLY_DRIVER::writeFrom      ( void ) const throw (MEDEXCEPTION)
181 {
182   _concreteMedDrv->writeFrom();
183 }
184
185 void MED_MED_RDONLY_DRIVER::open() throw (MEDEXCEPTION)
186 {
187   _concreteMedDrv->open();
188 }
189
190 void MED_MED_RDONLY_DRIVER::close()
191 {
192   _concreteMedDrv->close();
193 }
194 void MED_MED_RDONLY_DRIVER::read           ( void )
195 {
196   _concreteMedDrv->read();
197 }
198
199 void MED_MED_RDONLY_DRIVER::readFileStruct ( void )
200 {
201   _concreteMedDrv->readFileStruct();
202 }
203
204 GENDRIVER * MED_MED_RDONLY_DRIVER::copy ( void ) const
205 {
206   return new MED_MED_RDONLY_DRIVER(*this);
207 }
208
209 MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER()
210 {
211   MESSAGE_MED("You are using the default constructor of the Med write only Driver and it is 2.1 one");
212
213   _concreteMedDrv = new MED_MED_WRONLY_DRIVER21();
214 }
215
216 MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const string & fileName,  MED * const ptrMed):IMED_MED_WRONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER(fileName,ptrMed,WRONLY)
217 {
218   _concreteMedDrv = DRIVERFACTORY::buildMedDriverFromFile(fileName,ptrMed,WRONLY);
219 }
220
221 MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const MED_MED_WRONLY_DRIVER & driver):MED_MED_DRIVER(driver)
222 {
223 }
224
225 MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER()
226 {
227 }
228
229 void MED_MED_WRONLY_DRIVER::write          ( void ) const throw (MEDEXCEPTION)
230 {
231   _concreteMedDrv->write();
232 }
233
234 void MED_MED_WRONLY_DRIVER::writeFrom      ( void ) const throw (MEDEXCEPTION)
235 {
236   _concreteMedDrv->writeFrom();
237 }
238
239 void MED_MED_WRONLY_DRIVER::open() throw (MEDEXCEPTION)
240 {
241   _concreteMedDrv->open();
242 }
243
244 void MED_MED_WRONLY_DRIVER::close()
245 {
246   _concreteMedDrv->close();
247 }
248
249 void MED_MED_WRONLY_DRIVER::read           ( void ) throw (MEDEXCEPTION) 
250 {
251   _concreteMedDrv->read();
252 }
253
254 void MED_MED_WRONLY_DRIVER::readFileStruct ( void ) throw (MEDEXCEPTION) 
255 {
256   _concreteMedDrv->readFileStruct();
257 }
258
259 GENDRIVER * MED_MED_WRONLY_DRIVER::copy ( void ) const
260 {
261   return _concreteMedDrv->copy();
262 }
263
264 MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER()
265 {
266   MESSAGE_MED("You are using the default constructor of the Med read write Driver and it is 2.1 one");
267   _concreteMedDrv = new MED_MED_RDWR_DRIVER21();
268 }
269
270 MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER(const string & fileName,  MED * const ptrMed):IMED_MED_RDWR_DRIVER(fileName,ptrMed),MED_MED_DRIVER(fileName,ptrMed,RDWR)
271 {
272   _concreteMedDrv = DRIVERFACTORY::buildMedDriverFromFile(fileName,ptrMed,RDWR);
273 }
274
275 MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER(const MED_MED_RDWR_DRIVER & driver):
276   MED_MED_DRIVER(driver)
277 {
278 }
279
280 MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER()
281 {
282 }
283
284 void MED_MED_RDWR_DRIVER::write          ( void ) const throw (MEDEXCEPTION)
285 {
286   _concreteMedDrv->write();
287 }
288
289 void MED_MED_RDWR_DRIVER::writeFrom      ( void ) const throw (MEDEXCEPTION)
290 {
291   _concreteMedDrv->writeFrom();
292 }
293
294 void MED_MED_RDWR_DRIVER::open() throw (MEDEXCEPTION)
295 {
296   _concreteMedDrv->open();
297 }
298
299 void MED_MED_RDWR_DRIVER::close()
300 {
301   _concreteMedDrv->close();
302 }
303
304 void MED_MED_RDWR_DRIVER::read           ( void ) throw (MEDEXCEPTION) 
305 {
306   _concreteMedDrv->read();
307 }
308
309 void MED_MED_RDWR_DRIVER::readFileStruct ( void ) throw (MEDEXCEPTION) 
310 {
311   _concreteMedDrv->readFileStruct();
312 }
313
314 GENDRIVER * MED_MED_RDWR_DRIVER::copy ( void ) const
315 {
316   return _concreteMedDrv->copy();
317 }