summaryrefslogtreecommitdiff
path: root/src/buildtool/common/protocol_traits.hpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-09-11 10:21:13 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-09-13 14:41:00 +0200
commitddf48a60029bed958fb2cf0238dbb0bca0b770fb (patch)
tree6c42568d14624a36a4f9b07d578d2a001764065d /src/buildtool/common/protocol_traits.hpp
parentf60d39620b29aeaf1addeb244bdd6e15ddf4894c (diff)
downloadjustbuild-ddf48a60029bed958fb2cf0238dbb0bca0b770fb.tar.gz
Add to ProtocolTraits static functions that provide protocol-specific behaviour
Diffstat (limited to 'src/buildtool/common/protocol_traits.hpp')
-rw-r--r--src/buildtool/common/protocol_traits.hpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/buildtool/common/protocol_traits.hpp b/src/buildtool/common/protocol_traits.hpp
index 49850233..f1a51cbe 100644
--- a/src/buildtool/common/protocol_traits.hpp
+++ b/src/buildtool/common/protocol_traits.hpp
@@ -15,6 +15,8 @@
#ifndef INCLUDED_SRC_BUILDTOOL_COMMON_PROTOCOL_TRAITS_HPP
#define INCLUDED_SRC_BUILDTOOL_COMMON_PROTOCOL_TRAITS_HPP
+#include "src/buildtool/crypto/hash_function.hpp"
+
class ProtocolTraits final {
public:
[[nodiscard]] static auto Instance() noexcept -> ProtocolTraits& {
@@ -26,6 +28,16 @@ class ProtocolTraits final {
}
void SetCompatible(bool value = true) noexcept { compatible_ = value; }
+ inline static constexpr auto IsNative(HashFunction::Type hash_type) noexcept
+ -> bool {
+ return hash_type == HashFunction::Type::GitSHA1;
+ }
+
+ inline static constexpr auto IsTreeAllowed(
+ HashFunction::Type hash_type) noexcept -> bool {
+ return IsNative(hash_type);
+ }
+
private:
bool compatible_ = false;
};