Mercurial > hg > octave-lyh
annotate liboctave/oct-shlib.h @ 8920:eb63fbe60fab
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 07 Mar 2009 10:41:27 -0500 |
parents | 14e05160b99f |
children | 80432f0ee895 |
rev | line source |
---|---|
3326 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1999, 2000, 2002, 2004, 2005, 2006, 2007, 2008 John W. Eaton |
3326 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
3326 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
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/>. | |
3326 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_shlib_h) | |
24 #define octave_shlib_h 1 | |
25 | |
26 #include <string> | |
27 | |
4848 | 28 #include "oct-time.h" |
3326 | 29 |
30 // This just provides a way to avoid infinite recursion when building | |
31 // octave_shlib objects. | |
32 | |
33 class | |
6108 | 34 OCTAVE_API |
3326 | 35 octave_xshlib |
36 { | |
37 public: | |
38 | |
39 octave_xshlib (void) { } | |
40 }; | |
41 | |
42 class | |
6108 | 43 OCTAVE_API |
3326 | 44 octave_shlib |
45 { | |
46 public: | |
47 | |
3504 | 48 typedef std::string (*name_mangler) (const std::string&); |
3326 | 49 |
3504 | 50 typedef void (*close_hook) (const std::string&); |
3326 | 51 |
6323 | 52 octave_shlib (void) : relative (false), rep (make_shlib ()) { } |
3326 | 53 |
6323 | 54 octave_shlib (const std::string& f) |
55 : relative (false), rep (make_shlib ()) { open (f); } | |
3326 | 56 |
57 virtual ~octave_shlib (void) | |
58 { | |
59 if (rep && --rep->count == 0) | |
60 { | |
61 delete rep; | |
62 rep = 0; | |
63 } | |
64 } | |
65 | |
66 octave_shlib (const octave_shlib& sl) | |
67 { | |
68 rep = sl.rep; | |
69 rep->count++; | |
70 } | |
71 | |
72 octave_shlib& operator = (const octave_shlib& sl) | |
73 { | |
74 if (rep != sl.rep) | |
75 { | |
76 if (--rep->count == 0) | |
77 delete rep; | |
78 | |
79 rep = sl.rep; | |
80 rep->count++; | |
81 } | |
82 | |
83 return *this; | |
84 } | |
85 | |
86 bool operator == (const octave_shlib& sl) const | |
87 { return (rep == sl.rep); } | |
88 | |
89 operator bool () const { return is_open (); } | |
90 | |
5781 | 91 virtual void open (const std::string& f) { rep->open (f); } |
7749
14e05160b99f
reference counting for functions loaded from shared libraries
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
92 |
3504 | 93 virtual void *search (const std::string& nm, name_mangler mangler = 0) |
3326 | 94 { return rep->search (nm, mangler); } |
95 | |
96 virtual void close (close_hook cl_hook = 0) | |
97 { rep->close (cl_hook); } | |
98 | |
3504 | 99 virtual bool remove (const std::string& fcn_name) |
3326 | 100 { return rep->remove (fcn_name); } |
101 | |
102 virtual bool is_out_of_date (void) const | |
103 { return rep->is_out_of_date (); } | |
104 | |
6323 | 105 void mark_relative (void) { relative = true; } |
106 | |
107 bool is_relative (void) const { return relative; } | |
108 | |
7749
14e05160b99f
reference counting for functions loaded from shared libraries
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
109 virtual size_t number_of_functions_loaded (void) const |
3326 | 110 { return rep->number_of_functions_loaded (); } |
111 | |
3504 | 112 virtual std::string file_name (void) const |
3326 | 113 { return rep->file_name (); } |
114 | |
115 virtual octave_time time_loaded (void) const | |
116 { return rep->time_loaded (); } | |
117 | |
118 protected: | |
119 | |
120 octave_shlib (const octave_xshlib&) : rep (0) { } | |
121 | |
122 virtual bool is_open (void) const { return rep->is_open (); } | |
123 | |
124 static octave_shlib *make_shlib (void); | |
125 | |
6323 | 126 // TRUE if this function was found from a relative path element. |
127 bool relative; | |
128 | |
3326 | 129 union |
130 { | |
131 octave_shlib *rep; | |
132 int count; | |
133 }; | |
134 }; | |
135 | |
136 #endif | |
137 | |
138 /* | |
139 ;;; Local Variables: *** | |
140 ;;; mode: C++ *** | |
141 ;;; End: *** | |
142 */ |