Mercurial > octave
annotate libinterp/corefcn/dynamic-ld.h @ 22999:f4781639f847
convert octave_shlib_list from singleton to ordinary object
* dynamic-ld.h, dynamic-ld.cc
(octave_dynamic_loader::loaded_shlibs_list): Rename from
octave_shlib_list. Convert from singleton to ordinary object. Change
all uses.
(octave_dynamic_loader::loaded_shlibs): New data member. The
octave_dynamic_loader object now owns the list of loaded shared
libraries.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 04 Jan 2017 23:09:46 -0500 |
parents | f75d289645ec |
children | f981282a3bd0 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
21750
diff
changeset
|
3 Copyright (C) 1993-2016 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
1 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
1 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
23 #if ! defined (octave_dynamic_ld_h) |
383 | 24 #define octave_dynamic_ld_h 1 |
1 | 25 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
26 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
27 |
22999
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
28 #include <list> |
2862 | 29 #include <string> |
30 | |
3325 | 31 #include "oct-shlib.h" |
2894 | 32 |
7336 | 33 class octave_function; |
34 | |
2894 | 35 class |
36 octave_dynamic_loader | |
37 { | |
22999
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
38 private: |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
39 |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
40 class |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
41 loaded_shlibs_list |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
42 { |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
43 public: |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
44 |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
45 typedef std::list<octave::dynamic_library>::iterator iterator; |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
46 typedef std::list<octave::dynamic_library>::const_iterator const_iterator; |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
47 |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
48 loaded_shlibs_list (void) : lib_list () { } |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
49 |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
50 ~loaded_shlibs_list (void) = default; |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
51 |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
52 void append (const octave::dynamic_library& shl); |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
53 |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
54 void remove (octave::dynamic_library& shl, |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
55 octave::dynamic_library::close_hook cl_hook = 0); |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
56 |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
57 octave::dynamic_library find_file (const std::string& file_name) const; |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
58 |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
59 void display (void) const; |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
60 |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
61 private: |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
62 |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
63 // No copying! |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
64 |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
65 loaded_shlibs_list (const loaded_shlibs_list&) = delete; |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
66 |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
67 loaded_shlibs_list& operator = (const loaded_shlibs_list&) = delete; |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
68 |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
69 // List of libraries we have loaded. |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
70 std::list<octave::dynamic_library> lib_list; |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
71 }; |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
72 |
2894 | 73 protected: |
74 | |
22999
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
75 octave_dynamic_loader (void) : loaded_shlibs () { } |
2894 | 76 |
77 public: | |
78 | |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
79 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
80 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
81 octave_dynamic_loader (const octave_dynamic_loader&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
82 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
83 octave_dynamic_loader& operator = (const octave_dynamic_loader&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
84 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
85 virtual ~octave_dynamic_loader (void) = default; |
1 | 86 |
7336 | 87 static octave_function * |
88 load_oct (const std::string& fcn_name, | |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
89 const std::string& file_name = "", |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
90 bool relative = false); |
5864 | 91 |
7336 | 92 static octave_function * |
93 load_mex (const std::string& fcn_name, | |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
94 const std::string& file_name = "", |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
95 bool relative = false); |
3325 | 96 |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
97 static bool remove_oct (const std::string& fcn_name, |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
98 octave::dynamic_library& shl); |
7872 | 99 |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
100 static bool remove_mex (const std::string& fcn_name, |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
101 octave::dynamic_library& shl); |
2894 | 102 |
103 private: | |
104 | |
2926 | 105 static octave_dynamic_loader *instance; |
106 | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
107 static void cleanup_instance (void) { delete instance; instance = 0; } |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
108 |
2926 | 109 static bool instance_ok (void); |
110 | |
22999
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
111 void do_clear (octave::dynamic_library& oct_file); |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
112 |
7336 | 113 octave_function * |
114 do_load_oct (const std::string& fcn_name, | |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
115 const std::string& file_name = "", |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
116 bool relative = false); |
5864 | 117 |
7336 | 118 octave_function * |
119 do_load_mex (const std::string& fcn_name, | |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
120 const std::string& file_name = "", |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
121 bool relative = false); |
3325 | 122 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
123 bool do_remove_oct (const std::string& fcn_name, octave::dynamic_library& shl); |
7872 | 124 |
21750
6720e5a220ba
use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
125 bool do_remove_mex (const std::string& fcn_name, octave::dynamic_library& shl); |
3325 | 126 |
127 static bool doing_load; | |
2926 | 128 |
129 protected: | |
130 | |
22999
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
131 loaded_shlibs_list loaded_shlibs; |
f4781639f847
convert octave_shlib_list from singleton to ordinary object
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
132 |
7996
6a7db240b3a3
configure.in: eliminate CXX_ABI and OCTAVE_CXX_PREPEND_UNDERSCORE
John W. Eaton <jwe@octave.org>
parents:
7872
diff
changeset
|
133 static std::string name_mangler (const std::string& name); |
7336 | 134 |
7996
6a7db240b3a3
configure.in: eliminate CXX_ABI and OCTAVE_CXX_PREPEND_UNDERSCORE
John W. Eaton <jwe@octave.org>
parents:
7872
diff
changeset
|
135 static std::string name_uscore_mangler (const std::string& name); |
7872 | 136 |
137 static std::string mex_mangler (const std::string& name); | |
138 | |
139 static std::string mex_uscore_mangler (const std::string& name); | |
140 | |
141 static std::string mex_f77_mangler (const std::string& name); | |
2894 | 142 }; |
1 | 143 |
144 #endif | |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
145 |