annotate src/fn-cache.h @ 2847:8b262e771614

[project @ 1997-03-27 16:18:26 by jwe]
author jwe
date Thu, 27 Mar 1997 16:19:58 +0000
parents 874f758eade5
children 4d33b1e56bff
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
2284
a83ae9534d2c [project @ 1996-05-28 17:03:46 by jwe]
jwe
parents: 2233
diff changeset
26 #include <ctime>
a83ae9534d2c [project @ 1996-05-28 17:03:46 by jwe]
jwe
parents: 2233
diff changeset
27
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
28 #include <string>
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
29
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
30 #include "Map.h"
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
31
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
32 class string_vector;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
33
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
34 // XXX FIXME XXX -- this should maybe be nested in the
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
35 // octave_fcn_file_name_cache class...
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
36
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
37 class
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
38 file_name_cache_elt
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
39 {
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
40 public:
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
41
2432
874f758eade5 [project @ 1996-10-26 16:37:36 by jwe]
jwe
parents: 2370
diff changeset
42 file_name_cache_elt (void)
874f758eade5 [project @ 1996-10-26 16:37:36 by jwe]
jwe
parents: 2370
diff changeset
43 : timestamp (0), fcn_file_names (), fcn_file_names_no_suffix ()
874f758eade5 [project @ 1996-10-26 16:37:36 by jwe]
jwe
parents: 2370
diff changeset
44 { update (string ()); }
874f758eade5 [project @ 1996-10-26 16:37:36 by jwe]
jwe
parents: 2370
diff changeset
45
874f758eade5 [project @ 1996-10-26 16:37:36 by jwe]
jwe
parents: 2370
diff changeset
46 file_name_cache_elt (const string& dir_name)
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
47 : timestamp (0), fcn_file_names (), fcn_file_names_no_suffix ()
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
48 { update (dir_name); }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
49
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
50 file_name_cache_elt (const file_name_cache_elt& elt)
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
51 {
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
52 timestamp = elt.timestamp;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
53 fcn_file_names = elt.fcn_file_names;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
54 fcn_file_names_no_suffix = elt.fcn_file_names_no_suffix;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
55 }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
56
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
57 file_name_cache_elt& operator = (const file_name_cache_elt& elt)
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
58 {
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
59 if (&elt != this)
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
60 {
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
61 timestamp = elt.timestamp;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
62 fcn_file_names = elt.fcn_file_names;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
63 fcn_file_names_no_suffix = elt.fcn_file_names_no_suffix;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
64 }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
65 return *this;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
66 }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
67
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
68 ~file_name_cache_elt (void) { }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
69
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
70 int length (void) { return fcn_file_names.length (); }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
71
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
72 bool update (const string& dir_name);
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
73
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
74 // The time we last read this directory.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
75 time_t timestamp;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
76
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
77 // The list of file names in this directory.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
78 string_vector fcn_file_names;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
79
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
80 // 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
81 // suffixes.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
82 string_vector fcn_file_names_no_suffix;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
83 };
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 class
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
86 octave_fcn_file_name_cache
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
87 {
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
88 protected:
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
89
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
90 octave_fcn_file_name_cache (void)
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
91 : cache (file_name_cache_elt ())
2432
874f758eade5 [project @ 1996-10-26 16:37:36 by jwe]
jwe
parents: 2370
diff changeset
92 { update (string ()); }
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
93
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
94 public:
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
95
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
96 ~octave_fcn_file_name_cache (void) { }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
97
2432
874f758eade5 [project @ 1996-10-26 16:37:36 by jwe]
jwe
parents: 2370
diff changeset
98 bool update (const string& path);
2233
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
99
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
100 static string_vector list (bool no_suffix = false)
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
101 { return list (string (), no_suffix); }
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
102
2233
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
103 static string_vector list (const string& path, bool no_suffix = false);
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
104
2233
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
105 static string_vector list_no_suffix (void)
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
106 { return list (true); }
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
107
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
108 static string_vector list_no_suffix (const string& path)
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
109 { return list (path, true); }
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
110
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
111 private:
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
112
2370
a45c7d64b5e3 [project @ 1996-10-11 23:51:15 by jwe]
jwe
parents: 2286
diff changeset
113 static octave_fcn_file_name_cache* instance;
2232
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
114
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
115 // 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
116 // and the corresponding cache elements.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
117 CHMap<file_name_cache_elt> cache;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
118
2233
0da2c91573d9 [project @ 1996-05-17 17:27:17 by jwe]
jwe
parents: 2232
diff changeset
119 string_vector do_list (const string& path, bool no_suffix);
2232
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
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
122 #endif
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 /*
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
125 ;;; Local Variables: ***
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
126 ;;; mode: C++ ***
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
127 ;;; End: ***
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
128 */