Mercurial > hg > octave-nkf
annotate src/load-path.h @ 12541:dd2c70b30f28
Add tests for ifftshift.m
author | Robert T. Short <octave@phaselockedsystems.com.com> |
---|---|
date | Sat, 26 Mar 2011 06:50:12 -0700 |
parents | 12df7854fa7c |
children | 7dd7cccf0757 |
rev | line source |
---|---|
5832 | 1 /* |
2 | |
11523 | 3 Copyright (C) 2006-2011 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
4 Copyright (C) 2010 VZLU Prague |
5832 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
5832 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
5832 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_load_path_h) | |
25 #define octave_load_path_h 1 | |
26 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
27 #include <iosfwd> |
5832 | 28 #include <list> |
29 #include <map> | |
30 #include <string> | |
31 | |
5835 | 32 #include "pathsearch.h" |
5832 | 33 #include "str-vec.h" |
34 | |
35 class | |
6241 | 36 OCTINTERP_API |
5832 | 37 load_path |
38 { | |
39 protected: | |
40 | |
9010
f914834836e7
Partial implementation of derived classes using the old form with "@" files.
rtshort@smoketree.phaselocked.com
parents:
8950
diff
changeset
|
41 load_path (void) |
10907
6105ed2db9d7
load_path::dir_info::initialize: clear method_file_map before updating file list
John W. Eaton <jwe@octave.org>
parents:
10521
diff
changeset
|
42 : dir_info_list (), fcn_map (), private_fcn_map (), method_map () { } |
5832 | 43 |
44 public: | |
45 | |
7336 | 46 typedef void (*hook_fcn_ptr) (const std::string& dir); |
5832 | 47 |
48 ~load_path (void) { } | |
49 | |
6365 | 50 static void initialize (bool set_initial_path = false) |
5832 | 51 { |
52 if (instance_ok ()) | |
6365 | 53 instance->do_initialize (set_initial_path); |
5832 | 54 } |
55 | |
56 static void clear (void) | |
57 { | |
58 if (instance_ok ()) | |
59 instance->do_clear (); | |
60 } | |
61 | |
5867 | 62 static void set (const std::string& p, bool warn = false) |
5832 | 63 { |
64 if (instance_ok ()) | |
5867 | 65 instance->do_set (p, warn); |
5832 | 66 } |
67 | |
5867 | 68 static void append (const std::string& dir, bool warn = false) |
5832 | 69 { |
70 if (instance_ok ()) | |
5867 | 71 instance->do_append (dir, warn); |
5832 | 72 } |
73 | |
5867 | 74 static void prepend (const std::string& dir, bool warn = false) |
5832 | 75 { |
76 if (instance_ok ()) | |
5867 | 77 instance->do_prepend (dir, warn); |
5832 | 78 } |
79 | |
80 static bool remove (const std::string& dir) | |
81 { | |
82 return instance_ok () ? instance->do_remove (dir) : false; | |
83 } | |
84 | |
85 static void update (void) | |
86 { | |
87 if (instance_ok ()) | |
88 instance->do_update (); | |
89 } | |
90 | |
7336 | 91 static std::string find_method (const std::string& class_name, |
10313 | 92 const std::string& meth, |
93 std::string& dir_name) | |
7336 | 94 { |
95 return instance_ok () | |
96 ? instance->do_find_method (class_name, meth, dir_name) : std::string (); | |
97 } | |
98 | |
99 static std::string find_method (const std::string& class_name, | |
10313 | 100 const std::string& meth) |
7336 | 101 { |
102 std::string dir_name; | |
103 return find_method (class_name, meth, dir_name); | |
104 } | |
105 | |
106 static std::list<std::string> methods (const std::string& class_name) | |
107 { | |
108 return instance_ok () | |
109 ? instance->do_methods (class_name) : std::list<std::string> (); | |
110 } | |
111 | |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
112 static std::list<std::string> overloads (const std::string& meth) |
9458
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9261
diff
changeset
|
113 { |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9261
diff
changeset
|
114 return instance_ok () |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
115 ? instance->do_overloads (meth) : std::list<std::string> (); |
9458
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9261
diff
changeset
|
116 } |
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9261
diff
changeset
|
117 |
7336 | 118 static std::string find_fcn (const std::string& fcn, std::string& dir_name) |
119 { | |
120 return instance_ok () | |
121 ? instance->do_find_fcn (fcn, dir_name) : std::string (); | |
122 } | |
123 | |
5832 | 124 static std::string find_fcn (const std::string& fcn) |
125 { | |
7336 | 126 std::string dir_name; |
127 return find_fcn (fcn, dir_name); | |
128 } | |
129 | |
130 static std::string find_private_fcn (const std::string& dir, | |
10313 | 131 const std::string& fcn) |
7336 | 132 { |
5832 | 133 return instance_ok () |
7336 | 134 ? instance->do_find_private_fcn (dir, fcn) : std::string (); |
5832 | 135 } |
136 | |
137 static std::string find_fcn_file (const std::string& fcn) | |
138 { | |
7336 | 139 std::string dir_name; |
140 | |
5832 | 141 return instance_ok () ? |
7336 | 142 instance->do_find_fcn (fcn, dir_name, M_FILE) : std::string (); |
5832 | 143 } |
144 | |
145 static std::string find_oct_file (const std::string& fcn) | |
146 { | |
7336 | 147 std::string dir_name; |
148 | |
5832 | 149 return instance_ok () ? |
7336 | 150 instance->do_find_fcn (fcn, dir_name, OCT_FILE) : std::string (); |
5832 | 151 } |
152 | |
5864 | 153 static std::string find_mex_file (const std::string& fcn) |
154 { | |
7336 | 155 std::string dir_name; |
156 | |
5864 | 157 return instance_ok () ? |
7336 | 158 instance->do_find_fcn (fcn, dir_name, MEX_FILE) : std::string (); |
5864 | 159 } |
160 | |
5832 | 161 static std::string find_file (const std::string& file) |
162 { | |
163 return instance_ok () | |
164 ? instance->do_find_file (file) : std::string (); | |
165 } | |
166 | |
8041
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
167 static std::string find_dir (const std::string& dir) |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
168 { |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
169 return instance_ok () |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
170 ? instance->do_find_dir (dir) : std::string (); |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
171 } |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
172 |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
173 static string_vector find_matching_dirs (const std::string& dir) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
174 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
175 return instance_ok () |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
176 ? instance->do_find_matching_dirs (dir) : string_vector (); |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
177 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
178 |
5832 | 179 static std::string find_first_of (const string_vector& files) |
180 { | |
181 return instance_ok () ? | |
182 instance->do_find_first_of (files) : std::string (); | |
183 } | |
184 | |
185 static string_vector find_all_first_of (const string_vector& files) | |
186 { | |
187 return instance_ok () ? | |
188 instance->do_find_all_first_of (files) : string_vector (); | |
189 } | |
190 | |
191 static string_vector dirs (void) | |
192 { | |
193 return instance_ok () ? instance->do_dirs () : string_vector (); | |
194 } | |
195 | |
196 static std::list<std::string> dir_list (void) | |
197 { | |
198 return instance_ok () | |
199 ? instance->do_dir_list () : std::list<std::string> (); | |
200 } | |
201 | |
9261
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
202 static string_vector files (const std::string& dir, bool omit_exts = false) |
5832 | 203 { |
9261
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
204 return instance_ok () |
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
205 ? instance->do_files (dir, omit_exts) : string_vector (); |
5832 | 206 } |
207 | |
208 static string_vector fcn_names (void) | |
209 { | |
210 return instance_ok () ? instance->do_fcn_names () : string_vector (); | |
211 } | |
212 | |
213 static std::string path (void) | |
214 { | |
215 return instance_ok () ? instance->do_path () : std::string (); | |
216 } | |
217 | |
218 static void display (std::ostream& os) | |
219 { | |
220 if (instance_ok ()) | |
221 instance->do_display (os); | |
222 } | |
223 | |
7336 | 224 static void set_add_hook (hook_fcn_ptr f) { add_hook = f; } |
5832 | 225 |
7336 | 226 static void set_remove_hook (hook_fcn_ptr f) { remove_hook = f; } |
5832 | 227 |
228 static void set_command_line_path (const std::string& p) | |
229 { | |
5835 | 230 if (command_line_path.empty ()) |
231 command_line_path = p; | |
232 else | |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7971
diff
changeset
|
233 command_line_path += dir_path::path_sep_str () + p; |
5832 | 234 } |
235 | |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8329
diff
changeset
|
236 static std::string get_command_line_path (void) |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8329
diff
changeset
|
237 { |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8329
diff
changeset
|
238 return instance_ok () ? instance->do_get_command_line_path () : std::string (); |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8329
diff
changeset
|
239 } |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8329
diff
changeset
|
240 |
6626 | 241 static std::string system_path (void) |
242 { | |
6630 | 243 return instance_ok () ? instance->do_system_path () : std::string (); |
6626 | 244 } |
245 | |
5832 | 246 private: |
247 | |
248 static const int M_FILE = 1; | |
249 static const int OCT_FILE = 2; | |
5864 | 250 static const int MEX_FILE = 4; |
5832 | 251 |
252 class dir_info | |
253 { | |
254 public: | |
255 | |
7336 | 256 // <FCN_NAME, TYPE> |
257 typedef std::map<std::string, int> fcn_file_map_type; | |
258 | |
259 typedef fcn_file_map_type::const_iterator const_fcn_file_map_iterator; | |
260 typedef fcn_file_map_type::iterator fcn_file_map_iterator; | |
261 | |
7971
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
262 struct class_info |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
263 { |
11515
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
264 class_info (void) : method_file_map (), private_file_map () { } |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
265 |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
266 class_info (const class_info& ci) |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
267 : method_file_map (ci.method_file_map), |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
268 private_file_map (ci.private_file_map) { } |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
269 |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
270 class_info& operator = (const class_info& ci) |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
271 { |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
272 if (this != &ci) |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
273 { |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
274 method_file_map = ci.method_file_map; |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
275 private_file_map = ci.private_file_map; |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
276 } |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
277 return *this; |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
278 } |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
279 |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
280 ~class_info (void) { } |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
281 |
7971
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
282 fcn_file_map_type method_file_map; |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
283 fcn_file_map_type private_file_map; |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
284 }; |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
285 |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
286 // <CLASS_NAME, CLASS_INFO> |
dd5cc5016487
handle private functions in class directories
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
287 typedef std::map<std::string, class_info> method_file_map_type; |
7336 | 288 |
289 typedef method_file_map_type::const_iterator const_method_file_map_iterator; | |
290 typedef method_file_map_type::iterator method_file_map_iterator; | |
291 | |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
292 // This default constructor is only provided so we can create a |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
293 // std::map of dir_info objects. You should not use this |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
294 // constructor for any other purpose. |
11515
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
295 dir_info (void) |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
296 : dir_name (), abs_dir_name (), is_relative (false), |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
297 dir_mtime (), dir_time_last_checked (), all_files (), |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
298 fcn_files (), private_file_map (), method_file_map () |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
299 { } |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
300 |
11515
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
301 dir_info (const std::string& d) |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
302 : dir_name (d), abs_dir_name (), is_relative (false), |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
303 dir_mtime (), dir_time_last_checked (), all_files (), |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
304 fcn_files (), private_file_map (), method_file_map () |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
305 { |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
306 initialize (); |
6dbf9bcce90e
more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10907
diff
changeset
|
307 } |
5832 | 308 |
309 dir_info (const dir_info& di) | |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
310 : dir_name (di.dir_name), abs_dir_name (di.abs_dir_name), |
10313 | 311 is_relative (di.is_relative), |
312 dir_mtime (di.dir_mtime), | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
313 dir_time_last_checked (di.dir_time_last_checked), |
10313 | 314 all_files (di.all_files), fcn_files (di.fcn_files), |
315 private_file_map (di.private_file_map), | |
316 method_file_map (di.method_file_map) { } | |
5832 | 317 |
318 ~dir_info (void) { } | |
319 | |
320 dir_info& operator = (const dir_info& di) | |
321 { | |
322 if (&di != this) | |
10313 | 323 { |
324 dir_name = di.dir_name; | |
325 abs_dir_name = di.abs_dir_name; | |
326 is_relative = di.is_relative; | |
327 dir_mtime = di.dir_mtime; | |
328 dir_time_last_checked = di.dir_time_last_checked; | |
329 all_files = di.all_files; | |
330 fcn_files = di.fcn_files; | |
331 private_file_map = di.private_file_map; | |
332 method_file_map = di.method_file_map; | |
333 } | |
5832 | 334 |
335 return *this; | |
336 } | |
337 | |
338 void update (void); | |
339 | |
340 std::string dir_name; | |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
341 std::string abs_dir_name; |
5832 | 342 bool is_relative; |
343 octave_time dir_mtime; | |
9748
d6b2b708b6b0
load-path: compare directory timestamps with tolerance
John W. Eaton <jwe@octave.org>
parents:
9581
diff
changeset
|
344 octave_time dir_time_last_checked; |
5832 | 345 string_vector all_files; |
346 string_vector fcn_files; | |
7336 | 347 fcn_file_map_type private_file_map; |
348 method_file_map_type method_file_map; | |
5832 | 349 |
350 private: | |
351 | |
352 void initialize (void); | |
353 | |
7336 | 354 void get_file_list (const std::string& d); |
355 | |
356 void get_private_file_map (const std::string& d); | |
5832 | 357 |
7336 | 358 void get_method_file_map (const std::string& d, |
10313 | 359 const std::string& class_name); |
7336 | 360 |
361 friend fcn_file_map_type get_fcn_files (const std::string& d); | |
5832 | 362 }; |
363 | |
364 class file_info | |
365 { | |
366 public: | |
367 | |
368 file_info (const std::string& d, int t) : dir_name (d), types (t) { } | |
369 | |
370 file_info (const file_info& fi) | |
371 : dir_name (fi.dir_name), types (fi.types) { } | |
372 | |
373 ~file_info (void) { } | |
374 | |
375 file_info& operator = (const file_info& fi) | |
376 { | |
377 if (&fi != this) | |
10313 | 378 { |
379 dir_name = fi.dir_name; | |
380 types = fi.types; | |
381 } | |
5832 | 382 |
383 return *this; | |
384 } | |
385 | |
386 std::string dir_name; | |
387 int types; | |
388 }; | |
389 | |
390 // We maintain two ways of looking at the same information. | |
391 // | |
392 // First, a list of directories and the set of "public" files and | |
393 // private files (those found in the special "private" subdirectory) | |
394 // in each directory. | |
395 // | |
396 // Second, a map from file names (the union of all "public" files for all | |
7336 | 397 // directories, but without filename extensions) to a list of |
5832 | 398 // corresponding information (directory name and file types). This |
399 // way, we can quickly find shadowed file names and look up all | |
400 // overloaded functions (in the "@" directories used to implement | |
401 // classes). | |
402 | |
7336 | 403 typedef std::list<dir_info> dir_info_list_type; |
404 | |
405 typedef dir_info_list_type::const_iterator const_dir_info_list_iterator; | |
406 typedef dir_info_list_type::iterator dir_info_list_iterator; | |
407 | |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
408 typedef std::map<std::string, dir_info> abs_dir_cache_type; |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
409 |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
410 typedef abs_dir_cache_type::const_iterator const_abs_dir_cache_iterator; |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
411 typedef abs_dir_cache_type::iterator abs_dir_cache_iterator; |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
412 |
7336 | 413 typedef std::list<file_info> file_info_list_type; |
414 | |
415 typedef file_info_list_type::const_iterator const_file_info_list_iterator; | |
416 typedef file_info_list_type::iterator file_info_list_iterator; | |
417 | |
418 // <FCN_NAME, FILE_INFO_LIST> | |
419 typedef std::map<std::string, file_info_list_type> fcn_map_type; | |
420 | |
421 typedef fcn_map_type::const_iterator const_fcn_map_iterator; | |
422 typedef fcn_map_type::iterator fcn_map_iterator; | |
5832 | 423 |
7336 | 424 // <DIR_NAME, <FCN_NAME, TYPE>> |
425 typedef std::map<std::string, dir_info::fcn_file_map_type> private_fcn_map_type; | |
426 | |
427 typedef private_fcn_map_type::const_iterator const_private_fcn_map_iterator; | |
428 typedef private_fcn_map_type::iterator private_fcn_map_iterator; | |
429 | |
430 // <CLASS_NAME, <FCN_NAME, FILE_INFO_LIST>> | |
431 typedef std::map<std::string, fcn_map_type> method_map_type; | |
432 | |
433 typedef method_map_type::const_iterator const_method_map_iterator; | |
434 typedef method_map_type::iterator method_map_iterator; | |
10907
6105ed2db9d7
load_path::dir_info::initialize: clear method_file_map before updating file list
John W. Eaton <jwe@octave.org>
parents:
10521
diff
changeset
|
435 |
7336 | 436 mutable dir_info_list_type dir_info_list; |
437 | |
438 mutable fcn_map_type fcn_map; | |
439 | |
440 mutable private_fcn_map_type private_fcn_map; | |
441 | |
442 mutable method_map_type method_map; | |
5832 | 443 |
444 static load_path *instance; | |
445 | |
7336 | 446 static hook_fcn_ptr add_hook; |
5832 | 447 |
7336 | 448 static hook_fcn_ptr remove_hook; |
5832 | 449 |
450 static std::string command_line_path; | |
451 | |
6626 | 452 static std::string sys_path; |
453 | |
8329
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
454 static abs_dir_cache_type abs_dir_cache; |
c91b59532f32
load-path.cc (load_path::dir_info::update): smarter handling of relative names
John W. Eaton <jwe@octave.org>
parents:
8041
diff
changeset
|
455 |
5832 | 456 static bool instance_ok (void); |
457 | |
458 const_dir_info_list_iterator find_dir_info (const std::string& dir) const; | |
459 dir_info_list_iterator find_dir_info (const std::string& dir); | |
460 | |
461 bool contains (const std::string& dir) const; | |
462 | |
7336 | 463 void move_fcn_map (const std::string& dir, |
10313 | 464 const string_vector& fcn_files, bool at_end); |
7336 | 465 |
466 void move_method_map (const std::string& dir, bool at_end); | |
467 | |
5832 | 468 void move (std::list<dir_info>::iterator i, bool at_end); |
469 | |
6365 | 470 void do_initialize (bool set_initial_path); |
5832 | 471 |
472 void do_clear (void); | |
473 | |
5867 | 474 void do_set (const std::string& p, bool warn); |
475 | |
476 void do_append (const std::string& dir, bool warn); | |
5832 | 477 |
5867 | 478 void do_prepend (const std::string& dir, bool warn); |
5832 | 479 |
5867 | 480 void do_add (const std::string& dir, bool at_end, bool warn); |
5832 | 481 |
7336 | 482 void remove_fcn_map (const std::string& dir, const string_vector& fcn_files); |
483 | |
484 void remove_private_fcn_map (const std::string& dir); | |
485 | |
486 void remove_method_map (const std::string& dir); | |
487 | |
5832 | 488 bool do_remove (const std::string& dir); |
489 | |
490 void do_update (void) const; | |
491 | |
7336 | 492 static bool |
493 check_file_type (std::string& fname, int type, int possible_types, | |
10313 | 494 const std::string& fcn, const char *who); |
7336 | 495 |
5832 | 496 std::string do_find_fcn (const std::string& fcn, |
10313 | 497 std::string& dir_name, |
498 int type = M_FILE | OCT_FILE | MEX_FILE) const; | |
5832 | 499 |
7336 | 500 std::string do_find_private_fcn (const std::string& dir, |
10313 | 501 const std::string& fcn, |
502 int type = M_FILE | OCT_FILE | MEX_FILE) const; | |
7336 | 503 |
504 std::string do_find_method (const std::string& class_name, | |
10313 | 505 const std::string& meth, |
506 std::string& dir_name, | |
507 int type = M_FILE | OCT_FILE | MEX_FILE) const; | |
7336 | 508 |
509 std::list<std::string> do_methods (const std::string& class_name) const; | |
510 | |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
511 std::list<std::string> do_overloads (const std::string& meth) const; |
9458
0c7d84a65386
allow taking handles of methods with no base overload
Jaroslav Hajek <highegg@gmail.com>
parents:
9261
diff
changeset
|
512 |
5832 | 513 std::string do_find_file (const std::string& file) const; |
514 | |
8041
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
515 std::string do_find_dir (const std::string& dir) const; |
a14bdf90be55
Add a search for Contents.m files to the help function
David Bateman <dbateman@free.fr>
parents:
8008
diff
changeset
|
516 |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
517 string_vector do_find_matching_dirs (const std::string& dir) const; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9748
diff
changeset
|
518 |
5832 | 519 std::string do_find_first_of (const string_vector& files) const; |
520 | |
521 string_vector do_find_all_first_of (const string_vector& files) const; | |
522 | |
523 string_vector do_dirs (void) const; | |
524 | |
525 std::list<std::string> do_dir_list (void) const; | |
526 | |
9261
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9010
diff
changeset
|
527 string_vector do_files (const std::string& dir, bool omit_exts) const; |
5832 | 528 |
529 string_vector do_fcn_names (void) const; | |
530 | |
531 std::string do_path (void) const; | |
532 | |
7336 | 533 friend void print_types (std::ostream& os, int types); |
534 | |
535 friend string_vector get_file_list (const dir_info::fcn_file_map_type& lst); | |
536 | |
537 friend void | |
538 print_fcn_list (std::ostream& os, const dir_info::fcn_file_map_type& lst); | |
539 | |
5832 | 540 void do_display (std::ostream& os) const; |
541 | |
6629 | 542 std::string do_system_path (void) const { return sys_path; } |
6626 | 543 |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8329
diff
changeset
|
544 std::string do_get_command_line_path (void) const { return command_line_path; } |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8329
diff
changeset
|
545 |
5832 | 546 void add_to_fcn_map (const dir_info& di, bool at_end) const; |
7336 | 547 |
548 void add_to_private_fcn_map (const dir_info& di) const; | |
549 | |
550 void add_to_method_map (const dir_info& di, bool at_end) const; | |
551 | |
552 friend dir_info::fcn_file_map_type get_fcn_files (const std::string& d); | |
5832 | 553 }; |
554 | |
555 extern std::string | |
556 genpath (const std::string& dir, const string_vector& skip = "private"); | |
557 | |
558 extern void execute_pkg_add (const std::string& dir); | |
559 extern void execute_pkg_del (const std::string& dir); | |
560 | |
561 #endif |