]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_DriverFactory.cxx
Salome HOME
update due to bugs PAL8113 and another I do not remember the number ;) .
[modules/med.git] / src / MEDMEM / MEDMEM_DriverFactory.cxx
1 #include "MEDMEM_DriverFactory.hxx"
2
3 #include "MEDMEM_Mesh.hxx"
4 #include "MEDMEM_MedMeshDriver.hxx"
5 #include "MEDMEM_GibiMeshDriver.hxx"
6 #include "MEDMEM_PorflowMeshDriver.hxx"
7 #include "MEDMEM_VtkMeshDriver.hxx"
8
9 #include "MEDMEM_Med.hxx"
10 #include "MEDMEM_MedMedDriver.hxx"
11 #include "MEDMEM_VtkMedDriver.hxx"
12
13 //#include "MEDMEM_Field.hxx"
14
15 #include "MEDMEM_Exception.hxx"
16 //#include "MEDMEM_STRING.hxx"
17 //#include "utilities.h"
18
19 using namespace MEDMEM;
20 using namespace MED_EN;
21
22 GENDRIVER *DRIVERFACTORY::buildDriverForMesh(driverTypes driverType,
23                                              const std::string & fileName,
24                                              MESH *mesh,
25                                              const string & driverName,
26                                              med_mode_acces access)
27 {
28   GENDRIVER *ret;
29   switch(driverType)
30     {
31     case MED_DRIVER : {
32       switch(access)
33         {
34         case MED_LECT : {
35           MED_MESH_RDONLY_DRIVER *retmed=new MED_MESH_RDONLY_DRIVER(fileName,
36                                                                     mesh);
37           retmed->setMeshName(driverName);
38           return retmed;
39         }
40         case MED_ECRI : {
41           MED_MESH_WRONLY_DRIVER *retmed=new MED_MESH_WRONLY_DRIVER(fileName,
42                                                                     mesh);
43           retmed->setMeshName(driverName);
44           return retmed;
45         }
46         case MED_REMP : {
47           MED_MESH_RDWR_DRIVER *retmed=new MED_MESH_RDWR_DRIVER(fileName,mesh);
48           retmed->setMeshName(driverName);
49           return retmed;
50         }
51         default:
52           throw MED_EXCEPTION ("access type has not been properly specified to the method");
53         }
54       break;
55     }
56
57     case GIBI_DRIVER : {
58       switch(access)
59         {
60         case MED_LECT : {
61           ret=new GIBI_MESH_RDONLY_DRIVER(fileName,mesh);
62           return ret;
63         }
64         case MED_ECRI : {
65           throw MED_EXCEPTION ("access mode other than MED_LECT has been specified with the GIBI_DRIVER type which is not allowed because GIBI_DRIVER is only a read access driver");
66         }
67         case MED_REMP : {
68           throw MED_EXCEPTION ("access mode other than MED_LECT has been specified with the GIBI_DRIVER type which is not allowed because GIBI_DRIVER is only a read access driver");
69         }
70         default:
71           throw MED_EXCEPTION ("access type has not been properly specified to the method");
72         }
73       break;
74     }
75
76     case PORFLOW_DRIVER : {
77       switch(access)
78         {
79         case MED_LECT : {
80           ret=new PORFLOW_MESH_RDONLY_DRIVER(fileName,mesh);
81           return ret;
82         }
83         case MED_ECRI : {
84           throw MED_EXCEPTION ("access mode other than MED_LECT has been specified with the PORFLOW_DRIVER type which is not allowed because PORFLOW_DRIVER is only a read access driver");
85         }
86         case MED_REMP : {
87           throw MED_EXCEPTION ("access mode other than MED_LECT has been specified with the PORFLOW_DRIVER type which is not allowed because PORFLOW_DRIVER is only a read access driver");
88         }
89         default:
90           throw MED_EXCEPTION ("access type has not been properly specified to the method");
91         }
92       break;
93     }
94
95     case VTK_DRIVER : {
96       switch(access)
97         {
98         case MED_LECT : {
99           throw MED_EXCEPTION ("access mode other than MED_ECRI or MED_REMPT has been specified with the VTK_DRIVER type which is not allowed because VTK_DRIVER is only a write access driver");
100         }
101         case MED_ECRI : {
102           ret=new VTK_MESH_DRIVER(fileName,mesh);
103           return ret;
104         }
105         case MED_REMP : {
106           ret=new VTK_MESH_DRIVER(fileName,mesh);
107           return ret;
108         }
109         default:
110           throw MED_EXCEPTION ("access type has not been properly specified to the method");
111         }
112       break;
113     }
114
115     case NO_DRIVER : {
116       throw MED_EXCEPTION ("NO_DRIVER has been specified to the method which is not allowed");
117     }
118     default:
119       throw MED_EXCEPTION ("other driver than MED_DRIVER GIBI_DRIVER PORFLOW_DRIVER and VT_DRIVER has been specified to the method which is not allowed");
120     }
121 }
122
123 GENDRIVER *DRIVERFACTORY::buildDriverForMed(driverTypes driverType,
124                                             const std::string & fileName,
125                                             MED *med, med_mode_acces access)
126 {
127   GENDRIVER *ret;
128
129   switch(driverType)
130     {
131     case MED_DRIVER : {
132       switch(access)
133         {
134         case MED_LECT : {
135           ret=new MED_MED_RDONLY_DRIVER(fileName,med);
136           break ;
137         }
138         case MED_ECRI : {
139           ret=new MED_MED_WRONLY_DRIVER(fileName,med);
140           break ;
141         }
142         case MED_REMP : {
143           ret=new MED_MED_RDONLY_DRIVER(fileName,med);
144           break ;
145         }
146         default:
147           throw MED_EXCEPTION ("access type has not been properly specified to the method");
148         }
149       break;
150     }
151
152     case VTK_DRIVER : {
153       switch(access)
154         {
155         case MED_LECT : {
156           throw MED_EXCEPTION ("access mode other than MED_ECRI or MED_REMPT has been specified with the VTK_DRIVER type which is not allowed because VTK_DRIVER is only a write access driver");
157         }
158         case MED_ECRI : {
159           ret=new VTK_MED_DRIVER(fileName,med);
160           break ;
161         }
162         case MED_REMP : {
163           ret=new VTK_MED_DRIVER(fileName,med);
164           break ;
165         }
166         default:
167           throw MED_EXCEPTION ("access type has not been properly specified to the method");
168         }
169       break;
170     }
171
172     case GIBI_DRIVER : {
173       throw MED_EXCEPTION ("GIBI_DRIVER has been specified to the method which is not allowed because there is no GIBI driver for the MED object");
174       break;
175     }
176
177     case PORFLOW_DRIVER : {
178       throw MED_EXCEPTION ("PORFLOW_DRIVER has been specified to the method which is not allowed because there is no PORFLOW driver for the MED object");
179       break;
180     }
181
182     case NO_DRIVER : {
183       throw MED_EXCEPTION ("NO_DRIVER has been specified to the method which is not allowed");
184       break;
185     }
186     default:
187       throw MED_EXCEPTION ("NO_DRIVER has been specified to the method which is not allowed");
188     }
189   return ret;
190 }
191