]> git.tdb.fi Git - builder.git/blob - source/dependencycache.h
Add DependencyCache to speed up build preparation
[builder.git] / source / dependencycache.h
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef DEPENDENCYCACHE_H_
9 #define DEPENDENCYCACHE_H_
10
11 #include <msp/time/timestamp.h>
12 #include "misc.h"
13
14 class Package;
15
16 /**
17 Stores dependencies to avoid expensive operations during DAG building phase.
18 The dependencies are stored in a map with target name as key and a list of
19 strings as value.  The targets are free to store whatever they want here.
20 */
21 class DependencyCache
22 {
23 public:
24         DependencyCache(Package &p);
25         void             set_deps(const std::string &tgt, const StringList &d);
26         const StringList &get_deps(const std::string &tgt) const;
27         const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
28         void             load();
29         void             save() const;
30 private:
31         typedef std::map<std::string, StringList> DepsMap;
32
33         Package &package;
34         DepsMap deps;
35         Msp::Time::TimeStamp mtime;
36         bool changed;
37 };
38
39 #endif