API Documentation
Loading...
Searching...
No Matches
ObjectInfo.h
Go to the documentation of this file.
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{
38 /**--------------------------------------------------------------------------------------------------
39 \brief A dummy class for easy tracking of inheritance with templated Buffers.
40 **/
42 {};
43 /**--------------------------------------------------------------------------------------------------
44 Struct: ObjectInfo
45
46 \brief Information about the object.
47
48 Author: Tyler Parke
49
50 Date: 2017-11-17
51 **/
52
53 template<typename t_type, bool is_vector = IsVec<t_type>::value, bool is_buffer = std::is_base_of<BufferBase, t_type>::value>
54 struct ObjectInfo;
55
56 /**--------------------------------------------------------------------------------------------------
57 Struct: ObjectInfo<t_type,false>
58
59 \brief Information about the object.
60
61 Author: Tyler Parke
62
63 Date: 2017-11-17
64 **/
65 template<typename t_type>
66 struct ObjectInfo<t_type, false, false>
67 {
68 /** The number of dimensions or zero if scaler type. */
69 static const uint01 Dimensions = 0;
70 /** True if object is a vector. */
71 static const bool Vector = false;
72 /** True if object is a Buffer. */
73 static const bool Buffer = false;
74 /** Useful for buffers. Determines whether the object needs to call an allocator. */
75 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;
76 /** True if the object is a pointer. */
77 static const bool Pointer = std::is_pointer<t_type>::value;
78 /** True if unsigned. */
79 static const bool Unsigned = std::is_unsigned<t_type>::value;
80 /** True if is a floating point number. */
81 static const bool Float = std::is_floating_point<t_type>::value;
82 /** True is an integer. */
83 static const bool Integer = std::is_integral<t_type>::value;
84 /** True is a number. */
85 static const bool Number = std::is_integral<t_type>::value || std::is_floating_point<t_type>::value;
86 /** True if is an enum. */
87 static const bool Enum = std::is_enum<t_type>::value;
88 /** True is a string. */
89 static const bool String = false;
90 /** True is a color. */
91 static const bool Color = false;
92
93 static const bool Boolean = false;
94 /**--------------------------------------------------------------------------------------------------
95 \brief If this object is of type vector, returns this object's sub object. Otherwise returns the object itself
96
97 Author: Tyler Parke
98
99 Date: 2017-11-17
100
101 \returns An ObjectInfo&lt;t_type,false&gt;
102 **/
103
104 static constexpr ObjectInfo<t_type, false> VectorSub() { return ObjectInfo<t_type, false>(); }
105 };
106
107
108 /**--------------------------------------------------------------------------------------------------
109 Struct: ObjectInfo<t_type,true>
110
111 \brief Information about the object.
112
113 Author: Tyler Parke
114
115 Date: 2017-11-17
116 **/
117 template<typename t_type>
118 struct ObjectInfo<t_type, true, false>
119 {
120 static const uint01 Dimensions = t_type::NumberOfDimensions();
121 static const bool Vector = true;
122 static const bool Buffer = false;
123 static const bool Primitive = ObjectInfo<decltype(t_type::Type())>::Primitive;
124 static const bool Pointer = ObjectInfo<decltype(t_type::Type())>::Pointer;
125 static const bool Unsigned = ObjectInfo<decltype(t_type::Type())>::Unsigned;
126 static const bool Float = ObjectInfo<decltype(t_type::Type())>::Float;
127 static const bool Integer = ObjectInfo<decltype(t_type::Type())>::Integer;
128 static const bool Number = ObjectInfo<decltype(t_type::Type())>::Number;
129 static const bool String = ObjectInfo<decltype(t_type::Type())>::String;
130 static const bool Color = ObjectInfo<decltype(t_type::Type())>::Color;
131 static const bool Boolean = ObjectInfo<decltype(t_type::Type())>::Boolean;
132 static constexpr ObjectInfo<decltype(t_type::Type())> VectorSub() { return ObjectInfo<decltype(t_type::Type())>(); }
133 };
134
135 template<typename t_type>
136 struct ObjectInfo<t_type, false, true>
137 {
138 static const uint01 Dimensions = 0;
139 static const bool Vector = false;
140 static const bool Buffer = true;
141 static const bool Primitive = false;
142 static const bool Pointer = ObjectInfo<decltype(t_type::Type())>::Pointer;
143 static const bool Unsigned = ObjectInfo<decltype(t_type::Type())>::Unsigned;
144 static const bool Float = ObjectInfo<decltype(t_type::Type())>::Float;
145 static const bool Integer = ObjectInfo<decltype(t_type::Type())>::Integer;
146 static const bool Number = ObjectInfo<decltype(t_type::Type())>::Number;
147 static const bool String = ObjectInfo<decltype(t_type::Type())>::String;
148 static const bool Color = ObjectInfo<decltype(t_type::Type())>::Color;
149 static const bool Boolean = ObjectInfo<decltype(t_type::Type())>::Boolean;
150 static constexpr ObjectInfo<decltype(t_type::Type())> VectorSub() { return ObjectInfo<decltype(t_type::Type())>(); }
151 };
152
153 template<>
154 struct ObjectInfo<bool, false, false>
155 {
156 static const uint01 Dimensions = 0;
157 static const bool Vector = false;
158 static const bool Buffer = false;
159 static const bool Primitive = true;
160 static const bool Pointer = false;
161 static const bool Unsigned = false;
162 static const bool Float = false;
163 static const bool Integer = false;
164 static const bool Number = false;
165 static const bool Enum = false;
166 static const bool String = false;
167 static const bool Color = false;
168 static const bool Boolean = true;
169 static constexpr ObjectInfo<bool, false, false> VectorSub() { return ObjectInfo<bool, false, false>(); }
170 };
171 template<>
172 struct ObjectInfo<char, false, false>
173 {
174 static const uint01 Dimensions = 0;
175 static const bool Vector = false;
176 static const bool Buffer = false;
177 static const bool Primitive = true;
178 static const bool Pointer = false;
179 static const bool Unsigned = false;
180 static const bool Float = false;
181 static const bool Integer = false;
182 static const bool Number = false;
183 static const bool Enum = false;
184 static const bool String = false;
185 static const bool Color = false;
186 static const bool Boolean = false;
187 static constexpr ObjectInfo<char, false> VectorSub() { return ObjectInfo<char, false>(); }
188 };
189
190 template<class t_first_type, class t_second_type>
191 struct ObjectInfo<std::pair<t_first_type, t_second_type>, false, false>
192 {
193 static const uint01 Dimensions = 0;
194 static const bool Vector = false;
195 static const bool Buffer = false;
196 static const bool Primitive = ObjectInfo<t_first_type>::Primitive && ObjectInfo<t_second_type>::Primitive;
197 static const bool Pointer = false;
198 static const bool Unsigned = false;
199 static const bool Float = false;
200 static const bool Integer = false;
201 static const bool Number = false;
202 static const bool Enum = false;
203 static const bool String = false;
204 static const bool Color = false;
205 static const bool Boolean = false;
206 static constexpr ObjectInfo<std::pair<t_first_type, t_second_type>, false> VectorSub() { return ObjectInfo<std::pair<t_first_type, t_second_type>, false>(); }
207 };
208}
A dummy class for easy tracking of inheritance with templated Buffers.
Definition ObjectInfo.h:42
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
The core Color class in the NDEVR API. Colors can be defined in several ways. The ACIColor is compact...
Definition Color.h:41
Provides shared ownership of a dynamically allocated object.
Definition Pointer.hpp:71
The core String class for the NDEVR API.
Definition String.h:69
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
Definition ACIColor.h:37
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
Definition File.h:211
Information about the object.
Definition ObjectInfo.h:54