/usr/include/octave-4.0.0/octave/oct-shlib.h is in liboctave-dev 4.0.0-3ubuntu9.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | /*
Copyright (C) 1999-2015 John W. Eaton
Copyright (C) 2009 VZLU Prague
This file is part of Octave.
Octave is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
Octave is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with Octave; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>.
*/
#if !defined (octave_oct_shlib_h)
#define octave_oct_shlib_h 1
#include <string>
#include <map>
#include "oct-time.h"
#include "oct-refcount.h"
class
OCTAVE_API
octave_shlib
{
public: // FIXME: make this class private?
typedef std::string (*name_mangler) (const std::string&);
typedef void (*close_hook) (const std::string&);
class shlib_rep
{
public:
shlib_rep (void)
: count (1), file (), tm_loaded (time_t ()), fcn_names () { }
protected:
shlib_rep (const std::string& f);
public:
virtual ~shlib_rep (void)
{
instances.erase (file);
}
virtual bool is_open (void) const
{ return false; }
virtual void *search (const std::string&, name_mangler = 0)
{ return 0; }
bool is_out_of_date (void) const;
// This method will be overridden conditionally.
static shlib_rep *new_instance (const std::string& f);
static shlib_rep *get_instance (const std::string& f, bool fake);
octave_time time_loaded (void) const
{ return tm_loaded; }
std::string file_name (void) const
{ return file; }
size_t num_fcn_names (void) const { return fcn_names.size (); }
void add_fcn_name (const std::string&);
bool remove_fcn_name (const std::string&);
void do_close_hook (close_hook cl_hook);
public:
octave_refcount<int> count;
protected:
void fake_reload (void);
std::string file;
octave_time tm_loaded;
// Set of hooked function names.
typedef std::map<std::string, size_t>::iterator fcn_names_iterator;
typedef std::map<std::string, size_t>::const_iterator fcn_names_const_iterator;
std::map<std::string, size_t> fcn_names;
static std::map<std::string, shlib_rep *> instances;
};
private:
static shlib_rep nil_rep;
public:
octave_shlib (void) : rep (&nil_rep) { rep->count++; }
octave_shlib (const std::string& f, bool fake = true)
: rep (shlib_rep::get_instance (f, fake)) { }
~octave_shlib (void)
{
if (--rep->count == 0)
delete rep;
}
octave_shlib (const octave_shlib& sl)
: rep (sl.rep)
{
rep->count++;
}
octave_shlib& operator = (const octave_shlib& sl)
{
if (rep != sl.rep)
{
if (--rep->count == 0)
delete rep;
rep = sl.rep;
rep->count++;
}
return *this;
}
bool operator == (const octave_shlib& sl) const
{ return (rep == sl.rep); }
operator bool () const { return rep->is_open (); }
void open (const std::string& f)
{ *this = octave_shlib (f); }
void close (close_hook cl_hook = 0)
{
if (cl_hook)
rep->do_close_hook (cl_hook);
*this = octave_shlib ();
}
void *search (const std::string& nm, name_mangler mangler = 0) const
{
void *f = rep->search (nm, mangler);
if (f)
rep->add_fcn_name (nm);
return f;
}
void add (const std::string& name)
{ rep->add_fcn_name (name); }
bool remove (const std::string& name)
{ return rep->remove_fcn_name (name); }
size_t number_of_functions_loaded (void) const
{ return rep->num_fcn_names (); }
bool is_out_of_date (void) const
{ return rep->is_out_of_date (); }
std::string file_name (void) const
{ return rep->file_name (); }
octave_time time_loaded (void) const
{ return rep->time_loaded (); }
private:
shlib_rep *rep;
};
#endif
|