1 // SMESH Driver : implementaion 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
24 // File : Driver_dl.cxx
32 #include <utilities.h>
34 #include "DriverDAT_R_SMESHDS_Document.h"
42 double (*cosine)(double);
45 handle = dlopen ("/usr/lib/libm.so", RTLD_LAZY);
47 fputs (dlerror(), stderr);
51 cosine = dlsym(handle, "cos");
52 if ((error = dlerror()) != NULL) {
53 fprintf (stderr, "%s\n", error);
57 printf ("%f\n", (*cosine)(2.0));
61 string Extension=string("DAT");
62 string Class=string("SMESHDS_Document");
63 string myLibrary = string("/home/barberou/barberou/SALOME_3105/build/lib/libMeshDriver")+Extension+string(".so");
65 //Document_Reader* myDriver;//a caster ???
66 DriverDAT_R_SMESHDS_Document* myDriver;
68 string myClass = string("Driver")+Extension+string("_R_")+Class;
71 void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY);
73 fputs (dlerror(), stderr);
78 //int* res = (int*)dlsym(handle, "getOne");
80 SCRUTE(dlsym(handle, "getOne"));
82 myDriver = (DriverDAT_R_SMESHDS_Document*) dlsym(handle, myClass.c_str());
85 if ((error = dlerror()) != NULL) {
86 fprintf (stderr, "%s\n", error);
92 MESSAGE("after close");
97 Document_Reader* Driver::GetDocumentReader(string Extension, string Class) {
102 string myLibrary = string("/home/barberou/barberou/SALOME_3105/build/lib/libMeshDriver")+Extension+string(".so");
104 //Document_Reader* myDriver;//a caster ???
105 DriverDAT_R_SMESHDS_Document* myDriver;
107 string myClass = string("Driver")+Extension+string("_R_")+Class;
110 void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY);
112 fputs (dlerror(), stderr);
116 //myDriver = (Document_Reader*) dlsym(handle, myClass.c_str());
117 int* res = (int*) dlsym(handle, "getOne");
119 myDriver = (DriverDAT_R_SMESHDS_Document*) dlsym(handle, myClass.c_str());
120 MESSAGE("Reading 1");
122 if ((error = dlerror()) != NULL) {
123 fprintf (stderr, "%s\n", error);
126 MESSAGE("Reading 2");
129 MESSAGE("after close");
135 Document_Writer* Driver::GetDocumentWriter(string Extension, string Class) {
138 string myLibrary = string("libMeshDriver")+Extension+string(".so");
139 Document_Writer* myDriver;//a caster ???
140 string myClass = string("Driver")+Extension+string("_W_")+Class;
142 void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY);
144 fputs (dlerror(), stderr);
148 myDriver = (Document_Writer*) dlsym(handle, myClass.c_str());
149 if ((error = dlerror()) != NULL) {
150 fprintf (stderr, "%s\n", error);
160 Mesh_Reader* Driver::GetMeshReader(string Extension, string Class) {
163 string myLibrary = string("libMeshDriver")+Extension+string(".so");
164 Mesh_Reader* myDriver;//a caster ???
165 string myClass = string("Driver")+Extension+string("_R_")+Class;
167 void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY);
169 fputs (dlerror(), stderr);
173 myDriver = (Mesh_Reader*) dlsym(handle, myClass.c_str());
174 if ((error = dlerror()) != NULL) {
175 fprintf (stderr, "%s\n", error);
185 Mesh_Writer* Driver::GetMeshWriter(string Extension, string Class) {
188 string myLibrary = string("libMeshDriver")+Extension+string(".so");
189 Mesh_Writer* myDriver;//a caster ???
190 string myClass = string("Driver")+Extension+string("_W_")+Class;
192 void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY);
194 fputs (dlerror(), stderr);
198 myDriver = (Mesh_Writer*) dlsym(handle, myClass.c_str());
199 if ((error = dlerror()) != NULL) {
200 fprintf (stderr, "%s\n", error);