diff options
Diffstat (limited to 'src/buildtool/file_system/precomputed_root.hpp')
-rw-r--r-- | src/buildtool/file_system/precomputed_root.hpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/buildtool/file_system/precomputed_root.hpp b/src/buildtool/file_system/precomputed_root.hpp index 8261b94c..6df59bc9 100644 --- a/src/buildtool/file_system/precomputed_root.hpp +++ b/src/buildtool/file_system/precomputed_root.hpp @@ -42,6 +42,22 @@ struct ComputedRoot final { [[nodiscard]] auto ComputeHash() const -> std::size_t; }; +struct TreeStructureRoot final { + static constexpr auto kMarker = "tree structure"; + static constexpr std::size_t kSchemeLength = 2; + + std::string repository; + + [[nodiscard]] auto operator==(TreeStructureRoot const& other) const noexcept + -> bool; + + [[nodiscard]] auto operator<(TreeStructureRoot const& other) const noexcept + -> bool; + + [[nodiscard]] auto ToString() const -> std::string; + [[nodiscard]] auto ComputeHash() const -> std::size_t; +}; + namespace std { template <typename> struct hash; @@ -51,7 +67,7 @@ struct hash; /// real build starts. class PrecomputedRoot final { public: - using root_t = std::variant<ComputedRoot>; + using root_t = std::variant<ComputedRoot, TreeStructureRoot>; explicit PrecomputedRoot() : PrecomputedRoot(ComputedRoot{}) {} explicit PrecomputedRoot(root_t root) : root_{std::move(root)}, hash_{ComputeHash(root_)} {} @@ -61,7 +77,8 @@ class PrecomputedRoot final { [[nodiscard]] static auto IsPrecomputedMarker( std::string const& marker) noexcept -> bool { - return marker == ComputedRoot::kMarker; + return marker == ComputedRoot::kMarker or + marker == TreeStructureRoot::kMarker; } [[nodiscard]] auto operator==(PrecomputedRoot const& other) const noexcept @@ -86,6 +103,17 @@ class PrecomputedRoot final { return std::nullopt; } + [[nodiscard]] auto IsTreeStructure() const noexcept -> bool { + return std::holds_alternative<TreeStructureRoot>(root_); + } + [[nodiscard]] auto AsTreeStructure() const noexcept + -> std::optional<TreeStructureRoot> { + if (auto const* root = std::get_if<TreeStructureRoot>(&root_)) { + return *root; + } + return std::nullopt; + } + private: root_t root_; std::size_t hash_; |