annotate src/fn-cache.h @ 2232:834eab508368

[project @ 1996-05-17 17:11:40 by jwe] Initial revision
author jwe
date Fri, 17 May 1996 17:11:40 +0000
parents
children 0da2c91573d9
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
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
3 Copyright (C) 1996 John W. Eaton
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>
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
27
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
28 #include "Map.h"
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 class string_vector;
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 // XXX FIXME XXX -- this should maybe be nested in the
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
33 // octave_fcn_file_name_cache class...
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
34
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
35 class
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
36 file_name_cache_elt
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
37 {
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
38 public:
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 file_name_cache_elt (const string& dir_name = string ())
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
41 : timestamp (0), fcn_file_names (), fcn_file_names_no_suffix ()
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
42 { update (dir_name); }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
43
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
44 file_name_cache_elt (const file_name_cache_elt& elt)
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
45 {
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
46 timestamp = elt.timestamp;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
47 fcn_file_names = elt.fcn_file_names;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
48 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
49 }
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& operator = (const file_name_cache_elt& elt)
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
52 {
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
53 if (&elt != this)
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
54 {
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
55 timestamp = elt.timestamp;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
56 fcn_file_names = elt.fcn_file_names;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
57 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
58 }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
59 return *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
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
62 ~file_name_cache_elt (void) { }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
63
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
64 int length (void) { return fcn_file_names.length (); }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
65
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
66 bool update (const string& dir_name);
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 // The time we last read this directory.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
69 time_t timestamp;
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 // The list of file names in this directory.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
72 string_vector fcn_file_names;
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 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
75 // suffixes.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
76 string_vector fcn_file_names_no_suffix;
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
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
79 class
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
80 octave_fcn_file_name_cache
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
81 {
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
82 protected:
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 octave_fcn_file_name_cache (void)
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
85 : cache (file_name_cache_elt ())
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
86 { update (); }
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 public:
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
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
92 bool update (void);
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 static string_vector list (bool no_suffix = false);
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 static string_vector list_no_suffix (void) { return list (true); }
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
97
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
98 private:
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
99
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
100 static octave_fcn_file_name_cache *instance;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
101
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
102 // 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
103 // and the corresponding cache elements.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
104 CHMap<file_name_cache_elt> cache;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
105
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
106 // The list of function file names in the cache.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
107 string_vector fcn_file_names;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
108
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
109 // The list of function file names in the cache without the .m or
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
110 // .oct suffixes.
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
111 string_vector fcn_file_names_no_suffix;
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
112
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
113 string_vector do_list (bool no_suffix);
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
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
116 #endif
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
117
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
118 /*
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
119 ;;; Local Variables: ***
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
120 ;;; mode: C++ ***
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
121 ;;; End: ***
834eab508368 [project @ 1996-05-17 17:11:40 by jwe]
jwe
parents:
diff changeset
122 */