Mercurial > hg > octave-lyh
comparison liboctave/oct-shlib.h @ 3326:c19f4b9484af
[project @ 1999-10-29 21:52:12 by jwe]
author | jwe |
---|---|
date | Fri, 29 Oct 1999 21:52:30 +0000 |
parents | |
children | 5eef8a2294bd |
comparison
equal
deleted
inserted
replaced
3325:2efa28a91e7a | 3326:c19f4b9484af |
---|---|
1 /* | |
2 | |
3 Copyright (C) 1999 John W. Eaton | |
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 | |
9 Free Software Foundation; either version 2, or (at your option) any | |
10 later version. | |
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 | |
18 along with Octave; see the file COPYING. If not, write to the Free | |
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
20 | |
21 */ | |
22 | |
23 #if !defined (octave_shlib_h) | |
24 #define octave_shlib_h 1 | |
25 | |
26 #include <string> | |
27 | |
28 #include <oct-time.h> | |
29 | |
30 // This just provides a way to avoid infinite recursion when building | |
31 // octave_shlib objects. | |
32 | |
33 class | |
34 octave_xshlib | |
35 { | |
36 public: | |
37 | |
38 octave_xshlib (void) { } | |
39 }; | |
40 | |
41 class | |
42 octave_shlib | |
43 { | |
44 public: | |
45 | |
46 typedef string (*name_mangler) (const string&); | |
47 | |
48 typedef void (*close_hook) (const string&); | |
49 | |
50 octave_shlib (void) : rep (make_shlib ()) { } | |
51 | |
52 octave_shlib::octave_shlib (const string& f, bool warn_future) | |
53 : rep (make_shlib ()) | |
54 { | |
55 open (f, warn_future); | |
56 } | |
57 | |
58 virtual ~octave_shlib (void) | |
59 { | |
60 if (rep && --rep->count == 0) | |
61 { | |
62 delete rep; | |
63 rep = 0; | |
64 } | |
65 } | |
66 | |
67 octave_shlib (const octave_shlib& sl) | |
68 { | |
69 rep = sl.rep; | |
70 rep->count++; | |
71 } | |
72 | |
73 octave_shlib& operator = (const octave_shlib& sl) | |
74 { | |
75 if (rep != sl.rep) | |
76 { | |
77 if (--rep->count == 0) | |
78 delete rep; | |
79 | |
80 rep = sl.rep; | |
81 rep->count++; | |
82 } | |
83 | |
84 return *this; | |
85 } | |
86 | |
87 bool operator == (const octave_shlib& sl) const | |
88 { return (rep == sl.rep); } | |
89 | |
90 operator bool () const { return is_open (); } | |
91 | |
92 virtual void open (const string& f, bool warn_future = false) | |
93 { rep->open (f, warn_future); } | |
94 | |
95 virtual void *search (const string& nm, name_mangler mangler = 0) | |
96 { return rep->search (nm, mangler); } | |
97 | |
98 virtual void close (close_hook cl_hook = 0) | |
99 { rep->close (cl_hook); } | |
100 | |
101 virtual bool remove (const string& fcn_name) | |
102 { return rep->remove (fcn_name); } | |
103 | |
104 virtual bool is_out_of_date (void) const | |
105 { return rep->is_out_of_date (); } | |
106 | |
107 virtual int number_of_functions_loaded (void) const | |
108 { return rep->number_of_functions_loaded (); } | |
109 | |
110 virtual string file_name (void) const | |
111 { return rep->file_name (); } | |
112 | |
113 virtual octave_time time_loaded (void) const | |
114 { return rep->time_loaded (); } | |
115 | |
116 protected: | |
117 | |
118 octave_shlib (const octave_xshlib&) : rep (0) { } | |
119 | |
120 virtual bool is_open (void) const { return rep->is_open (); } | |
121 | |
122 static octave_shlib *make_shlib (void); | |
123 | |
124 union | |
125 { | |
126 octave_shlib *rep; | |
127 int count; | |
128 }; | |
129 }; | |
130 | |
131 #endif | |
132 | |
133 /* | |
134 ;;; Local Variables: *** | |
135 ;;; mode: C++ *** | |
136 ;;; End: *** | |
137 */ |