X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcache.h;h=95ae4fbfda4f1b3137d5d6ada72ede398a294591;hb=HEAD;hp=cf7253f717586982f98699d15485dd54d4272766;hpb=3938f8030b1f62802decce19777ce70fdafaff10;p=builder.git diff --git a/source/cache.h b/source/cache.h deleted file mode 100644 index cf7253f..0000000 --- a/source/cache.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef CACHE_H_ -#define CACHE_H_ - -#include -#include -#include -#include - -class SourcePackage; -class Target; - -/** -Stores data between build runs. This can be used to avoid scanning files again -every time builder is run, or to detect outside changes. - -Data is stored as lists of strings and keyed to target and an arbitrary -identifier. Any kind of strings can be stored, even ones that contain -unprintable characters or nuls. -*/ -class Cache -{ -public: - using Values = std::list; -private: - using Key = std::pair; - - SourcePackage &package; - Msp::FS::Path filename; - std::map data; - Msp::Time::TimeStamp mtime; - mutable bool changed; - -public: - Cache(SourcePackage &p); - - /// Sets a key to a single value, replacing any existing values. - void set_value(const Target *, const std::string &, const std::string &); - - /// Appends a value to a key. If the key does not exist, it is created. - void append_value(const Target *, const std::string &, const std::string &); - - /// Sets a key to a list of values, replacing any existing values. - void set_values(const Target *, const std::string &, const Values &); - - /** Returns the first value from a key. The key must exist and be - non-empty. */ - const std::string &get_value(const Target *, const std::string &); - - /// Returns the values from a key. The key must exist. - const Values &get_values(const Target *, const std::string &); - - /// Indicates whether a key exists. - bool has_key(const Target *, const std::string &); - - /// Returns the last modification timestamp of the cache. - const Msp::Time::TimeStamp &get_mtime() const { return mtime; } - - /** Loads the cache file and sets the last modification timestamp - accordingly. */ - void load(); - - /** Saves the cache. Does nothing if there is no data to save or nothing - has changed. */ - void save() const; -}; - -#endif