]> git.tdb.fi Git - builder.git/blob - source/dependencycache.h
Reorder class members
[builder.git] / source / dependencycache.h
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2007, 2009  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 private:
24         typedef std::map<std::string, StringList> DepsMap;
25
26         SourcePackage &package;
27         DepsMap deps;
28         Msp::Time::TimeStamp mtime;
29         bool changed;
30
31 public:
32         DependencyCache(SourcePackage &p);
33         void set_deps(const std::string &tgt, const StringList &d);
34         const StringList &get_deps(const std::string &tgt) const;
35         const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
36         void load();
37
38         /**
39         Saves the depencency cache.  Does nothing if the cache is empty or nothing
40         has changed. */
41         void save() const;
42 };
43
44 #endif