NVIDIA Iray API Home  Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
identifier.h
Go to the documentation of this file.
1 //*****************************************************************************
2 // Copyright 1986, 2016 NVIDIA Corporation. All rights reserved.
3 //*****************************************************************************
6 //*****************************************************************************
7 
8 #ifndef MI_NEURAYLIB_IDENTIFIER_H
9 #define MI_NEURAYLIB_IDENTIFIER_H
10 
11 #include <mi/base/types.h>
12 #include <mi/neuraylib/version.h>
13 
14 namespace mi {
15 
16 namespace neuraylib {
17 
22 enum Identifier_name {
30  HND_SCENE_GRAPH_VERSION,
31  HND_SCENE_GRAPH_NODE,
32  HND_SCENE_GRAPH_OBJECT_NODE,
33  HND_SCENE_GRAPH_LIGHT_NODE,
34  HND_SCENE_GRAPH_MESH,
35  HND_SCENE_GRAPH_MATERIAL,
36  HND_SCENE_GRAPH_DECAL_NODE
37 };
38 
39 template <typename T> struct Invalid_identifier { };
40 template <> struct Invalid_identifier<Uint32>
41 {
42  static inline Uint32 value( ) { return 0xffffffff; }
43 };
44 
45 template <> struct Invalid_identifier<Uint64>
46 {
47  static inline Uint64 value( ) { return 0xffffffffffffffffull; }
48 };
49 
53 template <Identifier_name name, typename Int_type = Uint32>
55 {
57  Int_type m_id;
58 };
59 
63 template <Identifier_name name, typename Int_type = Uint32>
64 class Identifier : public Identifier_struct<name, Int_type>
65 {
66 public:
68  Identifier( ) { this->m_id = Invalid_identifier<Int_type>::value(); }
69 
71  explicit Identifier( Int_type h ) { this->m_id = h; }
72 
75 
77  operator Int_type() const { return this->m_id; }
78 
80  Int_type operator*() const { return this->m_id; }
81 
83  bool is_valid( ) const { return this->m_id != Invalid_identifier<Int_type>::value(); }
84 
86  Identifier& operator++() { ++this->m_id; return *this; }
87 
89  Identifier operator++(int) { Identifier h(*this); ++this->m_id; return h; }
90 
92  Identifier& operator--() { --this->m_id; return *this; }
93 
95  Identifier operator--(int) { Identifier h(*this); --this->m_id; return h; }
96 
98  bool operator<( const Identifier &other ) const { return this->m_id < other.m_id; }
99 
101  bool operator<=( const Identifier &other ) const { return this->m_id <= other.m_id; }
102 
104  bool operator>( const Identifier &other ) const { return this->m_id > other.m_id; }
105 
107  bool operator>=( const Identifier &other ) const { return this->m_id >= other.m_id; }
108 };
109  // end group mi_neuray
111 
116 typedef Identifier_struct<HND_TRIANGLE> Triangle_handle_struct;
120 
125 
130 
135 
140 
145 
150 
155 
160 
165 
170 
175 
176 } // namespace neuraylib
177 
178 #ifdef MI_NEURAYLIB_DEPRECATED_NAMESPACE_MI_TRANSITION
185 using neuraylib::HND_POLY;
186 using neuraylib::HND_SCENE_GRAPH_DECAL_NODE;
187 using neuraylib::HND_SCENE_GRAPH_LIGHT_NODE;
188 using neuraylib::HND_SCENE_GRAPH_MATERIAL;
189 using neuraylib::HND_SCENE_GRAPH_MESH;
190 using neuraylib::HND_SCENE_GRAPH_NODE;
191 using neuraylib::HND_SCENE_GRAPH_OBJECT_NODE;
192 using neuraylib::HND_SCENE_GRAPH_VERSION;
207 #endif // MI_NEURAYLIB_DEPRECATED_NAMESPACE_MI_TRANSITION
208 
209 } // namespace mi
210 
211 #endif // MI_NEURAYLIB_IDENTIFIER_H