]> git.tdb.fi Git - builder.git/blobdiff - source/dependencycache.h
Add DependencyCache to speed up build preparation
[builder.git] / source / dependencycache.h
diff --git a/source/dependencycache.h b/source/dependencycache.h
new file mode 100644 (file)
index 0000000..5cde40d
--- /dev/null
@@ -0,0 +1,39 @@
+/* $Id$
+
+This file is part of builder
+Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef DEPENDENCYCACHE_H_
+#define DEPENDENCYCACHE_H_
+
+#include <msp/time/timestamp.h>
+#include "misc.h"
+
+class Package;
+
+/**
+Stores dependencies to avoid expensive operations during DAG building phase.
+The dependencies are stored in a map with target name as key and a list of
+strings as value.  The targets are free to store whatever they want here.
+*/
+class DependencyCache
+{
+public:
+       DependencyCache(Package &p);
+       void             set_deps(const std::string &tgt, const StringList &d);
+       const StringList &get_deps(const std::string &tgt) const;
+       const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
+       void             load();
+       void             save() const;
+private:
+       typedef std::map<std::string, StringList> DepsMap;
+
+       Package &package;
+       DepsMap deps;
+       Msp::Time::TimeStamp mtime;
+       bool changed;
+};
+
+#endif