]> git.lyx.org Git - lyx.git/blob - src/DepTable.h
include sys/time.h
[lyx.git] / src / DepTable.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *           Copyright 1995 Matthias Ettrich
7  *           Copyright 1995-2001 The LyX Team.
8  *
9  *           This file is Copyright 1996-2001
10  *           Lars Gullik Bjønnes
11  *           Ben Stanley
12  *
13  * ======================================================
14  */
15
16 #ifndef DEP_TABLE_H
17 #define DEP_TABLE_H
18
19 #include "LString.h"
20 #include <map>
21
22 ///
23 class DepTable {
24 public:
25         /** This one is a little bit harder since we need the absolute
26           filename. Should we insert files with .sty .cls etc as
27           extension? */
28         void insert(string const & f,
29                     bool upd = false);
30         ///
31         void update();
32
33         ///
34         void write(string const & f) const;
35         ///
36         void read(string const & f);
37         /// returns true if any of the files has changed
38         bool sumchange() const;
39         /// return true if fil has changed.
40         bool haschanged(string const & fil) const;
41         /// return true if a file with extension ext has changed.
42         bool extchanged(string const & ext) const;
43         ///
44         bool exist(string const & fil) const;
45         /// returns true if any files with ext exist
46         bool ext_exist(string const & ext) const;
47         ///
48         void remove_files_with_extension(string const &);
49         ///
50         void remove_file(string const &);
51 private:
52         ///
53         struct dep_info {
54                 /// Previously calculated CRC value
55                 unsigned long crc_prev;
56                 /// Current CRC value - only re-computed if mtime has changed.
57                 unsigned long crc_cur;
58                 /// mtime from last time current CRC was calculated.
59                 long mtime_cur;
60                 ///
61                 bool changed() const;
62         };
63         ///
64         typedef std::map<string, dep_info> DepList;
65         ///
66         DepList deplist;
67 };
68
69 #endif