]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_DriverFactory.hxx
Salome HOME
4ca108492d882156c274293a921f62658df6e482
[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, const std::string & fileName, MESH *mesh,const string &  driverName);
17     template<class T>
18     GENDRIVER *buildDriverForField(driverTypes driverType, const std::string & fileName, FIELD<T> *field);
19     GENDRIVER *buildDriverForMed(driverTypes driverType, const std::string & fileName, MED *med);
20   }
21
22 template<class T>
23 GENDRIVER *DRIVERFACTORY::buildDriverForField(driverTypes driverType, const std::string & fileName, FIELD<T> *field)
24 {
25   GENDRIVER *ret;
26   switch(driverType)
27     {
28     case MED_DRIVER : {
29       ret=new MED_FIELD_RDWR_DRIVER<T>(fileName,field);
30       break;
31     }
32
33     case VTK_DRIVER : {
34       ret=new VTK_FIELD_DRIVER<T>(fileName,field);
35       break ;
36     }
37
38     case GIBI_DRIVER : {
39       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");
40       break;
41     }
42
43     case PORFLOW_DRIVER : {
44       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");
45       break;
46     }
47
48     case NO_DRIVER : {
49       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");
50       break;
51     }
52     default:
53     MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
54     }
55   return ret;
56 }
57
58 }
59
60 #endif