From 8ac21c24e49bc3702c55d1c796f969f1d1f6128b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 7 Jun 2020 22:23:40 +0200 Subject: Storage: typed heads --- src/storage.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/storage.h') diff --git a/src/storage.h b/src/storage.h index 1635d40..18ac1ad 100644 --- a/src/storage.h +++ b/src/storage.h @@ -13,6 +13,7 @@ using std::shared_ptr; using std::unique_ptr; using std::unordered_map; using std::unordered_set; +using std::tuple; using std::variant; using std::vector; @@ -29,6 +30,11 @@ public: virtual optional> loadBytes(const Digest &) const = 0; virtual void storeBytes(const Digest &, const vector &) = 0; + virtual optional headRef(UUID type, UUID id) const = 0; + virtual vector> headRefs(UUID type) const = 0; + virtual UUID storeHead(UUID type, const Digest & dgst) = 0; + virtual bool replaceHead(UUID type, UUID id, const Digest & old, const Digest & dgst) = 0; + virtual optional> loadKey(const Digest &) const = 0; virtual void storeKey(const Digest &, const vector &) = 0; }; @@ -44,6 +50,11 @@ public: virtual optional> loadBytes(const Digest &) const override; virtual void storeBytes(const Digest &, const vector &) override; + virtual optional headRef(UUID type, UUID id) const override; + virtual vector> headRefs(UUID type) const override; + virtual UUID storeHead(UUID type, const Digest & dgst) override; + virtual bool replaceHead(UUID type, UUID id, const Digest & old, const Digest & dgst) override; + virtual optional> loadKey(const Digest &) const override; virtual void storeKey(const Digest &, const vector &) override; @@ -51,8 +62,11 @@ private: static constexpr size_t CHUNK = 16384; fs::path objectPath(const Digest &) const; + fs::path headPath(UUID id, UUID type) const; fs::path keyPath(const Digest &) const; + FILE * openLockFile(const fs::path & path) const; + fs::path root; }; @@ -67,11 +81,17 @@ public: virtual optional> loadBytes(const Digest &) const override; virtual void storeBytes(const Digest &, const vector &) override; + virtual optional headRef(UUID type, UUID id) const override; + virtual vector> headRefs(UUID type) const override; + virtual UUID storeHead(UUID type, const Digest & dgst) override; + virtual bool replaceHead(UUID type, UUID id, const Digest & old, const Digest & dgst) override; + virtual optional> loadKey(const Digest &) const override; virtual void storeKey(const Digest &, const vector &) override; private: unordered_map> storage; + unordered_map>> heads; unordered_map> keys; }; @@ -89,6 +109,11 @@ public: virtual optional> loadBytes(const Digest &) const override; virtual void storeBytes(const Digest &, const vector &) override; + virtual optional headRef(UUID type, UUID id) const override; + virtual vector> headRefs(UUID type) const override; + virtual UUID storeHead(UUID type, const Digest & dgst) override; + virtual bool replaceHead(UUID type, UUID id, const Digest & old, const Digest & dgst) override; + virtual optional> loadKey(const Digest &) const override; virtual void storeKey(const Digest &, const vector &) override; -- cgit v1.2.3