Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/med.git] / src / MEDMEM / MEDMEM_TypeMeshDriver.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 #ifndef TYPE_MESH_DRIVER_HXX
21 #define TYPE_MESH_DRIVER_HXX
22
23 #include "MEDMEM.hxx"
24
25 #include <string>
26 #include <vector>
27
28 #include "MEDMEM_define.hxx"
29 #include "MEDMEM_GenDriver.hxx"
30
31 #include "MEDMEM_STRING.hxx"
32 #include "MEDMEM_Exception.hxx"
33 #include "MEDMEM_Utilities.hxx"
34
35 /*!
36
37   Driver TYPE for MESH.
38
39   Generic part : implement the readopen and close methods.
40   
41 */
42
43
44 namespace MEDMEM {
45 class MESH;
46 class FAMILY;
47 class GROUP;
48 class CONNECTIVITY;
49 class MEDMEM_EXPORT TYPE_MESH_DRIVER : public GENDRIVER
50 {
51 protected:
52   
53   MESH *          _ptrMesh;
54   // A VOIR FILE DESCRIPTEUR ? MED_FR::med_idt _medIdt;
55   string          _meshName;    
56   
57 public :
58
59   /*!
60     Constructor.
61   */
62   TYPE_MESH_DRIVER() ;
63   /*!
64     Constructor.
65   */
66   TYPE_MESH_DRIVER(const std::string & fileName,  
67                   MESH * ptrMesh, 
68                   med_mode_acces accessMode) ;
69   /*!
70     Copy constructor.
71   */
72   TYPE_MESH_DRIVER(const TYPE_MESH_DRIVER & driver) ;
73
74   /*!
75     Destructor.
76   */
77   virtual ~TYPE_MESH_DRIVER() ;
78
79   void open() throw (MEDEXCEPTION);
80   void close() throw (MEDEXCEPTION);
81
82   virtual void write( void ) const = 0 ;
83   virtual void read ( void ) = 0 ;
84
85   /*!
86     Set the name of the MESH asked in file.
87
88     It could be different than the name of the MESH object.
89   */
90   void   setMeshName(const string & meshName) ;
91   /*!
92     Get the name of the MESH asked in file.
93   */
94   string getMeshName() const ;
95
96 private:
97   virtual GENDRIVER * copy ( void ) const = 0 ;
98
99 };
100
101
102 class MEDMEM_EXPORT TYPE_MESH_RDONLY_DRIVER : public virtual TYPE_MESH_DRIVER
103 {
104  
105 public :
106   
107   /*!
108     Constructor.
109   */
110   TYPE_MESH_RDONLY_DRIVER() ;
111   /*!
112     Constructor.
113   */
114   TYPE_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
115   /*!
116     Copy constructor.
117   */
118   TYPE_MESH_RDONLY_DRIVER(const TYPE_MESH_RDONLY_DRIVER & driver) ;
119
120   /*!
121     Destructor.
122   */
123   virtual ~TYPE_MESH_RDONLY_DRIVER() ;
124   
125   /*!
126     Return a MEDEXCEPTION : it is the read-only driver.
127   */
128   void write( void ) const throw (MEDEXCEPTION);
129   /*!
130     Read MESH in the specified file.
131   */
132   void read ( void ) throw (MEDEXCEPTION);
133
134 private:
135  
136   GENDRIVER * copy ( void ) const ;
137
138 };
139
140 /*!
141
142   Driver Med for MESH : Write only.
143
144   Implement write method.
145
146 */
147
148 class MEDMEM_EXPORT TYPE_MESH_WRONLY_DRIVER : public virtual TYPE_MESH_DRIVER {
149   
150 public :
151   
152   /*!
153     Constructor.
154   */
155   TYPE_MESH_WRONLY_DRIVER() ;
156   /*!
157     Constructor.
158   */
159   TYPE_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
160   /*!
161     Copy constructor.
162   */
163   TYPE_MESH_WRONLY_DRIVER(const TYPE_MESH_WRONLY_DRIVER & driver) ;
164
165   /*!
166     Destructor.
167   */
168   virtual ~TYPE_MESH_WRONLY_DRIVER() ;
169
170   /*!
171     Write MESH in the specified file.
172   */
173   void write( void ) const throw (MEDEXCEPTION);
174   /*!
175     Return a MEDEXCEPTION : it is the write-only driver.
176   */
177   void read ( void ) throw (MEDEXCEPTION);
178
179 private:
180
181   GENDRIVER * copy ( void ) const ;
182 };
183
184
185 /*!
186
187   Driver TYPE for MESH : Read write.
188   - Use read method from TYPE_MESH_RDONLY_DRIVER
189   - Use write method from TYPE_MESH_WRONLY_DRIVER
190
191 */
192
193 class MEDMEM_EXPORT TYPE_MESH_RDWR_DRIVER : public TYPE_MESH_RDONLY_DRIVER, public TYPE_MESH_WRONLY_DRIVER {
194
195 public :
196
197   /*!
198     Constructor.
199   */
200   TYPE_MESH_RDWR_DRIVER() ;
201   /*!
202     Constructor.
203   */
204   TYPE_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ;
205   /*!
206     Copy constructor.
207   */
208   TYPE_MESH_RDWR_DRIVER(const TYPE_MESH_RDWR_DRIVER & driver) ;
209
210   /*!
211     Destructor.
212   */
213   ~TYPE_MESH_RDWR_DRIVER() ;
214
215   /*!
216     Write MESH in the specified file.
217   */
218   void write(void) const throw (MEDEXCEPTION);
219   /*!
220     Read MESH in the specified file.
221   */
222   void read (void) throw (MEDEXCEPTION);
223
224 private:
225   GENDRIVER * copy(void) const ;
226
227 };
228 };
229
230
231 #endif /* TYPE_MESH_DRIVER_HXX */