![]() |
Octave-Forge - Extra packages for GNU Octave |
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code |
00001 /* 00002 00003 Copyright (C) 1999, 2000, 2002, 2004, 2005, 2006, 2007, 2008 John W. Eaton 00004 00005 This file is part of Octave. 00006 00007 Octave is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 Octave is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Octave; see the file COPYING. If not, see 00019 <http://www.gnu.org/licenses/>. 00020 00021 */ 00022 00023 #if !defined (octave_shlib_h) 00024 #define octave_shlib_h 1 00025 00026 #include <string> 00027 00028 #include "oct-time.h" 00029 00030 // This just provides a way to avoid infinite recursion when building 00031 // octave_shlib objects. 00032 00033 class 00034 OCTAVE_API 00035 octave_xshlib 00036 { 00037 public: 00038 00039 octave_xshlib (void) { } 00040 }; 00041 00042 class 00043 OCTAVE_API 00044 octave_shlib 00045 { 00046 public: 00047 00048 typedef std::string (*name_mangler) (const std::string&); 00049 00050 typedef void (*close_hook) (const std::string&); 00051 00052 octave_shlib (void) : relative (false), rep (make_shlib ()) { } 00053 00054 octave_shlib (const std::string& f) 00055 : relative (false), rep (make_shlib ()) { open (f); } 00056 00057 virtual ~octave_shlib (void) 00058 { 00059 if (rep && --rep->count == 0) 00060 { 00061 delete rep; 00062 rep = 0; 00063 } 00064 } 00065 00066 octave_shlib (const octave_shlib& sl) 00067 { 00068 rep = sl.rep; 00069 rep->count++; 00070 } 00071 00072 octave_shlib& operator = (const octave_shlib& sl) 00073 { 00074 if (rep != sl.rep) 00075 { 00076 if (--rep->count == 0) 00077 delete rep; 00078 00079 rep = sl.rep; 00080 rep->count++; 00081 } 00082 00083 return *this; 00084 } 00085 00086 bool operator == (const octave_shlib& sl) const 00087 { return (rep == sl.rep); } 00088 00089 operator bool () const { return is_open (); } 00090 00091 virtual void open (const std::string& f) { rep->open (f); } 00092 00093 virtual void *search (const std::string& nm, name_mangler mangler = 0) 00094 { return rep->search (nm, mangler); } 00095 00096 virtual void close (close_hook cl_hook = 0) 00097 { rep->close (cl_hook); } 00098 00099 virtual bool remove (const std::string& fcn_name) 00100 { return rep->remove (fcn_name); } 00101 00102 virtual bool is_out_of_date (void) const 00103 { return rep->is_out_of_date (); } 00104 00105 void mark_relative (void) { relative = true; } 00106 00107 bool is_relative (void) const { return relative; } 00108 00109 virtual size_t number_of_functions_loaded (void) const 00110 { return rep->number_of_functions_loaded (); } 00111 00112 virtual std::string file_name (void) const 00113 { return rep->file_name (); } 00114 00115 virtual octave_time time_loaded (void) const 00116 { return rep->time_loaded (); } 00117 00118 protected: 00119 00120 octave_shlib (const octave_xshlib&) : rep (0) { } 00121 00122 virtual bool is_open (void) const { return rep->is_open (); } 00123 00124 static octave_shlib *make_shlib (void); 00125 00126 // TRUE if this function was found from a relative path element. 00127 bool relative; 00128 00129 union 00130 { 00131 octave_shlib *rep; 00132 int count; 00133 }; 00134 }; 00135 00136 #endif 00137 00138 /* 00139 ;;; Local Variables: *** 00140 ;;; mode: C++ *** 00141 ;;; End: *** 00142 */