]> git.tdb.fi Git - builder.git/blob - source/dependencycache.h
Big rewrite for a more tool-centric approach
[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         void set_deps(const std::string &tgt, const StringList &d);
27         const StringList &get_deps(const std::string &tgt) const;
28         const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
29         void load();
30
31         /**
32         Saves the depencency cache.  Does nothing if the cache is empty or nothing
33         has changed. */
34         void save() const;
35 };
36
37 #endif