Files
test2/source/blender/blenlib/BLI_session_uid.h
Brecht Van Lommel e2e1984e60 Refactor: Convert remainder of blenlib to C++
A few headers like BLI_math_constants.h and BLI_utildefines.h keep working
for C code, for remaining makesdna and userdef defaults code in C.

Pull Request: https://projects.blender.org/blender/blender/pulls/134406
2025-02-12 23:01:08 +01:00

55 lines
1.4 KiB
C++

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup bli
*
* Functions for generating and handling "Session UIDs".
*
* Note that these are not true universally-unique identifiers, but only unique during the current
* Blender session.
*
* For true UUIDs, see `BLI_uuid.h`.
*/
#include "DNA_session_uid_types.h"
#include "BLI_hash.hh"
/** Generate new UID which is unique throughout the Blender session. */
SessionUID BLI_session_uid_generate(void);
/** Check whether the UID is properly generated. */
bool BLI_session_uid_is_generated(const SessionUID *uid);
/** Check whether two UIDs are identical. */
bool BLI_session_uid_is_equal(const SessionUID *lhs, const SessionUID *rhs);
uint64_t BLI_session_uid_hash_uint64(const SessionUID *uid);
/* Utility functions to make it possible to create set/map with UID as a key. */
uint BLI_session_uid_ghash_hash(const void *uid_v);
bool BLI_session_uid_ghash_compare(const void *lhs_v, const void *rhs_v);
namespace blender {
inline bool operator==(const SessionUID &lhs, const SessionUID &rhs)
{
return BLI_session_uid_is_equal(&lhs, &rhs);
}
template<typename T> struct DefaultHash;
template<> struct DefaultHash<SessionUID> {
uint64_t operator()(const SessionUID &value) const
{
return BLI_session_uid_hash_uint64(&value);
}
};
} // namespace blender