]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_DriverFactory.hxx
Salome HOME
update due to bugs PAL8113 and another I do not remember the number ;) .
[modules/med.git] / src / MEDMEM / MEDMEM_DriverFactory.hxx
1 #ifndef DRIVERFACTORY_HXX
2 #define DRIVERFACTORY_HXX
3
4 #include "MEDMEM_GenDriver.hxx"
5 #include "MEDMEM_VtkFieldDriver.hxx"
6 #include "MEDMEM_MedFieldDriver.hxx"
7 #include <string>
8
9 namespace MEDMEM {
10
11   class MESH;
12   template<class T> class FIELD;
13   class MED;
14
15   namespace DRIVERFACTORY {
16     GENDRIVER *buildDriverForMesh(driverTypes driverType,
17                                   const std::string & fileName,
18                                   MESH *mesh,const string &  driverName,
19                                   MED_EN::med_mode_acces access);
20     template<class T>
21     GENDRIVER *buildDriverForField(driverTypes driverType,
22                                    const std::string & fileName,
23                                    FIELD<T> *fielde,
24                                    MED_EN::med_mode_acces access);
25     GENDRIVER *buildDriverForMed(driverTypes driverType,
26                                  const std::string & fileName,
27                                  MED *mede,
28                                  MED_EN::med_mode_acces access);
29   }
30
31 template<class T>
32 GENDRIVER *DRIVERFACTORY::buildDriverForField(driverTypes driverType,
33                                               const std::string & fileName,
34                                               FIELD<T> *field,
35                                               MED_EN::med_mode_acces access)
36 {
37   GENDRIVER *ret;
38   switch(driverType)
39     {
40     case MED_DRIVER : {
41       switch(access)
42         {
43         case MED_EN::MED_LECT : {
44           ret=new MED_FIELD_RDONLY_DRIVER<T>(fileName,field);
45           break;
46         }
47         case MED_EN::MED_ECRI : {
48           ret=new MED_FIELD_WRONLY_DRIVER<T>(fileName,field);
49           break;
50         }
51         case MED_EN::MED_REMP : {
52           ret=new MED_FIELD_RDWR_DRIVER<T>(fileName,field);
53           break;
54         }
55         default:
56           throw MED_EXCEPTION ("access type has not been properly specified to the method");
57         }
58       break;
59     }
60
61     case VTK_DRIVER : {
62       switch(access)
63         {
64         case MED_EN::MED_LECT : {
65           throw MED_EXCEPTION ("access mode other than MED_ECRI and MED_REMP has been specified with the VTK_DRIVER type which is not allowed because VTK_DRIVER is only a write access driver");
66           break;
67         }
68         case MED_EN::MED_ECRI : {
69           ret=new VTK_FIELD_DRIVER<T>(fileName,field);
70           break;
71         }
72         case MED_EN::MED_REMP : {
73           ret=new VTK_FIELD_DRIVER<T>(fileName,field);
74           break ;
75         }
76         default:
77           throw MED_EXCEPTION ("access type has not been properly specified to the method");
78         }
79       break;
80     }
81
82     case GIBI_DRIVER : {
83       throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
84       break;
85     }
86
87     case PORFLOW_DRIVER : {
88       throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
89       break;
90     }
91
92     case NO_DRIVER : {
93       throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
94       break;
95     }
96     default:
97     MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
98     }
99   return ret;
100 }
101
102 }
103
104 #endif