]> git.lyx.org Git - lyx.git/blob - src/DepTable.h
6148f67736507a140c768734bf38d61d91a45ba8
[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 <map>
17
18 ///
19 class DepTable {
20 public:
21         /** This one is a little bit harder since we need the absolute
22           filename. Should we insert files with .sty .cls etc as
23           extension? */
24         void insert(std::string const & f, bool upd = false);
25         ///
26         void update();
27
28         ///
29         void write(std::string const & f) const;
30         /// returns true if dep file was read successfully
31         bool read(std::string const & f);
32         /// returns true if any of the files has changed
33         bool sumchange() const;
34         /// return true if fil has changed.
35         bool haschanged(std::string const & fil) const;
36         /// return true if a file with extension ext has changed.
37         bool extchanged(std::string const & ext) const;
38         ///
39         bool exist(std::string const & fil) const;
40         /// returns true if any files with ext exist
41         bool ext_exist(std::string const & ext) const;
42         ///
43         void remove_files_with_extension(std::string const &);
44         ///
45         void remove_file(std::string const &);
46 private:
47         ///
48         struct dep_info {
49                 /// Previously calculated CRC value
50                 unsigned long crc_prev;
51                 /// Current CRC value - only re-computed if mtime has changed.
52                 unsigned long crc_cur;
53                 /// mtime from last time current CRC was calculated.
54                 long mtime_cur;
55                 ///
56                 bool changed() const;
57         };
58         ///
59         typedef std::map<std::string, dep_info> DepList;
60         ///
61         DepList deplist;
62 };
63
64 #endif