API Documentation
Loading...
Searching...
No Matches
TableType.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: Database
28File: TableType
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/Table.h>
35#include <NDEVR/TableVectorType.h>
36namespace NDEVR
37{
38 /**--------------------------------------------------------------------------------------------------
39 \brief A Table that can create columns of specific types
40 *-----------------------------------------------------------------------------------------------**/
42 {
43 public:
45 : Table()
46 {}
47 explicit TableType(const String& name)
48 : Table(name)
49 {}
50 template<uint01 t_dims, class t_type>
52 {
53 TableVectorType<t_dims, t_type>* value = dynamic_cast<TableVectorType<t_dims, t_type>*>(m_data_channels[channel]);
54 lib_assert(value != nullptr, "Channel is of improper type");
55 return (*value);
56 }
57 template<class t_type>
58 uint04 createScalerChannel(const String& name, bool is_floating = false)
59 {
60 if (!hasColumn(name))
61 return addChannel(new TableVectorType<1, t_type>(name), is_floating);
62 else
63 return indexOf(name);
64 }
65
66 /*template<>
67 uint04 createScalerChannel<UUID>(const String& name, bool is_floating)
68 {
69 if (!hasColumn(name))
70 return addChannel(new TableUUIDType(name), is_floating);
71 else
72 return indexOf(name);
73 }*/
74
75 template<class t_type>
76 uint04 createColorChannel(const String& name, bool is_floating = false)
77 {
78 if (!hasColumn(name))
79 return addChannel(new TableColumnColorType(name), is_floating);
80 else
81 return indexOf(name);
82 }
83
84 template<uint01 t_dims, class t_type>
85 uint04 createVectorChannel(const String& name, bool is_floating = false)
86 {
87 if (!hasColumn(name))
88 return addChannel(new TableVectorType<t_dims, t_type>(name), is_floating);
89 else
90 return indexOf(name);
91 }
92
93 template<uint01 t_dims, class t_type>
94 uint04 createBoundingBoxChannel(const String& name, bool is_floating = false)
95 {
96 if (!hasColumn(name))
97 return addChannel(new TableVectorType<2 * t_dims, t_type>(name), is_floating);
98 else
99 return indexOf(name);
100 }
101
102 template<class t_type, uint01 t_cols, uint01 t_rows>
103 uint04 createMatrixChannel(const String& name, bool is_floating = false)
104 {
105 if (!hasColumn(name))
106 return addChannel(new TableMatrixType<t_type, t_cols, t_rows>(name), is_floating);
107 else
108 return indexOf(name);
109 }
110 uint04 createStringChannel(const String& name, bool is_floating = false);
111 template<class t_type>
112 uint04 createBufferChannel(const String& name, bool is_floating = false)
113 {
114 if (!hasColumn(name))
115 return addChannel(new TableColumnTypeBuffer<t_type>(name), is_floating);
116 else
117 return indexOf(name);
118 }
119
120 template<uint01 t_dims>
121 TableColumn* createScalerChannel(const String& name, const TypeInfo& type_info)
122 {
123 if (type_info.is_number)
124 {
125 if (type_info.is_float)
126 {
127 if (type_info.byte_size == 4)
128 return new TableVectorType<t_dims, fltp04>(name);
129 else
130 return new TableVectorType<t_dims, fltp08>(name);
131 }
132 else if (type_info.is_unsigned)
133 {
134 switch (type_info.byte_size)
135 {
136 case 1: return new TableVectorType<t_dims, uint01>(name);
137 case 2: return new TableVectorType<t_dims, uint02>(name);
138 case 4: return new TableVectorType<t_dims, uint04>(name);
139 case 8: return new TableVectorType<t_dims, uint08>(name);
140 }
141 }
142 else
143 {
144 switch (type_info.byte_size)
145 {
146 case 1: return new TableVectorType<t_dims, sint01>(name);
147 case 2: return new TableVectorType<t_dims, sint02>(name);
148 case 4: return new TableVectorType<t_dims, sint04>(name);
149 case 8: return new TableVectorType<t_dims, sint08>(name);
150 }
151 }
152 }
153 else if (type_info.is_color)
154 {
155 return new TableColumnColorType(name);
156 }
157 else if (type_info.is_boolean)
158 {
159 switch (type_info.byte_size)
160 {
161 case 1: return new TableVectorType<1, bool>(name);
162 }
163 }
164 lib_assert(false, "Unknown Column Type");
165 return nullptr;
166 }
167 template<uint01 t_cols, uint01 t_rows>
168 TableColumn* createMatrixChannel(const String& name, const TypeInfo& type_info, bool is_floating = false)
169 {
170 UNUSED(is_floating);
171 if (type_info.is_number)
172 {
173 if (type_info.is_float)
174 {
175 if (type_info.byte_size == 4)
177 else
179 }
180 else if (type_info.is_unsigned)
181 {
182 switch (type_info.byte_size)
183 {
184 case 1: return new TableMatrixType<uint01, t_cols, t_rows>(name);
185 case 2: return new TableMatrixType<uint02, t_cols, t_rows>(name);
186 case 4: return new TableMatrixType<uint04, t_cols, t_rows>(name);
187 case 8: return new TableMatrixType<uint08, t_cols, t_rows>(name);
188 }
189 }
190 else
191 {
192 switch (type_info.byte_size)
193 {
194 case 1: return new TableMatrixType<sint01, t_cols, t_rows>(name);
195 case 2: return new TableMatrixType<sint02, t_cols, t_rows>(name);
196 case 4: return new TableMatrixType<sint04, t_cols, t_rows>(name);
197 case 8: return new TableMatrixType<sint08, t_cols, t_rows>(name);
198 }
199 }
200 }
201 lib_assert(false, "Unknown Column Type");
202 return nullptr;
203 }
204 uint04 createChannel(const String& name, const TypeInfo& type_info, bool is_floating = false) override;
205 TableColumn* createBufferChannel(const String& name, const TypeInfo& type_info, bool is_floating = false);
206
207 };
208}
#define UNUSED(expr)
Definition BaseValues.hpp:428
#define NDEVR_DATABASE_API
Definition DLLInfo.h:71
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
The core String class for the software.
Definition String.h:47
A TableColumnBuffer of Colors.
Definition TableColumnType.h:1082
Definition TableColumn.h:68
A TableColumnBuffer of buffers. Meaning each row has some potentially unique N-number of columns.
Definition TableColumnType.h:733
Provides access to a set of named columns all with the same number of rows. Columns can also.
Definition Table.h:46
A TableColumnBuffer column of Matrices.
Definition TableColumnType.h:455
A Table that can create columns of specific types.
Definition TableType.h:42
TableType()
Definition TableType.h:44
TableColumn * createMatrixChannel(const String &name, const TypeInfo &type_info, bool is_floating=false)
Definition TableType.h:168
uint04 createColorChannel(const String &name, bool is_floating=false)
Definition TableType.h:76
uint04 createMatrixChannel(const String &name, bool is_floating=false)
Definition TableType.h:103
uint04 createBoundingBoxChannel(const String &name, bool is_floating=false)
Definition TableType.h:94
const TableVectorType< t_dims, t_type > & getType(uint04 channel) const
Definition TableType.h:51
uint04 createVectorChannel(const String &name, bool is_floating=false)
Definition TableType.h:85
uint04 createBufferChannel(const String &name, bool is_floating=false)
Definition TableType.h:112
TableColumn * createScalerChannel(const String &name, const TypeInfo &type_info)
Definition TableType.h:121
uint04 createScalerChannel(const String &name, bool is_floating=false)
Definition TableType.h:58
TableType(const String &name)
Definition TableType.h:47
A TableColumnBuffer that also has some number of defined rows stored in a Vector object.
Definition TableColumnType.h:259
Stores information about a type, relevant for certain templated functions.
Definition TypeInfo.h:43
bool is_number
Definition TypeInfo.h:61
bool is_unsigned
Definition TypeInfo.h:62
bool is_color
Definition TypeInfo.h:66
uint02 byte_size
Definition TypeInfo.h:58
bool is_float
Definition TypeInfo.h:63
bool is_boolean
Definition TypeInfo.h:67
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:115