Mercurial > hg > orthanc
annotate Core/SharedLibrary.cpp @ 3877:4b4f387c6bb8 transcoding
making DicomMoveScuJob more consistent with DicomModalityStoreJob
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 04 May 2020 16:00:38 +0200 |
parents | 626d5f4a5afb |
children |
rev | line source |
---|---|
884
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1032
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
884
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU General Public License as |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * published by the Free Software Foundation, either version 3 of the |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * License, or (at your option) any later version. |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * In addition, as a special exception, the copyright holders of this |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * program give permission to link the code of its release with the |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * in all respects for all of the code used other than "OpenSSL". If you |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * modify file(s) with this exception, you may extend this exception to |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * your version of the file(s), but you are not obligated to do so. If |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * you do not wish to do so, delete this exception statement from your |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * version. If you delete this exception statement from all source files |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * in the program, then also delete it here. |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * This program is distributed in the hope that it will be useful, but |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * General Public License for more details. |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * You should have received a copy of the GNU General Public License |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 **/ |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
2463
be5c0f4155f6
move SharedLibrary into OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
34 #include "PrecompiledHeaders.h" |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
35 #include "SharedLibrary.h" |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
36 |
2463
be5c0f4155f6
move SharedLibrary into OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
37 #include "Logging.h" |
be5c0f4155f6
move SharedLibrary into OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
38 #include "OrthancException.h" |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
39 |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1625
diff
changeset
|
40 #include <boost/filesystem.hpp> |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1625
diff
changeset
|
41 |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
42 #if defined(_WIN32) |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
43 #include <windows.h> |
2364 | 44 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__) |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
45 #include <dlfcn.h> |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
46 #else |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
47 #error Support your platform here |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
48 #endif |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
49 |
884
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 namespace Orthanc |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 { |
1631 | 52 SharedLibrary::SharedLibrary(const std::string& path) : |
53 path_(path), | |
54 handle_(NULL) | |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
55 { |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
56 #if defined(_WIN32) |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1625
diff
changeset
|
57 handle_ = ::LoadLibraryA(path_.c_str()); |
893
f57802f8b4dc
plugins for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
887
diff
changeset
|
58 if (handle_ == NULL) |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
59 { |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1625
diff
changeset
|
60 LOG(ERROR) << "LoadLibrary(" << path_ << ") failed: Error " << ::GetLastError(); |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
61 throw OrthancException(ErrorCode_SharedLibrary); |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
62 } |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
63 |
2364 | 64 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__) |
3788
626d5f4a5afb
disable RTLD_DEEPBIND if loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3696
diff
changeset
|
65 |
3696
b7087f928050
use of RTLD_DEEPBIND in dlopen() while loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
66 /** |
b7087f928050
use of RTLD_DEEPBIND in dlopen() while loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
67 * "RTLD_LOCAL" is the default, and is only present to be |
b7087f928050
use of RTLD_DEEPBIND in dlopen() while loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
68 * explicit. "RTLD_DEEPBIND" was added in Orthanc 1.6.0, in order |
b7087f928050
use of RTLD_DEEPBIND in dlopen() while loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
69 * to avoid crashes while loading plugins from the LSB binaries of |
b7087f928050
use of RTLD_DEEPBIND in dlopen() while loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
70 * the Orthanc core. |
3788
626d5f4a5afb
disable RTLD_DEEPBIND if loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3696
diff
changeset
|
71 * |
626d5f4a5afb
disable RTLD_DEEPBIND if loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3696
diff
changeset
|
72 * BUT this had no effect, and this results in a crash if loading |
626d5f4a5afb
disable RTLD_DEEPBIND if loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3696
diff
changeset
|
73 * the Python 2.7 plugin => We disabled it again in Orthanc 1.6.1. |
3696
b7087f928050
use of RTLD_DEEPBIND in dlopen() while loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
74 **/ |
3788
626d5f4a5afb
disable RTLD_DEEPBIND if loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3696
diff
changeset
|
75 |
626d5f4a5afb
disable RTLD_DEEPBIND if loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3696
diff
changeset
|
76 #if 0 // && defined(RTLD_DEEPBIND) // This is a GNU extension |
626d5f4a5afb
disable RTLD_DEEPBIND if loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3696
diff
changeset
|
77 // Disabled in Orthanc 1.6.1 |
3696
b7087f928050
use of RTLD_DEEPBIND in dlopen() while loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
78 handle_ = ::dlopen(path_.c_str(), RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND); |
b7087f928050
use of RTLD_DEEPBIND in dlopen() while loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
79 #else |
b7087f928050
use of RTLD_DEEPBIND in dlopen() while loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
80 handle_ = ::dlopen(path_.c_str(), RTLD_NOW | RTLD_LOCAL); |
b7087f928050
use of RTLD_DEEPBIND in dlopen() while loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
81 #endif |
b7087f928050
use of RTLD_DEEPBIND in dlopen() while loading plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
82 |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
83 if (handle_ == NULL) |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
84 { |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
85 std::string explanation; |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
86 const char *tmp = ::dlerror(); |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
87 if (tmp) |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
88 { |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
89 explanation = ": Error " + std::string(tmp); |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
90 } |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
91 |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1625
diff
changeset
|
92 LOG(ERROR) << "dlopen(" << path_ << ") failed" << explanation; |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
93 throw OrthancException(ErrorCode_SharedLibrary); |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
94 } |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
95 |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
96 #else |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
97 #error Support your platform here |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
98 #endif |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
99 } |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
100 |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
101 SharedLibrary::~SharedLibrary() |
884
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 { |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
103 if (handle_) |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
104 { |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
105 #if defined(_WIN32) |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
106 ::FreeLibrary((HMODULE)handle_); |
2364 | 107 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__) |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
108 ::dlclose(handle_); |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
109 #else |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
110 #error Support your platform here |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
111 #endif |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
112 } |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
113 } |
884
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
115 |
893
f57802f8b4dc
plugins for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
887
diff
changeset
|
116 SharedLibrary::FunctionPointer SharedLibrary::GetFunctionInternal(const std::string& name) |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
117 { |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
118 if (!handle_) |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
119 { |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
120 throw OrthancException(ErrorCode_InternalError); |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
121 } |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
122 |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
123 #if defined(_WIN32) |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
124 return ::GetProcAddress((HMODULE)handle_, name.c_str()); |
2364 | 125 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__) |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
126 return ::dlsym(handle_, name.c_str()); |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
127 #else |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
128 #error Support your platform here |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
129 #endif |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
130 } |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
131 |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
132 |
893
f57802f8b4dc
plugins for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
887
diff
changeset
|
133 SharedLibrary::FunctionPointer SharedLibrary::GetFunction(const std::string& name) |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
134 { |
893
f57802f8b4dc
plugins for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
887
diff
changeset
|
135 SharedLibrary::FunctionPointer result = GetFunctionInternal(name); |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
136 |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
137 if (result == NULL) |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
138 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2463
diff
changeset
|
139 throw OrthancException( |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2463
diff
changeset
|
140 ErrorCode_SharedLibrary, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2463
diff
changeset
|
141 "Shared library does not expose function \"" + name + "\""); |
885
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
142 } |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
143 else |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
144 { |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
145 return result; |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
146 } |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
147 } |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
148 |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
149 |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
150 bool SharedLibrary::HasFunction(const std::string& name) |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
151 { |
0570a8c859cb
SharedLibrary class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
884
diff
changeset
|
152 return GetFunctionInternal(name) != NULL; |
884
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 } |
cd8a69aa4093
creation of branch plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 } |