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