Iray SDK API nvidia_logo_transpbg.gif Up
identifier.h
Go to the documentation of this file.
1/***************************************************************************************************
2 * Copyright 2024 NVIDIA Corporation. All rights reserved.
3 **************************************************************************************************/
6
7#ifndef MI_NEURAYLIB_IDENTIFIER_H
8#define MI_NEURAYLIB_IDENTIFIER_H
9
10#include <mi/base/types.h>
11
12namespace mi {
13
14namespace neuraylib {
15
29 HND_SCENE_GRAPH_VERSION,
30 HND_SCENE_GRAPH_NODE,
31 HND_SCENE_GRAPH_OBJECT_NODE,
32 HND_SCENE_GRAPH_LIGHT_NODE,
33 HND_SCENE_GRAPH_MESH,
34 HND_SCENE_GRAPH_MATERIAL,
35 HND_SCENE_GRAPH_DECAL_NODE,
36 HND_SCENE_GRAPH_PROJECTOR_NODE,
37 HND_SCENE_GRAPH_SECTION_OBJECT_NODE
38};
39
40template <typename T> struct Invalid_identifier { };
41template <> struct Invalid_identifier<Uint32>
42{
43 static inline Uint32 value( ) { return 0xffffffff; }
44};
45
46template <> struct Invalid_identifier<Uint64>
47{
48 static inline Uint64 value( ) { return 0xffffffffffffffffull; }
49};
50
54template <Identifier_name name, typename Int_type = Uint32>
56{
58 Int_type m_id;
59};
60
64template <Identifier_name name, typename Int_type = Uint32>
65class Identifier : public Identifier_struct<name, Int_type>
66{
67public:
69 Identifier( ) { this->m_id = Invalid_identifier<Int_type>::value(); }
70
72 explicit Identifier( Int_type h ) { this->m_id = h; }
73
76
78 operator Int_type() const { return this->m_id; }
79
81 Int_type operator*() const { return this->m_id; }
82
84 bool is_valid( ) const { return this->m_id != Invalid_identifier<Int_type>::value(); }
85
87 Identifier& operator++() { ++this->m_id; return *this; }
88
90 Identifier operator++(int) { Identifier h(*this); ++this->m_id; return h; }
91
93 Identifier& operator--() { --this->m_id; return *this; }
94
96 Identifier operator--(int) { Identifier h(*this); --this->m_id; return h; }
97
99 bool operator<( const Identifier &other ) const { return this->m_id < other.m_id; }
100
102 bool operator<=( const Identifier &other ) const { return this->m_id <= other.m_id; }
103
105 bool operator>( const Identifier &other ) const { return this->m_id > other.m_id; }
106
108 bool operator>=( const Identifier &other ) const { return this->m_id >= other.m_id; }
109};
110 // end group mi_neuray
112
121
126
131
136
141
146
151
156
161
166
171
176
181
186
187} // namespace neuraylib
188
189} // namespace mi
190
191#endif // MI_NEURAYLIB_IDENTIFIER_H
Handle class for type-safety.
Definition: identifier.h:66
unsigned long long Uint64
64-bit unsigned integer.
Definition: types.h:62
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
Identifier< HND_TEXTURE_SURFACE > Texture_surface_handle
Handle for texture surfaces
Definition: identifier.h:180
Identifier & operator++()
Pre-increment operator.
Definition: identifier.h:87
Identifier_struct< HND_CURVE > Curve_handle_struct
Handle for curves
Definition: identifier.h:135
Identifier & operator--()
Pre-decrement operator.
Definition: identifier.h:93
bool operator>=(const Identifier &other) const
Greater-than-or-equal-to operator.
Definition: identifier.h:108
Identifier_struct< HND_TRIANGLE > Triangle_handle_struct
Handle for triangles
Definition: identifier.h:120
Int_type operator*() const
Dereferences the handle. Returns its integer value.
Definition: identifier.h:81
Identifier_struct< HND_SURFACE > Surface_handle_struct
Handle for surfaces
Definition: identifier.h:130
Int_type m_id
The handle ID.
Definition: identifier.h:58
bool operator>(const Identifier &other) const
Greater-than operator.
Definition: identifier.h:105
Identifier< HND_FIBER > Fiber_handle
Handle for fibers
Definition: identifier.h:185
Identifier_struct< HND_FIBER, Uint64 > Fiber_handle_struct
Handle for fibers
Definition: identifier.h:150
Identifier< HND_POLY > Polygon_handle
Handle for polygons
Definition: identifier.h:160
Identifier operator--(int)
Post-decrement operator.
Definition: identifier.h:96
Identifier_struct< HND_POLY > Polygon_handle_struct
Handle for polygons
Definition: identifier.h:125
Identifier< HND_TRIANGLE > Triangle_handle
Handle for triangles
Definition: identifier.h:155
Identifier_struct< HND_TEXTURE_SURFACE > Texture_surface_handle_struct
Handle for texture surfaces
Definition: identifier.h:145
bool operator<=(const Identifier &other) const
Less-than-or-equal-to operator.
Definition: identifier.h:102
Identifier< HND_CURVE > Curve_handle
Handle for curve
Definition: identifier.h:170
Identifier operator++(int)
Post-increment operator.
Definition: identifier.h:90
Identifier< HND_SURFACE > Surface_handle
Handle for surfaces
Definition: identifier.h:165
bool operator<(const Identifier &other) const
Less-than operator.
Definition: identifier.h:99
Identifier< HND_CURVE_SEGMENT > Curve_segment_handle
Handle for curve segments
Definition: identifier.h:175
Identifier()
Default constructor. Initializes handle with invalid value.
Definition: identifier.h:69
Identifier_struct< HND_CURVE_SEGMENT > Curve_segment_handle_struct
Handle for curve segments
Definition: identifier.h:140
Identifier(Int_type h)
Constructor. Initializes handle with given integer value.
Definition: identifier.h:72
bool is_valid() const
Returns whether the handle is valid.
Definition: identifier.h:84
Identifier(Identifier_struct<name, Int_type> h)
Constructor from underlying storage type.
Definition: identifier.h:75
Identifier_name
Various handle types.
Definition: identifier.h:21
@ HND_CURVE_SEGMENT
Curve_segment_handle
Definition: identifier.h:26
@ HND_SURFACE
Surface_handle
Definition: identifier.h:24
@ HND_CURVE
Curve_handle
Definition: identifier.h:25
@ HND_TRIANGLE
Triangle_handle
Definition: identifier.h:22
@ HND_FIBER
Fiber_handle
Definition: identifier.h:28
@ HND_TEXTURE_SURFACE
Texture_surface_handle
Definition: identifier.h:27
@ HND_POLY
Polygon_handle
Definition: identifier.h:23
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: neuraylib.h:179
Handle class for type-safety.
Definition: identifier.h:56
Basic types.