Math API nvidia_logo_transpbg.gif Up
uuid.h
Go to the documentation of this file.
1/***************************************************************************************************
2 * Copyright 2023 NVIDIA Corporation. All rights reserved.
3 **************************************************************************************************/
8
9#ifndef MI_BASE_UUID_H
10#define MI_BASE_UUID_H
11
12#include <mi/base/types.h>
13
14namespace mi {
15namespace base {
16
25struct Uuid
26{
31};
32
34inline bool operator==( const Uuid & id1, const Uuid & id2)
35{
36 if( id1.m_id1 != id2.m_id1 ) return false;
37 if( id1.m_id2 != id2.m_id2 ) return false;
38 if( id1.m_id3 != id2.m_id3 ) return false;
39 if( id1.m_id4 != id2.m_id4 ) return false;
40 return true;
41}
42
44inline bool operator!=( const Uuid & id1, const Uuid & id2)
45{
46 if( id1.m_id1 != id2.m_id1 ) return true;
47 if( id1.m_id2 != id2.m_id2 ) return true;
48 if( id1.m_id3 != id2.m_id3 ) return true;
49 if( id1.m_id4 != id2.m_id4 ) return true;
50 return false;
51}
52
54inline bool operator<( const Uuid & id1, const Uuid & id2)
55{
56 if( id1.m_id1 < id2.m_id1 ) return true;
57 if( id1.m_id1 > id2.m_id1 ) return false;
58 if( id1.m_id2 < id2.m_id2 ) return true;
59 if( id1.m_id2 > id2.m_id2 ) return false;
60 if( id1.m_id3 < id2.m_id3 ) return true;
61 if( id1.m_id3 > id2.m_id3 ) return false;
62 if( id1.m_id4 < id2.m_id4 ) return true;
63 return false;
64}
65
67inline bool operator >( const Uuid & id1, const Uuid & id2) {
68 if( id1.m_id1 > id2.m_id1 ) return true;
69 if( id1.m_id1 < id2.m_id1 ) return false;
70 if( id1.m_id2 > id2.m_id2 ) return true;
71 if( id1.m_id2 < id2.m_id2 ) return false;
72 if( id1.m_id3 > id2.m_id3 ) return true;
73 if( id1.m_id3 < id2.m_id3 ) return false;
74 if( id1.m_id4 > id2.m_id4 ) return true;
75 return false;
76}
77
79inline bool operator<=( const Uuid & id1, const Uuid & id2)
80{
81 return !(id1 > id2);
82}
83
85inline bool operator >=( const Uuid & id1, const Uuid & id2)
86{
87 return !(id1 < id2);
88}
89
91inline Uint32 uuid_hash32( const Uuid& id)
92{
93 return id.m_id1 ^ id.m_id2 ^ id.m_id3 ^ id.m_id4;
94}
95
96
118template <Uint32 id1, Uint16 id2, Uint16 id3
119 , Uint8 id4, Uint8 id5, Uint8 id6, Uint8 id7
120 , Uint8 id8, Uint8 id9, Uint8 id10, Uint8 id11>
122{
123public:
128 operator const Uuid & () const
129 {
130 static const Uuid uuid = {m_id1, m_id2, m_id3, m_id4};
131 return uuid;
132 }
133
135 static const Uint32 m_id1 = id1;
136
138 static const Uint32 m_id2 = static_cast<Uint32>( id2 | (id3 << 16));
139
141 static const Uint32 m_id3
142 = static_cast<Uint32>( id4 | (id5 << 8) | (id6 << 16) | (id7 << 24));
143
145 static const Uint32 m_id4
146 = static_cast<Uint32>( id8 | (id9 << 8) | (id10 << 16) | (id11 << 24));
147
149 static const Uint32 hash32 = m_id1 ^ m_id2 ^ m_id3 ^ m_id4;
150};
151 // end group mi_base_iinterface
153
154} // namespace base
155} // namespace mi
156
157#endif // MI_BASE_UUID_H
Class template for a compile-time representation of universally unique identifiers (UUIDs or GUIDs).
Definition: uuid.h:122
static const Uint32 m_id1
First 32 bit out of four.
Definition: uuid.h:135
static const Uint32 m_id4
Fourth 32 bit out of four.
Definition: uuid.h:146
Uint32 m_id1
First value.
Definition: uuid.h:27
static const Uint32 m_id3
Third 32 bit out of four.
Definition: uuid.h:142
bool operator==(const Handle<Interface1> &lhs, const Handle<Interface2> &rhs)
Returns true if the underlying interface pointers are equal.
Definition: handle.h:410
static const Uint32 m_id2
Second 32 bit out of four.
Definition: uuid.h:138
Uint32 uuid_hash32(const Uuid &id)
Returns a 32 bit hash value by performing a bitwise xor of all four 32 bit values.
Definition: uuid.h:91
bool operator>=(const Uuid &id1, const Uuid &id2)
Returns true if id1 is greater than or equal to id2.
Definition: uuid.h:85
bool operator>(const Uuid &id1, const Uuid &id2)
Returns true if id1 is greater than id2.
Definition: uuid.h:67
Uint32 m_id2
Second value.
Definition: uuid.h:28
static const Uint32 hash32
A 32 bit hash value from a bitwise xor of all four 32 bit values.
Definition: uuid.h:149
bool operator<(const Uuid &id1, const Uuid &id2)
Returns true if id1 is less than id2.
Definition: uuid.h:54
bool operator<=(const Uuid &id1, const Uuid &id2)
Returns true if id1 is less than or equal to id2.
Definition: uuid.h:79
bool operator!=(const Handle<Interface1> &lhs, const Handle<Interface2> &rhs)
Returns true if the underlying interface pointers are not equal.
Definition: handle.h:417
Uint32 m_id3
Third value.
Definition: uuid.h:29
Uint32 m_id4
Fourth value.
Definition: uuid.h:30
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
unsigned char Uint8
8-bit unsigned integer.
Definition: types.h:47
unsigned short Uint16
16-bit unsigned integer.
Definition: types.h:48
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: math.h:22
A 128 bit representation of a universally unique identifier (UUID or GUID).
Definition: uuid.h:26
Basic types.