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