[Bf-blender-cvs] [f8294b33b8b] temp-T78835: BLI: Allow use of SessionUUID in Map

Sergey Sharybin noreply at git.blender.org
Thu Jul 30 15:44:36 CEST 2020


Commit: f8294b33b8bb2319658b9ebdb7f510c7f5518382
Author: Sergey Sharybin
Date:   Thu Jul 30 15:24:17 2020 +0200
Branches: temp-T78835
https://developer.blender.org/rBf8294b33b8bb2319658b9ebdb7f510c7f5518382

BLI: Allow use of SessionUUID in Map

===================================================================

M	source/blender/blenlib/BLI_session_uuid.h
M	source/blender/blenlib/intern/session_uuid.c

===================================================================

diff --git a/source/blender/blenlib/BLI_session_uuid.h b/source/blender/blenlib/BLI_session_uuid.h
index 93097e9959d..02feb1a072d 100644
--- a/source/blender/blenlib/BLI_session_uuid.h
+++ b/source/blender/blenlib/BLI_session_uuid.h
@@ -36,6 +36,8 @@ bool BLI_session_uuid_is_generated(const SessionUUID *uuid);
 /* Check whether two UUIDs are identical. */
 bool BLI_session_uuid_is_equal(const SessionUUID *lhs, const SessionUUID *rhs);
 
+uint64_t BLI_session_uuid_hash_uint64(const SessionUUID *uuid);
+
 /* Utility functions to make it possible to create GHash/GSet with UUID as a key. */
 uint BLI_session_uuid_ghash_hash(const void *uuid_v);
 bool BLI_session_uuid_ghash_compare(const void *lhs_v, const void *rhs_v);
@@ -44,4 +46,26 @@ bool BLI_session_uuid_ghash_compare(const void *lhs_v, const void *rhs_v);
 }
 #endif
 
+#ifdef __cplusplus
+
+namespace blender {
+
+inline const bool operator==(const SessionUUID &lhs, const SessionUUID &rhs)
+{
+  return BLI_session_uuid_is_equal(&lhs, &rhs);
+}
+
+template<typename T> struct DefaultHash;
+
+template<> struct DefaultHash<SessionUUID> {
+  uint64_t operator()(const SessionUUID &value) const
+  {
+    return BLI_session_uuid_hash_uint64(&value);
+  }
+};
+
+}  // namespace blender
+
+#endif
+
 #endif /* __BLI_SESSION_UUID_H__ */
diff --git a/source/blender/blenlib/intern/session_uuid.c b/source/blender/blenlib/intern/session_uuid.c
index 30d1839116e..51d1177a332 100644
--- a/source/blender/blenlib/intern/session_uuid.c
+++ b/source/blender/blenlib/intern/session_uuid.c
@@ -59,6 +59,11 @@ bool BLI_session_uuid_is_equal(const SessionUUID *lhs, const SessionUUID *rhs)
   return lhs->uuid_ == rhs->uuid_;
 }
 
+uint64_t BLI_session_uuid_hash_uint64(const SessionUUID *uuid)
+{
+  return uuid->uuid_;
+}
+
 uint BLI_session_uuid_ghash_hash(const void *uuid_v)
 {
   const SessionUUID *uuid = (const SessionUUID *)uuid_v;



More information about the Bf-blender-cvs mailing list