Version: 8.3.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
YACS
Introduction
Features
Packages
Building
TODOs
Base classes
Engine
SALOME Runtime
XML file loader
GUI design
Python wrapping
PMMLlib C++ examples
Configuring and Installing PMML from sources
PMMLlib
PMMLlib Python examples
Modules
Namespaces
Classes
Files
File List
idl
src
bases
AlternateThread.cxx
AlternateThread.hxx
AlternateThreadPT.cxx
AlternateThreadPT.hxx
AutoLocker.hxx
AutoRefCnt.hxx
chrono.cxx
chrono.hxx
Cstr2d.cxx
Cstr2d.hxx
define.hxx
DynLibLoader.cxx
DynLibLoader.hxx
DynLibLoaderGNU.cxx
DynLibLoaderGNU.hxx
DynLibLoaderWin.cxx
DynLibLoaderWin.hxx
Exception.cxx
Exception.hxx
Mutex.cxx
Mutex.hxx
MutexPT.cxx
MutexPT.hxx
Semaphore.cxx
Semaphore.hxx
SemaphorePT.cxx
SemaphorePT.hxx
Thread.cxx
Thread.hxx
ThreadPT.cxx
ThreadPT.hxx
YACSBasesExport.hxx
yacsconfig.h
YacsTrace.cxx
YacsTrace.hxx
engine
genericgui
hmi
pmml
pyqt
runtime
salomegui
salomewrap
yacsloader
yacsorb
File Members
DynLibLoaderGNU.cxx
Go to the documentation of this file.
1
// Copyright (C) 2006-2016 CEA/DEN, EDF R&D
2
//
3
// This library is free software; you can redistribute it and/or
4
// modify it under the terms of the GNU Lesser General Public
5
// License as published by the Free Software Foundation; either
6
// version 2.1 of the License, or (at your option) any later version.
7
//
8
// This library is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
// Lesser General Public License for more details.
12
//
13
// You should have received a copy of the GNU Lesser General Public
14
// License along with this library; if not, write to the Free Software
15
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
//
17
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18
//
19
20
#include "
DynLibLoaderGNU.hxx
"
21
#include <iostream>
22
#include <dlfcn.h>
23
#include "
Exception.hxx
"
24
25
using namespace
YACS::BASES;
26
27
#if defined(__APPLE__)
28
const
char
DynLibLoaderGNU::_extForDynLib
[]=
".dylib"
;
29
#else
30
const
char
DynLibLoaderGNU::_extForDynLib
[]=
".so"
;
31
#endif
32
33
DynLibLoaderGNU::DynLibLoaderGNU
(
const
std::string& libNameWithoutExtension):_libName(libNameWithoutExtension),
34
_handleOnLoadedLib(0)
35
{
36
}
37
38
DynLibLoaderGNU::~DynLibLoaderGNU
()
39
{
40
if
(
_handleOnLoadedLib
)
41
dlclose(
_handleOnLoadedLib
);
42
}
43
44
bool
DynLibLoaderGNU::isLibFileFindable
()
const
45
{
46
return
true
;
47
}
48
49
std::string
DynLibLoaderGNU::getLibNameWithoutExt
()
const
50
{
51
return
_libName
;
52
}
53
60
int
DynLibLoaderGNU::appendDirInSearchPath
(
const
std::string& dirName)
61
{
62
return
0;
63
}
64
71
int
DynLibLoaderGNU::removeDirInSearchPath
(
const
std::string& dirName)
72
{
73
return
0;
74
}
75
76
void
*
DynLibLoaderGNU::getHandleOnSymbolWithName
(
const
std::string& symbName,
bool
stopOnError)
77
{
78
if
(!
_handleOnLoadedLib
)
79
if
(!
isLibFileFindable
())
80
{
81
std::cerr <<
"Dynamic library with name "
<< symbName <<
_extForDynLib
;
82
std::cerr <<
" not existing in paths specified"
<< std::endl;
83
return
0;
84
}
85
else
86
loadLib
();
87
return
resolveSymb
(symbName, stopOnError);
88
}
89
90
bool
DynLibLoaderGNU::load
()
91
{
92
std::string fullLibName(
_libName
);
93
fullLibName+=
_extForDynLib
;
94
dlerror();
95
_handleOnLoadedLib
=dlopen(fullLibName.c_str(),RTLD_LAZY | RTLD_GLOBAL);
96
char
*message=dlerror();
97
if
(message != NULL)
98
{
99
std::string error =
"Error while trying to load library with name "
+ fullLibName +
100
" with the following internal message: "
+ message;
101
throw
YACS::Exception
(error);
102
}
103
return
_handleOnLoadedLib
!= NULL;
104
}
105
106
bool
DynLibLoaderGNU::unload
()
107
{
108
if
(
_handleOnLoadedLib
)
109
{
110
dlclose(
_handleOnLoadedLib
);
111
_handleOnLoadedLib
= NULL;
112
}
113
}
114
115
bool
DynLibLoaderGNU::reload
()
116
{
117
unload
();
118
return
load
();
119
}
120
121
void
*
DynLibLoaderGNU::resolveSymb
(
const
std::string& symbName,
bool
stopOnError)
122
{
123
dlerror();
124
void
*
ret
=dlsym(
_handleOnLoadedLib
,symbName.c_str());
125
char
*message=dlerror();
126
if
(stopOnError && (NULL != message))
127
{
128
std::string error=
"Error detected on symbol "
;
129
error=error+symbName +
" search in library with name "
+
_libName
+
_extForDynLib
+
" with the following internal message "
+message;
130
throw
YACS::Exception
(error);
131
}
132
else
133
return
ret
;
134
}
135
136
const
char
*
DynLibLoaderGNU::getExtensionForDynLib
()
137
{
138
return
_extForDynLib
+1;
139
}
140
src
bases
DynLibLoaderGNU.cxx
Copyright © 2006-2017 CEA/DEN, EDF R&D