annotate src/fn-cache.h @ 4720:e759d01692db ss-2-1-53

[project @ 2004-01-23 04:13:37 by jwe]
author jwe
date Fri, 23 Jan 2004 04:13:37 +0000
parents bc6059c5ddc7
children 4c8a2e4e0717
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
1 /*
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
2
2847
8b262e771614 [project @ 1997-03-27 16:18:26 by jwe]
jwe
parents: 2432
diff changeset
3 Copyright (C) 1996, 1997 John W. Eaton
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
4
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
6
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
10 later version.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
11
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
15 for more details.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
16
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, write to the Free
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
20
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
21 */
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
22
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
23 #if !defined (octave_fn_cache_h)
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
24 #define octave_fn_cache_h 1
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
25
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
26 #include <string>
4215
bc6059c5ddc7 [project @ 2002-12-04 05:21:08 by jwe]
jwe
parents: 3523
diff changeset
27 #include <map>
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
28
3255
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
29 #include "oct-time.h"
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
30
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
31 class string_vector;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
32
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
33 // XXX FIXME XXX -- this should maybe be nested in the
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
34 // octave_fcn_file_name_cache class...
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
35
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
36 class
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
37 file_name_cache_elt
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
38 {
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
39 public:
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
40
2432
874f758eade5 [project @ 1996-10-26 16:37:36 by jwe]
jwe
parents: 2370
diff changeset
41 file_name_cache_elt (void)
3255
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
42 : timestamp (static_cast<time_t> (0)), fcn_file_names (),
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
43 fcn_file_names_no_suffix ()
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3258
diff changeset
44 { update (std::string ()); }
2432
874f758eade5 [project @ 1996-10-26 16:37:36 by jwe]
jwe
parents: 2370
diff changeset
45
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3258
diff changeset
46 file_name_cache_elt (const std::string& dir_name)
3255
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
47 : timestamp (static_cast<time_t> (0)), fcn_file_names (),
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
48 fcn_file_names_no_suffix ()
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
49 { update (dir_name); }
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
50
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
51 file_name_cache_elt (const file_name_cache_elt& elt)
3255
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
52 {
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
53 timestamp = elt.timestamp;
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
54 fcn_file_names = elt.fcn_file_names;
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
55 fcn_file_names_no_suffix = elt.fcn_file_names_no_suffix;
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
56 }
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
57
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
58 file_name_cache_elt& operator = (const file_name_cache_elt& elt)
3255
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
59 {
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
60 if (&elt != this)
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
61 {
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
62 timestamp = elt.timestamp;
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
63 fcn_file_names = elt.fcn_file_names;
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
64 fcn_file_names_no_suffix = elt.fcn_file_names_no_suffix;
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
65 }
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
66 return *this;
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
67 }
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
68
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
69 ~file_name_cache_elt (void) { }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
70
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
71 int length (void) { return fcn_file_names.length (); }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
72
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3258
diff changeset
73 bool update (const std::string& dir_name);
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
74
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
75 // The time we last read this directory.
3255
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 2847
diff changeset
76 octave_time timestamp;
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
77
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
78 // The list of file names in this directory.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
79 string_vector fcn_file_names;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
80
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
81 // The list of file names in this directory without the .m or .oct
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
82 // suffixes.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
83 string_vector fcn_file_names_no_suffix;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
84 };
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
85
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
86 class
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
87 octave_fcn_file_name_cache
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
88 {
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
89 protected:
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
90
4215
bc6059c5ddc7 [project @ 2002-12-04 05:21:08 by jwe]
jwe
parents: 3523
diff changeset
91 octave_fcn_file_name_cache (void) : cache () { update (std::string ()); }
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
92
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
93 public:
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
94
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
95 ~octave_fcn_file_name_cache (void) { }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
96
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3258
diff changeset
97 bool update (const std::string& path);
2233
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
98
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
99 static string_vector list (bool no_suffix = false)
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3258
diff changeset
100 { return list (std::string (), no_suffix); }
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
101
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3258
diff changeset
102 static string_vector list (const std::string& path, bool no_suffix = false);
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
103
2233
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
104 static string_vector list_no_suffix (void)
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
105 { return list (true); }
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
106
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3258
diff changeset
107 static string_vector list_no_suffix (const std::string& path)
2233
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
108 { return list (path, true); }
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
109
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
110 private:
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
111
2370
a45c7d64b5e3 [project @ 1996-10-11 23:51:15 by jwe]
jwe
parents: 2286
diff changeset
112 static octave_fcn_file_name_cache* instance;
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
113
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
114 // An associative array of all the directory names in the load path
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
115 // and the corresponding cache elements.
4215
bc6059c5ddc7 [project @ 2002-12-04 05:21:08 by jwe]
jwe
parents: 3523
diff changeset
116 std::map<std::string, file_name_cache_elt> cache;
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
117
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3258
diff changeset
118 string_vector do_list (const std::string& path, bool no_suffix);
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
119 };
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
120
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
121 #endif
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
122
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
123 /*
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
124 ;;; Local Variables: ***
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
125 ;;; mode: C++ ***
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
126 ;;; End: ***
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
127 */