]> git.tdb.fi Git - builder.git/blob - source/dependencycache.h
Comment updates
[builder.git] / source / dependencycache.h
1 #ifndef DEPENDENCYCACHE_H_
2 #define DEPENDENCYCACHE_H_
3
4 #include <msp/time/timestamp.h>
5 #include "misc.h"
6
7 class Package;
8
9 /**
10 Stores dependencies to avoid expensive filesystem operations during DAG
11 building phase.  The dependencies are stored in a map with target name as key
12 and a list of strings as value.  The targets are free to store whatever they
13 want here.
14 */
15 class DependencyCache
16 {
17 private:
18         typedef std::map<std::string, StringList> DepsMap;
19
20         SourcePackage &package;
21         DepsMap deps;
22         Msp::Time::TimeStamp mtime;
23         bool changed;
24
25 public:
26         DependencyCache(SourcePackage &p);
27
28         void set_deps(const std::string &tgt, const StringList &d);
29         bool has_deps(const std::string &tgt) const;
30         const StringList &get_deps(const std::string &tgt) const;
31         const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
32         void load();
33
34         /** Saves the depencency cache.  Does nothing if the cache is empty or
35         nothing has changed. */
36         void save() const;
37 };
38
39 #endif