GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
dynamic-ld.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1993-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_dynamic_ld_h)
27 #define octave_dynamic_ld_h 1
28 
29 #include "octave-config.h"
30 
31 #include <list>
32 #include <string>
33 
34 #include "oct-shlib.h"
35 
36 class octave_function;
37 
39 
40 class interpreter;
41 
42 class
44 {
45 private:
46 
47  class
48  shlibs_list
49  {
50  public:
51 
52  typedef std::list<dynamic_library>::iterator iterator;
53  typedef std::list<dynamic_library>::const_iterator const_iterator;
54 
55  shlibs_list () : m_lib_list () { }
56 
57  OCTAVE_DISABLE_COPY_MOVE (shlibs_list)
58 
59  ~shlibs_list () = default;
60 
61  void append (const dynamic_library& shl);
62 
63  std::list<std::string> remove (dynamic_library& shl);
64 
65  dynamic_library find_file (const std::string& file_name) const;
66 
67  void display () const;
68 
69  private:
70 
71  // List of libraries we have loaded.
72  std::list<dynamic_library> m_lib_list;
73  };
74 
75 
76 public:
77 
78  dynamic_loader () = delete;
79 
81  : m_interpreter (interp), m_loaded_shlibs (), m_doing_load (false)
82  { }
83 
84  OCTAVE_DISABLE_COPY_MOVE (dynamic_loader)
85 
86  virtual ~dynamic_loader () = default;
87 
89  load_oct (const std::string& fcn_name,
90  const std::string& file_name = "",
91  bool relative = false);
92 
94  load_mex (const std::string& fcn_name,
95  const std::string& file_name = "",
96  bool relative = false);
97 
98  bool remove_oct (const std::string& fcn_name,
99  dynamic_library& shl);
100 
101  bool remove_mex (const std::string& fcn_name,
102  dynamic_library& shl);
103 
104 private:
105 
106  void clear_function (const std::string& fcn_name);
107 
108  void clear (dynamic_library& oct_file);
109 
110  interpreter& m_interpreter;
111 
112  shlibs_list m_loaded_shlibs;
113 
114  bool m_doing_load;
115 
116  static std::string name_mangler (const std::string& name);
117 
118  static std::string name_uscore_mangler (const std::string& name);
119 
120  static std::string mex_mangler (const std::string& name);
121 
122  static std::string mex_uscore_mangler (const std::string& name);
123 
124  static std::string mex_f77_mangler (const std::string& name);
125 
126  static void * try_load_mex (dynamic_library& mex_file,
127  const std::string& fcn_name, bool& have_fmex);
128 };
129 
130 OCTAVE_END_NAMESPACE(octave)
131 
132 #endif
dynamic_loader(interpreter &interp)
Definition: dynamic-ld.h:80
dynamic_loader()=delete
void clear_function(const std::string &name)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn