Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / src / MEDMEM / MEDMEM_TypeMeshDriver.hxx
1 // Copyright (C) 2007-2012  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
23 #ifndef TYPE_MESH_DRIVER_HXX
24 #define TYPE_MESH_DRIVER_HXX
25
26 #include "MEDMEM.hxx"
27
28 #include <string>
29 #include <vector>
30
31 #include "MEDMEM_define.hxx"
32 #include "MEDMEM_GenDriver.hxx"
33
34 #include "MEDMEM_STRING.hxx"
35 #include "MEDMEM_Exception.hxx"
36 #include "MEDMEM_Utilities.hxx"
37
38 /*!
39
40   Driver TYPE for MESH.
41
42   Generic part : implement the readopen and close methods.
43   
44 */
45
46
47 namespace MEDMEM {
48 class MESH;
49 class FAMILY;
50 class GROUP;
51 class CONNECTIVITY;
52 class MEDMEM_EXPORT TYPE_MESH_DRIVER : public GENDRIVER
53 {
54 protected:
55   
56   MESH *          _ptrMesh;
57   // A VOIR FILE DESCRIPTEUR ? MED_FR::med_idt _medIdt;
58   string          _meshName;    
59   
60 public :
61
62   /*!
63     Constructor.
64   */
65   TYPE_MESH_DRIVER() ;
66   /*!
67     Constructor.
68   */
69   TYPE_MESH_DRIVER(const std::string & fileName,  
70                   MESH * ptrMesh, 
71                   med_mode_acces accessMode) ;
72   /*!
73     Copy constructor.
74   */
75   TYPE_MESH_DRIVER(const TYPE_MESH_DRIVER & driver) ;
76
77   /*!
78     Destructor.
79   */
80   virtual ~TYPE_MESH_DRIVER() ;
81
82   void open() throw (MEDEXCEPTION);
83   void close() throw (MEDEXCEPTION);
84
85   virtual void write( void ) const = 0 ;
86   virtual void read ( void ) = 0 ;
87
88   /*!
89     Set the name of the MESH asked in file.
90
91     It could be different than the name of the MESH object.
92   */
93   void   setMeshName(const string & meshName) ;
94   /*!
95     Get the name of the MESH asked in file.
96   */
97   string getMeshName() const ;
98
99 private:
100   virtual GENDRIVER * copy ( void ) const = 0 ;
101
102 };
103
104
105 class MEDMEM_EXPORT TYPE_MESH_RDONLY_DRIVER : public virtual TYPE_MESH_DRIVER
106 {
107  
108 public :
109   
110   /*!
111     Constructor.
112   */
113   TYPE_MESH_RDONLY_DRIVER() ;
114   /*!
115     Constructor.
116   */
117   TYPE_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
118   /*!
119     Copy constructor.
120   */
121   TYPE_MESH_RDONLY_DRIVER(const TYPE_MESH_RDONLY_DRIVER & driver) ;
122
123   /*!
124     Destructor.
125   */
126   virtual ~TYPE_MESH_RDONLY_DRIVER() ;
127   
128   /*!
129     Return a MEDEXCEPTION : it is the read-only driver.
130   */
131   void write( void ) const throw (MEDEXCEPTION);
132   /*!
133     Read MESH in the specified file.
134   */
135   void read ( void ) throw (MEDEXCEPTION);
136
137 private:
138  
139   GENDRIVER * copy ( void ) const ;
140
141 };
142
143 /*!
144
145   Driver Med for MESH : Write only.
146
147   Implement write method.
148
149 */
150
151 class MEDMEM_EXPORT TYPE_MESH_WRONLY_DRIVER : public virtual TYPE_MESH_DRIVER {
152   
153 public :
154   
155   /*!
156     Constructor.
157   */
158   TYPE_MESH_WRONLY_DRIVER() ;
159   /*!
160     Constructor.
161   */
162   TYPE_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
163   /*!
164     Copy constructor.
165   */
166   TYPE_MESH_WRONLY_DRIVER(const TYPE_MESH_WRONLY_DRIVER & driver) ;
167
168   /*!
169     Destructor.
170   */
171   virtual ~TYPE_MESH_WRONLY_DRIVER() ;
172
173   /*!
174     Write MESH in the specified file.
175   */
176   void write( void ) const throw (MEDEXCEPTION);
177   /*!
178     Return a MEDEXCEPTION : it is the write-only driver.
179   */
180   void read ( void ) throw (MEDEXCEPTION);
181
182 private:
183
184   GENDRIVER * copy ( void ) const ;
185 };
186
187
188 /*!
189
190   Driver TYPE for MESH : Read write.
191   - Use read method from TYPE_MESH_RDONLY_DRIVER
192   - Use write method from TYPE_MESH_WRONLY_DRIVER
193
194 */
195
196 class MEDMEM_EXPORT TYPE_MESH_RDWR_DRIVER : public TYPE_MESH_RDONLY_DRIVER, public TYPE_MESH_WRONLY_DRIVER {
197
198 public :
199
200   /*!
201     Constructor.
202   */
203   TYPE_MESH_RDWR_DRIVER() ;
204   /*!
205     Constructor.
206   */
207   TYPE_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ;
208   /*!
209     Copy constructor.
210   */
211   TYPE_MESH_RDWR_DRIVER(const TYPE_MESH_RDWR_DRIVER & driver) ;
212
213   /*!
214     Destructor.
215   */
216   ~TYPE_MESH_RDWR_DRIVER() ;
217
218   /*!
219     Write MESH in the specified file.
220   */
221   void write(void) const throw (MEDEXCEPTION);
222   /*!
223     Read MESH in the specified file.
224   */
225   void read (void) throw (MEDEXCEPTION);
226
227 private:
228   GENDRIVER * copy(void) const ;
229
230 };
231 };
232
233
234 #endif /* TYPE_MESH_DRIVER_HXX */