Salome HOME
Correct some memory leaks
[modules/smesh.git] / src / Driver / SMESHDriver.cxx
1 //  SMESH Driver : implementaion of driver for reading and writing      
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESHDriver.cxx
25 //  Module : SMESH
26
27 using namespace std;
28 #include "SMESHDriver.h"
29
30 #include <dlfcn.h>
31 #include <utilities.h>
32
33 //A enlever
34 #include "DriverMED_R_SMESHDS_Document.h"
35 #include "DriverMED_R_SMESHDS_Mesh.h"
36 #include "DriverMED_R_SMDS_Mesh.h"
37 #include "DriverMED_W_SMESHDS_Document.h"
38 #include "DriverMED_W_SMESHDS_Mesh.h"
39 #include "DriverMED_W_SMDS_Mesh.h"
40
41 #include "DriverDAT_R_SMESHDS_Document.h"
42 #include "DriverDAT_R_SMESHDS_Mesh.h"
43 #include "DriverDAT_R_SMDS_Mesh.h"
44 #include "DriverDAT_W_SMESHDS_Document.h"
45 #include "DriverDAT_W_SMESHDS_Mesh.h"
46 #include "DriverDAT_W_SMDS_Mesh.h"
47 //
48
49 Document_Reader* SMESHDriver::GetDocumentReader(string Extension, string Class) {
50   if (Extension==string("MED")) {
51     DriverMED_R_SMESHDS_Document* myDriver = new DriverMED_R_SMESHDS_Document();
52     return (myDriver);
53   }
54   else if (Extension==string("DAT")) {
55     DriverDAT_R_SMESHDS_Document* myDriver = new DriverDAT_R_SMESHDS_Document();
56     return (myDriver);
57   }
58   else {
59     MESSAGE("No driver known for this extension");
60     return (Document_Reader*)NULL;
61   }
62
63
64 }
65
66 Document_Writer* SMESHDriver::GetDocumentWriter(string Extension, string Class) {
67   if (Extension==string("MED")) {
68     DriverMED_W_SMESHDS_Document* myDriver = new DriverMED_W_SMESHDS_Document();
69     return (myDriver);
70   }    
71   else if (Extension==string("DAT")) {
72     DriverDAT_W_SMESHDS_Document* myDriver = new DriverDAT_W_SMESHDS_Document();
73     return (myDriver);
74   }    
75   else {
76     MESSAGE("No driver known for this extension");
77     return (Document_Writer*)NULL;
78   }
79
80
81 }
82
83 Mesh_Reader* SMESHDriver::GetMeshReader(string Extension, string Class) {
84   if (Extension==string("MED")) {
85
86   if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) {
87     DriverMED_R_SMESHDS_Mesh* myDriver = new DriverMED_R_SMESHDS_Mesh();
88     return (myDriver);
89   }
90   else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) {
91     DriverMED_R_SMDS_Mesh* myDriver = new DriverMED_R_SMDS_Mesh();
92     return (myDriver);
93   }
94
95   }
96   else if (Extension==string("DAT")) {
97
98   if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) {
99     DriverDAT_R_SMESHDS_Mesh* myDriver = new DriverDAT_R_SMESHDS_Mesh();
100     return (myDriver);
101   }
102   else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) {
103     DriverDAT_R_SMDS_Mesh* myDriver = new DriverDAT_R_SMDS_Mesh();
104     return (myDriver);
105   }
106
107   }
108
109
110 }
111
112 Mesh_Writer* SMESHDriver::GetMeshWriter(string Extension, string Class) {
113   if (Extension==string("MED")) {
114
115   if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) {
116     DriverMED_W_SMESHDS_Mesh* myDriver = new DriverMED_W_SMESHDS_Mesh();
117     return (myDriver);
118   }
119   else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) {
120     DriverMED_W_SMDS_Mesh* myDriver = new DriverMED_W_SMDS_Mesh();
121     return (myDriver);
122   }
123
124   }
125   else if (Extension==string("DAT")) {
126
127   if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) {
128     DriverDAT_W_SMESHDS_Mesh* myDriver = new DriverDAT_W_SMESHDS_Mesh();
129     return (myDriver);
130   }
131   else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) {
132     DriverDAT_W_SMDS_Mesh* myDriver = new DriverDAT_W_SMDS_Mesh();
133     return (myDriver);
134   }
135
136   }
137
138 }
139