1 // SMESH Driver : implementation of driver for reading and writing
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 #include "SMESHDriver.h"
25 #include <utilities.h>
27 Document_Reader* SMESHDriver::GetDocumentReader(string Extension)
29 // if there is not document reader in the driver create a default
30 // one with the mesh reader.
31 Document_Reader * docReader=
32 (Document_Reader*)getMeshDocumentDriver(Extension);
36 Mesh_Reader * reader=GetMeshReader(Extension);
39 MESSAGE("No driver known for this extension");
42 return new Document_Reader(reader);
44 else return docReader;
47 Document_Writer* SMESHDriver::GetDocumentWriter(string Extension)
49 Mesh_Writer * writer=GetMeshWriter(Extension);
52 MESSAGE("No driver known for this extension");
55 return new Document_Writer(writer);
58 Mesh_Reader* SMESHDriver::GetMeshReader(string extension)
60 void * driver = getMeshDriver(extension, string("Reader"));
61 return (Mesh_Reader*)driver;
64 Mesh_Writer* SMESHDriver::GetMeshWriter(string extension)
66 void * driver = getMeshDriver(extension, string("Writer"));
67 return (Mesh_Writer*)driver;
70 void * SMESHDriver::getMeshDriver(string extension, string type)
72 string libName = string("libMeshDriver")+extension+string(".so");
73 void * handle = dlopen(libName.c_str(), RTLD_LAZY);
76 fputs (dlerror(), stderr);
82 string symbol = string("SMESH_create")+extension+string("Mesh")+type;
83 factory = (void * (*)()) dlsym(handle, symbol.c_str());
86 fputs (dlerror(), stderr);
89 else return factory();
93 void * SMESHDriver::getMeshDocumentDriver(string extension)
95 string libName = string("libMeshDriver")+extension+string(".so");
96 void * handle = dlopen(libName.c_str(), RTLD_LAZY);
99 fputs (dlerror(), stderr);
105 string symbol = string("SMESH_create")+extension+string("DocumentReader");
106 factory = (void * (*)()) dlsym(handle, symbol.c_str());
109 fputs (dlerror(), stderr);
112 else return factory();