Blender  V2.93
BLI_session_uuid.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include "DNA_session_uuid_types.h"
28 
29 /* Generate new UUID which is unique throughout the Blender session. */
31 
32 /* Check whether the UUID is properly generated. */
34 
35 /* Check whether two UUIDs are identical. */
36 bool BLI_session_uuid_is_equal(const SessionUUID *lhs, const SessionUUID *rhs);
37 
39 
40 /* Utility functions to make it possible to create GHash/GSet with UUID as a key. */
41 uint BLI_session_uuid_ghash_hash(const void *uuid_v);
42 bool BLI_session_uuid_ghash_compare(const void *lhs_v, const void *rhs_v);
43 
44 #ifdef __cplusplus
45 }
46 #endif
47 
48 #ifdef __cplusplus
49 
50 namespace blender {
51 
52 inline const bool operator==(const SessionUUID &lhs, const SessionUUID &rhs)
53 {
54  return BLI_session_uuid_is_equal(&lhs, &rhs);
55 }
56 
57 template<typename T> struct DefaultHash;
58 
59 template<> struct DefaultHash<SessionUUID> {
60  uint64_t operator()(const SessionUUID &value) const
61  {
62  return BLI_session_uuid_hash_uint64(&value);
63  }
64 };
65 
66 } // namespace blender
67 
68 #endif
uint64_t BLI_session_uuid_hash_uint64(const SessionUUID *uuid)
Definition: session_uuid.c:62
bool BLI_session_uuid_ghash_compare(const void *lhs_v, const void *rhs_v)
Definition: session_uuid.c:73
SessionUUID BLI_session_uuid_generate(void)
Definition: session_uuid.c:36
uint BLI_session_uuid_ghash_hash(const void *uuid_v)
Definition: session_uuid.c:67
bool BLI_session_uuid_is_equal(const SessionUUID *lhs, const SessionUUID *rhs)
Definition: session_uuid.c:57
bool BLI_session_uuid_is_generated(const SessionUUID *uuid)
Definition: session_uuid.c:52
unsigned int uint
Definition: BLI_sys_types.h:83
constexpr bool operator==(StringRef a, StringRef b)
unsigned __int64 uint64_t
Definition: stdint.h:93
uint64_t operator()(const T &value) const
Definition: BLI_hash.hh:95