]> git.lyx.org Git - lyx.git/blob - src/DepTable.h
Avoid full metrics computation with Update:FitCursor
[lyx.git] / src / DepTable.h
1 // -*- C++ -*-
2 /**
3  * \file DepTable.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Jean-Marc Lasgouttes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef DEP_TABLE_H
14 #define DEP_TABLE_H
15
16 #include <ctime>
17 #include <map>
18 #include <string>
19
20
21 namespace lyx {
22
23 namespace support { class FileName; }
24
25 ///
26 class DepTable {
27 public:
28         /** This one is a little bit harder since we need the absolute
29           filename. Should we insert files with .sty .cls etc as
30           extension? */
31         void insert(support::FileName const & f, bool upd = false);
32         ///
33         void update();
34
35         ///
36         void write(support::FileName const & f) const;
37         /// returns true if dep file was read successfully
38         bool read(support::FileName const & f);
39         /// returns true if any of the files has changed
40         bool sumchange() const;
41         /// return true if fil has changed.
42         bool haschanged(support::FileName const & fil) const;
43         /// return true if a file with extension ext has changed.
44         bool extchanged(std::string const & ext) const;
45         ///
46         bool exist(support::FileName const & fil) const;
47         /// returns true if any files with ext exist
48         bool ext_exist(std::string const & ext) const;
49         ///
50         void remove_files_with_extension(std::string const &);
51         ///
52         void remove_file(support::FileName const &);
53 private:
54         ///
55         class dep_info {
56         public:
57                 /// Previously calculated CRC value
58                 unsigned long crc_prev;
59                 /// Current CRC value - only re-computed if mtime has changed.
60                 unsigned long crc_cur;
61                 /// mtime from last time current CRC was calculated.
62                 std::time_t mtime_cur;
63                 ///
64                 bool changed() const;
65         };
66         ///
67         typedef std::map<support::FileName, dep_info> DepList;
68         ///
69         DepList deplist;
70 };
71
72
73 } // namespace lyx
74
75 #endif