NVIDIA Iray API
 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, 2014 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 
13 namespace mi {
14 
19 enum Identifier_name {
27  HND_SCENE_GRAPH_VERSION,
28  HND_SCENE_GRAPH_NODE,
29  HND_SCENE_GRAPH_OBJECT_NODE,
30  HND_SCENE_GRAPH_LIGHT_NODE,
31  HND_SCENE_GRAPH_MESH,
32  HND_SCENE_GRAPH_MATERIAL,
33  HND_SCENE_GRAPH_DECAL_NODE
34 };
35 
36 template <typename T> struct Invalid_identifier { };
37 template <> struct Invalid_identifier<Uint32>
38 {
39  static inline Uint32 value( ) { return 0xffffffff; }
40 };
41 
42 template <> struct Invalid_identifier<Uint64>
43 {
44  static inline Uint64 value( ) { return 0xffffffffffffffffull; }
45 };
46 
50 template <Identifier_name name, typename Int_type = Uint32>
52 {
54  Int_type m_id;
55 };
56 
60 template <Identifier_name name, typename Int_type = Uint32>
61 class Identifier : public Identifier_struct<name, Int_type>
62 {
63 public:
65  Identifier( ) { this->m_id = Invalid_identifier<Int_type>::value(); }
66 
68  explicit Identifier( Int_type h ) { this->m_id = h; }
69 
72 
74  operator Int_type() const { return this->m_id; }
75 
77  Int_type operator*() const { return this->m_id; }
78 
80  bool is_valid( ) const { return this->m_id != Invalid_identifier<Int_type>::value(); }
81 
83  Identifier& operator++() { ++this->m_id; return *this; }
84 
86  Identifier operator++(int) { Identifier h(*this); ++this->m_id; return h; }
87 
89  Identifier& operator--() { --this->m_id; return *this; }
90 
92  Identifier operator--(int) { Identifier h(*this); --this->m_id; return h; }
93 
95  bool operator<( const Identifier &other ) const { return this->m_id < other.m_id; }
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 };
106 
111 
116 
121 
126 
131 
136 
141 
146 
151 
156 
161 
166  // end group mi_neuray
168 
169 } // namespace mi
170 
171 #endif // MI_NEURAYLIB_IDENTIFIER_H