NDEVR
API Documentation
ObjectInfo.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Base
28File: ObjectInfo
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/Vector.h>
34#include <type_traits>
35#include <utility>
36namespace NDEVR
37{
42 {};
43
52
53 template<typename t_type, bool is_vector = IsVec<t_type>::value, bool is_buffer = std::is_base_of<BufferBase, t_type>::value>
55 {};
56
66 template<typename t_type>
67 struct ObjectInfo<t_type, false, false>
68 {
70 static const uint01 Dimensions = 0;
72 static const bool Vector = false;
74 static const bool Buffer = false;
76 static const bool Primitive = std::is_integral<t_type>::value || std::is_floating_point<t_type>::value || std::is_enum<t_type>::value || std::is_pointer<t_type>::value;
78 static const bool Pointer = std::is_pointer<t_type>::value;
80 static const bool Unsigned = std::is_unsigned<t_type>::value;
82 static const bool Float = std::is_floating_point<t_type>::value;
84 static const bool Integer = std::is_integral<t_type>::value;
86 static const bool Number = std::is_integral<t_type>::value || std::is_floating_point<t_type>::value;
88 static const bool Enum = std::is_enum<t_type>::value;
90 static const bool String = false;
92 static const bool Color = false;
93
94 static const bool Boolean = false;
104
106 };
107
108
118 template<typename t_type>
119 struct ObjectInfo<t_type, true, false>
120 {
121 static const uint01 Dimensions = t_type::NumberOfDimensions();
122 static const bool Vector = true;
123 static const bool Buffer = false;
124 static const bool Primitive = ObjectInfo<decltype(t_type::Type())>::Primitive;
125 static const bool Pointer = ObjectInfo<decltype(t_type::Type())>::Pointer;
126 static const bool Unsigned = ObjectInfo<decltype(t_type::Type())>::Unsigned;
127 static const bool Float = ObjectInfo<decltype(t_type::Type())>::Float;
128 static const bool Integer = ObjectInfo<decltype(t_type::Type())>::Integer;
129 static const bool Number = ObjectInfo<decltype(t_type::Type())>::Number;
130 static const bool String = ObjectInfo<decltype(t_type::Type())>::String;
131 static const bool Color = ObjectInfo<decltype(t_type::Type())>::Color;
132 static const bool Boolean = ObjectInfo<decltype(t_type::Type())>::Boolean;
137 static constexpr ObjectInfo<decltype(t_type::Type())> VectorSub() { return ObjectInfo<decltype(t_type::Type())>(); }
138 };
139
143 template<typename t_type>
144 struct ObjectInfo<t_type, false, true>
145 {
146 static const uint01 Dimensions = 0;
147 static const bool Vector = false;
148 static const bool Buffer = true;
149 static const bool Primitive = false;
150 static const bool Pointer = ObjectInfo<decltype(t_type::Type())>::Pointer;
151 static const bool Unsigned = ObjectInfo<decltype(t_type::Type())>::Unsigned;
152 static const bool Float = ObjectInfo<decltype(t_type::Type())>::Float;
153 static const bool Integer = ObjectInfo<decltype(t_type::Type())>::Integer;
154 static const bool Number = ObjectInfo<decltype(t_type::Type())>::Number;
155 static const bool String = ObjectInfo<decltype(t_type::Type())>::String;
156 static const bool Color = ObjectInfo<decltype(t_type::Type())>::Color;
157 static const bool Boolean = ObjectInfo<decltype(t_type::Type())>::Boolean;
162 static constexpr ObjectInfo<decltype(t_type::Type())> VectorSub() { return ObjectInfo<decltype(t_type::Type())>(); }
163 };
164
168 template<>
169 struct ObjectInfo<bool, false, false>
170 {
171 static const uint01 Dimensions = 0;
172 static const bool Vector = false;
173 static const bool Buffer = false;
174 static const bool Primitive = true;
175 static const bool Pointer = false;
176 static const bool Unsigned = false;
177 static const bool Float = false;
178 static const bool Integer = false;
179 static const bool Number = false;
180 static const bool Enum = false;
181 static const bool String = false;
182 static const bool Color = false;
183 static const bool Boolean = true;
189 };
190
193 template<>
194 struct ObjectInfo<char, false, false>
195 {
196 static const uint01 Dimensions = 0;
197 static const bool Vector = false;
198 static const bool Buffer = false;
199 static const bool Primitive = true;
200 static const bool Pointer = false;
201 static const bool Unsigned = false;
202 static const bool Float = false;
203 static const bool Integer = false;
204 static const bool Number = false;
205 static const bool Enum = false;
206 static const bool String = false;
207 static const bool Color = false;
208 static const bool Boolean = false;
214 };
215
219 template<class t_first_type, class t_second_type>
220 struct ObjectInfo<std::pair<t_first_type, t_second_type>, false, false>
221 {
222 static const uint01 Dimensions = 0;
223 static const bool Vector = false;
224 static const bool Buffer = false;
225 static const bool Primitive = ObjectInfo<t_first_type>::Primitive && ObjectInfo<t_second_type>::Primitive;
226 static const bool Pointer = false;
227 static const bool Unsigned = false;
228 static const bool Float = false;
229 static const bool Integer = false;
230 static const bool Number = false;
231 static const bool Enum = false;
232 static const bool String = false;
233 static const bool Color = false;
234 static const bool Boolean = false;
239 static constexpr ObjectInfo<std::pair<t_first_type, t_second_type>, false> VectorSub() { return ObjectInfo<std::pair<t_first_type, t_second_type>, false>(); }
240 };
241}
A dummy class for easy tracking of inheritance with templated Buffers.
Definition ObjectInfo.h:42
The primary namespace for the NDEVR SDK.
@ Color
Per-vertex RGBA color.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
STL namespace.
static const bool Vector
False because bool is not a vector.
Definition ObjectInfo.h:172
static const bool Unsigned
False because bool is not considered unsigned.
Definition ObjectInfo.h:176
static const bool Enum
False because bool is not an enum.
Definition ObjectInfo.h:180
static const bool Integer
False because bool is not an integer.
Definition ObjectInfo.h:178
static const bool Color
False because bool is not a color.
Definition ObjectInfo.h:182
static const bool String
False because bool is not a string.
Definition ObjectInfo.h:181
static const bool Float
False because bool is not floating point.
Definition ObjectInfo.h:177
static const bool Primitive
True because bool is a primitive type.
Definition ObjectInfo.h:174
static const bool Pointer
False because bool is not a pointer.
Definition ObjectInfo.h:175
static const uint01 Dimensions
Always zero for scalar types.
Definition ObjectInfo.h:171
static const bool Buffer
False because bool is not a buffer.
Definition ObjectInfo.h:173
static constexpr ObjectInfo< bool, false, false > VectorSub()
Returns the ObjectInfo for this type since bool has no sub-type.
Definition ObjectInfo.h:188
static const bool Number
False because bool is not a number.
Definition ObjectInfo.h:179
static const bool Boolean
True because this is the bool specialization.
Definition ObjectInfo.h:183
static const bool Unsigned
False because char is not considered unsigned.
Definition ObjectInfo.h:201
static const bool Primitive
True because char is a primitive type.
Definition ObjectInfo.h:199
static const bool Color
False because char is not a color.
Definition ObjectInfo.h:207
static const bool Enum
False because char is not an enum.
Definition ObjectInfo.h:205
static const uint01 Dimensions
Always zero for scalar types.
Definition ObjectInfo.h:196
static const bool String
False because char is not a string.
Definition ObjectInfo.h:206
static const bool Buffer
False because char is not a buffer.
Definition ObjectInfo.h:198
static constexpr ObjectInfo< char, false > VectorSub()
Returns the ObjectInfo for this type since char has no sub-type.
Definition ObjectInfo.h:213
static const bool Boolean
False because char is not a boolean.
Definition ObjectInfo.h:208
static const bool Vector
False because char is not a vector.
Definition ObjectInfo.h:197
static const bool Integer
False because char is treated as a character, not an integer.
Definition ObjectInfo.h:203
static const bool Number
False because char is treated as a character, not a number.
Definition ObjectInfo.h:204
static const bool Pointer
False because char is not a pointer.
Definition ObjectInfo.h:200
static const bool Float
False because char is not floating point.
Definition ObjectInfo.h:202
static const bool Unsigned
True if unsigned.
Definition ObjectInfo.h:80
static const bool Enum
True if is an enum.
Definition ObjectInfo.h:88
static const bool Vector
True if object is a vector.
Definition ObjectInfo.h:72
static const bool Integer
True is an integer.
Definition ObjectInfo.h:84
static const bool Pointer
True if the object is a pointer.
Definition ObjectInfo.h:78
static const bool Primitive
Useful for buffers.
Definition ObjectInfo.h:76
static const uint01 Dimensions
The number of dimensions or zero if scaler type.
Definition ObjectInfo.h:70
static const bool Float
True if is a floating point number.
Definition ObjectInfo.h:82
static constexpr ObjectInfo< t_type, false > VectorSub()
If this object is of type vector, returns this object's sub object.
Definition ObjectInfo.h:105
static const bool Boolean
True if is a boolean type.
Definition ObjectInfo.h:94
static const bool Buffer
True if object is a Buffer.
Definition ObjectInfo.h:74
static const bool Number
True is a number.
Definition ObjectInfo.h:86
static const bool String
True is a string.
Definition ObjectInfo.h:90
static const bool Color
True is a color.
Definition ObjectInfo.h:92
static const bool Boolean
Whether the buffer's element type is a boolean.
Definition ObjectInfo.h:157
static const uint01 Dimensions
Always zero for buffer types.
Definition ObjectInfo.h:146
static const bool Float
Whether the buffer's element type is floating point.
Definition ObjectInfo.h:152
static const bool Primitive
Always false for buffers since they require allocation.
Definition ObjectInfo.h:149
static const bool Unsigned
Whether the buffer's element type is unsigned.
Definition ObjectInfo.h:151
static const bool Color
Whether the buffer's element type is a color.
Definition ObjectInfo.h:156
static const bool Buffer
True because this specialization handles buffer types.
Definition ObjectInfo.h:148
static const bool Vector
False because this is not a vector type.
Definition ObjectInfo.h:147
static constexpr ObjectInfo< decltype(t_type::Type())> VectorSub()
Returns the ObjectInfo for the buffer's element sub-type.
Definition ObjectInfo.h:162
static const bool Pointer
Whether the buffer's element type is a pointer.
Definition ObjectInfo.h:150
static const bool Number
Whether the buffer's element type is numeric.
Definition ObjectInfo.h:154
static const bool String
Whether the buffer's element type is a string.
Definition ObjectInfo.h:155
static const bool Integer
Whether the buffer's element type is an integer.
Definition ObjectInfo.h:153
static const bool Unsigned
Whether the vector's element type is unsigned.
Definition ObjectInfo.h:126
static const bool Float
Whether the vector's element type is floating point.
Definition ObjectInfo.h:127
static const bool Color
Whether the vector's element type is a color.
Definition ObjectInfo.h:131
static constexpr ObjectInfo< decltype(t_type::Type())> VectorSub()
Returns the ObjectInfo for the vector's element sub-type.
Definition ObjectInfo.h:137
static const bool Boolean
Whether the vector's element type is a boolean.
Definition ObjectInfo.h:132
static const bool Vector
True because this specialization handles vector types.
Definition ObjectInfo.h:122
static const bool Number
Whether the vector's element type is numeric.
Definition ObjectInfo.h:129
static const uint01 Dimensions
The number of dimensions of the vector type.
Definition ObjectInfo.h:121
static const bool Primitive
Whether the vector's element type is primitive.
Definition ObjectInfo.h:124
static const bool Pointer
Whether the vector's element type is a pointer.
Definition ObjectInfo.h:125
static const bool Buffer
False because this is not a buffer type.
Definition ObjectInfo.h:123
static const bool String
Whether the vector's element type is a string.
Definition ObjectInfo.h:130
static const bool Integer
Whether the vector's element type is an integer.
Definition ObjectInfo.h:128
Information about the object.
Definition ObjectInfo.h:55