API Documentation
Loading...
Searching...
No Matches
TypeInfo.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: TypeInfo
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <type_traits>
34#include <NDEVR/BaseValues.h>
35#include <NDEVR/ObjectInfo.h>
36namespace NDEVR
37{
39 {
40 public:
41 constexpr TypeInfo()
42 : total_size(0)
43 , byte_size(0)
44 , vector_size(0)
45 , is_number(false)
46 , is_unsigned(false)
47 , is_float(false)
48 , is_string(false)
49 , is_buffer(false)
50 , is_color(false)
51 , is_boolean(false)
52 {}
56
64
65 template<class t_type>
66 bool isSame(const t_type& object)
67 {
68 return TypeInfo(object) == *this;
69 }
70 bool operator==(const TypeInfo& type) const
71 {
72 return total_size == type.total_size
73 && byte_size == type.byte_size
74 && vector_size == type.vector_size
75 && is_number == type.is_number
76 && is_unsigned == type.is_unsigned
77 && is_float == type.is_float
78 && is_string == type.is_string
79 && is_buffer == type.is_buffer
80 && is_color == type.is_color
81 && is_boolean == type.is_boolean;
82 }
83 bool operator!=(const TypeInfo& type) const
84 {
85 return total_size != type.total_size
86 || byte_size != type.byte_size
87 || vector_size != type.vector_size
88 || is_number != type.is_number
89 || is_unsigned != type.is_unsigned
90 || is_float != type.is_float
91 || is_string != type.is_string
92 || is_buffer != type.is_buffer
93 || is_color != type.is_color
94 || is_boolean != type.is_boolean;
95 }
96 };
97 static_assert(sizeof(TypeInfo) == 16, "Bad TypeInfo Size");//used in raw ndv file
98 template<class t_type, bool is_buffer = ObjectInfo<t_type>::Buffer>
99 constexpr typename std::enable_if<!ObjectInfo<t_type>::Buffer, TypeInfo>::type GetTypeInfo()
100 {
101 TypeInfo col_type;
102 col_type.byte_size = cast<uint02>(sizeof(t_type) / (ObjectInfo<t_type>::Dimensions + (ObjectInfo<t_type>::Dimensions == 0 ? 1 : 0)));
104 col_type.total_size = cast<uint04>(sizeof(t_type));
105
113 return col_type;
114 }
115 template<class t_type>
116 constexpr typename std::enable_if<ObjectInfo<t_type>::Buffer, TypeInfo>::type GetTypeInfo()
117 {
118 TypeInfo col_type;
119 col_type.byte_size = cast<uint02>(sizeof(decltype(t_type::Type())) / (ObjectInfo<decltype(t_type::Type())>::Dimensions + (ObjectInfo<decltype(t_type::Type())>::Dimensions == 0 ? 1 : 0)));
120 col_type.vector_size = ObjectInfo<decltype(t_type::Type())>::Dimensions;
121 col_type.total_size = cast<uint04>(sizeof(decltype(t_type::Type())));
122
123 col_type.is_number = ObjectInfo<decltype(t_type::Type())>::Number;
124 col_type.is_unsigned = ObjectInfo<decltype(t_type::Type())>::Unsigned;
125 col_type.is_float = ObjectInfo<decltype(t_type::Type())>::Float;
127 col_type.is_buffer = true;
128 col_type.is_color = ObjectInfo<decltype(t_type::Type())>::Color;
129 col_type.is_boolean = ObjectInfo<decltype(t_type::Type())>::Boolean;
130 return col_type;
131 }
132
133}
Definition TypeInfo.h:39
bool operator==(const TypeInfo &type) const
Definition TypeInfo.h:70
bool is_number
Definition TypeInfo.h:57
constexpr TypeInfo()
Definition TypeInfo.h:41
bool operator!=(const TypeInfo &type) const
Definition TypeInfo.h:83
bool is_unsigned
Definition TypeInfo.h:58
bool is_color
Definition TypeInfo.h:62
bool is_buffer
Definition TypeInfo.h:61
uint02 byte_size
Definition TypeInfo.h:54
bool is_string
Definition TypeInfo.h:60
uint02 vector_size
Definition TypeInfo.h:55
bool is_float
Definition TypeInfo.h:59
bool isSame(const t_type &object)
Definition TypeInfo.h:66
uint04 total_size
Definition TypeInfo.h:53
bool is_boolean
Definition TypeInfo.h:63
Definition ACIColor.h:37
constexpr std::enable_if<!ObjectInfo< t_type >::Buffer, TypeInfo >::type GetTypeInfo()
Definition TypeInfo.h:99
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:109
Information about the object.
Definition ObjectInfo.h:56