NDEVR
API Documentation
TableColumn.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: Database
28File: TableColumn
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/String.h>
35#include <NDEVR/Time.h>
36#include <NDEVR/File.h>
37#include <NDEVR/UUID.h>
38#include <NDEVR/Vector.h>
39#include <NDEVR/TranslatedString.h>
40#include <NDEVR/TypeInfo.h>
41#include <NDEVR/RGBColor.h>
42#include <NDEVR/BitFlag.h>
43#include <NDEVR/Compressor.h>
44namespace NDEVR
45{
46 class RGBColor;
47 class Table;
79
85 class NDEVR_DATABASE_API TableColumn
86 {
87 public:
91
93 virtual ~TableColumn();
94
97 const String& label() const;
98
102
105 virtual void setSize(uint04 size) = 0;
106
111 virtual void setRowSize(uint04, uint04) { lib_assert(false, "Must be of array type to use"); };
112
117 virtual uint04 getRowSize(uint04) const { lib_assert(false, "Must be of array type to use"); return 0; };
118
121 virtual TypeInfo type() const = 0;
122
125 virtual void removeRow(uint04 index) = 0;
126
130 virtual void removeRows(uint04 index, uint04 size) = 0;
131
134 virtual void removeRows(const Buffer<uint04>& sorted_remove_indices) = 0;
135
138 virtual void insert(uint04 index) = 0;
139
144 template<class t_class>
145 typename std::enable_if<!ObjectInfo<t_class>::Enum>::type set(uint04 index, const t_class& value);
146
150 template<std::size_t N>
151 void set(uint04 index, const char(&string)[N])
152 {
153 set(index, StringView(string));
154 }
155
159 void set(uint04 index, const char* string)
160 {
161 set(index, StringView(string));
162 }
163
167 void set(uint04 index, const StringAllocatingView& string)
168 {
169 set(index, StringView(string));
170 }
171
175 void set(uint04 index, const BitReference& val)
176 {
177 bool bval = val;
178 set(index, bval);
179 }
180
184 template<class t_pointer_type>
185 void set(uint04 index, t_pointer_type* pointer)
186 {
187 set(index, (uint08)(pointer));
188 }
189
193 template<class t_pointer_type>
194 void set(uint04 index, const t_pointer_type* pointer)
195 {
196 set(index, (uint08)(pointer));
197 }
198
201 void set(uint04 index, const std::nullptr_t&)
202 {
203 set(index, 0U);
204 }
205
209 virtual void swap(uint04 a, uint04 b) = 0;
210
214 virtual void set(uint04 index, bool value) = 0;
215
219 virtual void set(uint04 index, uint01 value) = 0;
220
224 virtual void set(uint04 index, uint02 value) = 0;
225
229 virtual void set(uint04 index, uint04 value) = 0;
230
234 virtual void set(uint04 index, uint08 value) = 0;
235
239 virtual void set(uint04 index, sint01 value) = 0;
240
244 virtual void set(uint04 index, sint02 value) = 0;
245
249 virtual void set(uint04 index, sint04 value) = 0;
250
254 virtual void set(uint04 index, sint08 value) = 0;
255
259 virtual void set(uint04 index, fltp04 value) = 0;
260
264 virtual void set(uint04 index, fltp08 value) = 0;
265
269 virtual void set(uint04 index, const StringView& value) = 0;
270
274 virtual void set(uint04 index, RGBColor value) = 0;
275
280 virtual void set(uint04 index, uint04 vector_pos, bool value) = 0;
281
286 virtual void set(uint04 index, uint04 vector_pos, uint01 value) = 0;
287
292 virtual void set(uint04 index, uint04 vector_pos, uint02 value) = 0;
293
298 virtual void set(uint04 index, uint04 vector_pos, uint04 value) = 0;
299
304 virtual void set(uint04 index, uint04 vector_pos, uint08 value) = 0;
305
310 virtual void set(uint04 index, uint04 vector_pos, sint01 value) = 0;
311
316 virtual void set(uint04 index, uint04 vector_pos, sint02 value) = 0;
317
322 virtual void set(uint04 index, uint04 vector_pos, sint04 value) = 0;
323
328 virtual void set(uint04 index, uint04 vector_pos, sint08 value) = 0;
329
334 virtual void set(uint04 index, uint04 vector_pos, fltp04 value) = 0;
335
340 virtual void set(uint04 index, uint04 vector_pos, fltp08 value) = 0;
341
346 virtual void set(uint04 index, uint04 vector_pos, const StringView& value) = 0;
347
351 virtual void set(uint04 index, const Matrix<fltp08>& transform);
352
356 virtual void set(uint04 index, const Matrix<fltp04>& transform);
357
361 virtual void set(uint04 index, const Bounds<3, fltp08>& bounds);
362
366 virtual void set(uint04 index, const Bounds<3, fltp04>& bounds);
367
370 virtual void compress(BinaryCompressionObject& object) = 0;
371
374 virtual void resetRow(uint04) {}
375
379 virtual void mapToFile(BinaryFileTableInfo&, int) {};
380
385
389
393
397 virtual void set(uint04 index, const UUID& value);
398
402 void set(uint04 index, const Time& time);
403
407 void set(uint04 index, const Vector<32, bool>& value);
408
412 void set(uint04 index, const TranslatedString& value);
413
417 void set(uint04 index, const File& value);
418
422 void set(uint04 index, const String& value);
423
428 template<uint01 t_dims, class t_type>
429 void set(uint04 index, const Triangle<t_dims, t_type>& value)
430 {
431 lib_assert(type().vector_size == t_dims * 3, "Unexpected vector size write to column");
432 for (uint01 i = 0; i < 3; i++)
433 for (uint01 n = 0; n < t_dims; n++)
434 set(index, 3 * i + n, value[i][n]);
435 }
436
437
442 template<uint01 t_dims, class t_type>
443 void set(uint04 index, const Bounds<t_dims, t_type>& value)
444 {
445 lib_assert(type().vector_size == t_dims * 2, "Unexpected vector size write to column");
446 for (uint01 i = 0; i < 2; i++)
447 for (uint01 n = 0; n < t_dims; n++)
448 set(index, t_dims * i + n, value[i][n]);
449 }
450
455 template<class t_type, uint01 t_col, uint01 t_row>
456 void set(uint04 index, const Matrix<t_type, t_col, t_row>& matrix)
457 {
458 lib_assert(type().vector_size == t_col * t_row, "Unexpected vector size write to column");
459 for (uint01 col = 0; col < t_col; col++)
460 for (uint01 row = 0; row < t_row; row++)
461 set(index, col * t_row + row, matrix[col][row]);
462 }
463
468 template<class t_class>
469 typename std::enable_if<IsVec<t_class>::value>::type set(uint04 index, const t_class& value)
470 {
471 if (t_class::NumberOfDimensions() == 1)
472 set(index, value[0]);
473 else
474 setVector(index, value);
475 }
476
481 template<class t_class>
482 typename std::enable_if<ObjectInfo<t_class>::Enum>::type set(uint04 index, const t_class& value)
483 {
484 lib_assert(type().vector_size == 0, "Unexpected vector size write to column");
485 set(index, cast<uint04>(value));
486 }
487
491 inline void set(uint04 index, const BitFlag& bitflag)
492 {
493 set(index, bitflag.bits());
494 }
495 /*template<class t_class>
496 typename std::enable_if<!ObjectInfo<t_class>::Enum && !IsVec<t_class>::value>::type set(uint04 index, const t_class& value)
497 {
498 lib_assert(type().vector_size == 0, "Unexpected vector size write to column");
499 set(index, String(value));
500 }*/
501
507 template<class t_type>
508 void set(t_type* values, uint04 start_index, uint04 size)
509 {
510 if (GetTypeInfo<t_type>() == type())
511 {
512 memcpy(((t_type*)begin()) + start_index, values, size * sizeof(t_type));
513 }
514 else for (uint04 i = 0; i < size; i++)
515 {
516 set(i + start_index, values[i]);
517 }
518 }
519
523 template<uint01 t_dims, class t_type>
524 void setVector(uint04 index, const Vector<t_dims, t_type>& value)
525 {
526 const uint01 dim_size = getMin(cast<uint01>(type().vector_size), t_dims);
527 for (uint01 i = 0; i < dim_size; i++)
528 set(index, i, value[i]);
529 }
530
535 virtual bool isSame(uint04 index, const StringView& value) const = 0;
536
542 virtual bool contains(uint04 index, const StringView& value, bool ignore_case) const = 0;
543
549 virtual bool beginsWith(uint04 index, const StringView& value, bool ignore_case) const = 0;
550
554 template<class t_class>
555 void get(uint04 index, Vector<1, t_class>& vector) const
556 {
557 get(index, vector[0]);
558 }
559
563 void get(uint04 index, BitFlag& bitflag) const
564 {
565 uint01 value;
566 get(index, value);
567 bitflag = BitFlag(value);
568 }
569
574 template<class t_class>
575 typename std::enable_if<std::is_pointer<t_class>::value>::type get(uint04 index, t_class& vector) const
576 {
577 uint08 value;
578 get(index, value);
579 vector = (t_class)value;
580 }
581
586 template<class t_class>
587 typename std::enable_if<IsVec<t_class>::value && t_class::NumberOfDimensions() != 1>::type get(uint04 index, t_class& vector) const
588 {
589 getVector(index, vector);
590 }
591
596 template<class t_class>
597 typename std::enable_if<ObjectInfo<t_class>::Enum>::type get(uint04 index, t_class& enum_value) const
598 {
599 uint04 value;
600 get(index, value);
601 enum_value = cast<t_class>(value);
602 }
603
604
608 template<class t_type>
609 inline uint04 getIndexOf(const t_type& object) const
610 {
611 for (uint04 i = 0; i < size(); i++)
612 {
613 if (object == get<t_type>(i))
614 return i;
615 }
616 return Constant<uint04>::Invalid;
617 }
618
621 void setCompressionMode(CompressionMode compression_mode)
622 {
623 if (m_compression_mode != compression_mode)
624 m_compression_mode = compression_mode;
625 }
626
631 virtual void get(uint04 index, uint04 vector_pos, bool& value) const = 0;
632
637 virtual void get(uint04 index, uint04 vector_pos, uint01& value) const = 0;
638
643 virtual void get(uint04 index, uint04 vector_pos, uint02& value) const = 0;
644
649 virtual void get(uint04 index, uint04 vector_pos, uint04& value) const = 0;
650
655 virtual void get(uint04 index, uint04 vector_pos, uint08& value) const = 0;
656
661 virtual void get(uint04 index, uint04 vector_pos, sint01& value) const = 0;
662
667 virtual void get(uint04 index, uint04 vector_pos, sint02& value) const = 0;
668
673 virtual void get(uint04 index, uint04 vector_pos, sint04& value) const = 0;
674
679 virtual void get(uint04 index, uint04 vector_pos, sint08& value) const = 0;
680
685 virtual void get(uint04 index, uint04 vector_pos, fltp04& value) const = 0;
686
691 virtual void get(uint04 index, uint04 vector_pos, fltp08& value) const = 0;
692
697 virtual void get(uint04 index, uint04 vector_pos, StringAllocatingView& value) const = 0;
698
702 virtual void get(uint04 index, bool& value) const = 0;
703
707 virtual void get(uint04 index, uint01& value) const = 0;
708
712 virtual void get(uint04 index, uint02& value) const = 0;
713
717 virtual void get(uint04 index, uint04& value) const = 0;
718
722 virtual void get(uint04 index, uint08& value) const = 0;
723
727 virtual void get(uint04 index, sint01& value) const = 0;
728
732 virtual void get(uint04 index, sint02& value) const = 0;
733
737 virtual void get(uint04 index, sint04& value) const = 0;
738
742 virtual void get(uint04 index, sint08& value) const = 0;
743
747 virtual void get(uint04 index, fltp04& value) const = 0;
748
752 virtual void get(uint04 index, fltp08& value) const = 0;
753
757 virtual void get(uint04 index, StringAllocatingView& value) const = 0;
758
762 virtual void get(uint04 index, StringView& value) const = 0;
763
767 virtual void get(uint04 index, RGBColor& value) const = 0;
768
772 virtual void get(uint04 index, Matrix<fltp08>& transform) const;
773
777 virtual void get(uint04 index, Matrix<fltp04>& transform) const;
778
782 virtual void get(uint04 index, Bounds<3, fltp08>& bounds) const;
783
787 virtual void get(uint04 index, Bounds<3, fltp04>& bounds) const;
788
792 virtual void getVector(uint04 index, Vector<3, fltp04>& vector) const;
793
797 virtual void getVector(uint04 index, Vector<3, fltp08>& vector) const;
798
802 virtual void getVector(uint04 index, Vector<3, uint04>& vector) const;
803
807 virtual void getVector(uint04 index, Vector<2, uint04>& vector) const;
808
812 virtual void getVector(uint04 index, Vector<1, uint04>& vector) const;
813
818 template<class t_type, uint01 t_col, uint01 t_row>
819 void get(uint04 index, Matrix<t_type, t_col, t_row>& matrix) const
820 {
821 for (uint01 col = 0; col < t_col; col++)
822 for (uint01 row = 0; row < t_row; row++)
823 get(index, col * t_row + row, matrix[col][row]);
824 }
825
829 void get(uint04 index, File& file) const
830 {
832 get(index, value);
833 file = value;
834 }
835
839 virtual void get(uint04 index, UUID& vector) const
840 {
841 for (uint01 i = 0; i < 16; i++)
842 get(index, i, vector[i]);
843 }
844
848 void get(uint04 index, Time& time) const
849 {
850 uint08 value;
851 get(index, value);
852 time = Time(value);
853 }
854
857 void get(uint04 index, const String& value) const = delete;
858
862 void get(uint04 index, TranslatedString& string) const
863 {
865 get(index, value);
866 string = TranslatedString(value);
867 }
868
873 void get(uint04 index, Vector<32, bool>& value) const
874 {
875 uint04 int_value;
876 get(index, int_value);
877 value = rcast<Vector<32, bool>>(int_value);
878 //memcpy(&value, &int_value, sizeof(int_value));
879 }
880
885 template<uint01 t_dims, class t_type>
886 void get(uint04 index, Bounds<t_dims, t_type>& bounds) const
887 {
888 for (uint01 i = 0; i < 2; i++)
889 for (uint01 n = 0; n < t_dims; n++)
890 get(index, t_dims * i + n, bounds[i][n]);
891 }
892
899 template<uint01 t_dims, class t_type>
900 void get(uint04 index, Triangle<t_dims, t_type>& tri) const
901 {
902 for (uint01 i = 0; i < 3; i++)
903 for (uint01 n = 0; n < t_dims; n++)
904 get(index, 3 * i + n, tri[i][n]);
905 }
906
910 template<class t_class>
911 t_class get(uint04 index) const
912 {
913 t_class value;
914 get(index, value);
915 return value;
916 }
917
923 template<class t_class>
924 t_class get(uint04 index, uint04 sub_index) const
925 {
926 t_class value;
927 get(index, sub_index, value);
928 return value;
929 }
930
935 template<uint01 t_dims, class t_type>
936 void getVector(uint04 index, Vector<t_dims, t_type>& value) const
937 {
938 for (uint01 i = 0; i < t_dims; i++)
939 get(index, i, value[i]);
940 }
941
945 template<class t_type>
946 void insert(uint04 index, const t_type& value)
947 {
948 insert(index);
949 set(index, value);
950 }
951
958 virtual void setAll(uint04 to_location, uint04 from_location, uint04 size, const TableColumn& from_column)
959 {
960 switch (type().vector_size)
961 {
962 case 0:
963 case 1:
964 {
965 if (type().is_string)
966 setAll<StringView>(to_location, from_location, size, from_column);
967 else
968 _setAll<1>(to_location, from_location, size, from_column);
969 } break;
970
971 case 2: _setAll<2>(to_location, from_location, size, from_column); break;
972 case 3: _setAll<3>(to_location, from_location, size, from_column); break;
973 case 4: _setAll<4>(to_location, from_location, size, from_column); break;
974 case 16: _setAll<16>(to_location, from_location, size, from_column); break;
975 default: setAll<StringView>(to_location, from_location, size, from_column); break;
976 }
977 };
978
985 template<class t_type>
986 void setAll(uint04 to_location, uint04 from_location, uint04 size, const TableColumn& from_column)
987 {
988 bool can_copy = ObjectInfo<t_type>::Primitive;
989 can_copy &= !ObjectInfo<t_type>::Boolean;
990 can_copy &= type() == GetTypeInfo<t_type>();
991 can_copy &= from_column.type() == type();
992 can_copy &= begin() != nullptr;
993 can_copy &= from_column.begin() != nullptr;
994 if(can_copy)
995 {
996 memmove(
997 (uint01*)(begin()) + to_location * sizeof(t_type)
998 , (uint01*)(from_column.begin()) + from_location * sizeof(t_type)
999 , size * sizeof(t_type));
1000 }
1001 else
1002 {
1003 for (uint04 i = 0; i < size; i++)
1004 {
1005 set(to_location + i, from_column.get<t_type>(from_location + i));
1006 }
1007 }
1008 }
1009
1014 virtual TableColumn* getSelected(const Buffer<bool>& selected_indices) const = 0;
1015
1019 virtual void insertRows(uint04 location, uint04 size) = 0;
1020
1022 virtual void addRow() { insertRows(size(), 1); }
1023
1027 virtual void swapIndices(uint04 a, uint04 b) = 0;
1028
1032 virtual void insertIndices(uint04 location, uint04 size) = 0;
1033
1037 virtual void removeIndices(uint04 location, uint04 size) = 0;
1038
1041 virtual void removeIndices(const Buffer<uint04>& offset_lookup_list) = 0;
1042
1046 virtual void removeRows(uint04 offset, const Buffer<bool>& indices) = 0;
1047
1051 {
1052 return m_modified_time;
1053 }
1054
1057 {
1058 m_modified_time = Time(0);
1059 m_changes.clear();
1060 }
1061
1064 {
1066 }
1067
1071 virtual void updateFrom(const TableColumn& column);
1072
1075 void update(const TableChange& change);
1076
1080 virtual void copyRow(uint04 source, uint04 destination) = 0;
1081
1086 virtual void copyRows(uint04 source, uint04 destination, uint04 size) = 0;
1087
1091 template<class t_type>
1092 typename std::enable_if<std::is_enum<t_type>::value>::type setDefault(const t_type& value)
1093 {
1095 }
1096
1100 template<class t_type>
1101 typename std::enable_if<!std::is_enum<t_type>::value>::type setDefault(const t_type& value)
1102 {
1104 }
1105
1108 virtual void setDefaultValue(const StringAllocatingView& value) = 0;
1109
1112 virtual void setDefaultValueFrom(const TableColumn& column) = 0;
1113
1116 virtual const StringAllocatingView getDefaultValue() const = 0;
1117
1121 {
1122 return m_changes;
1123 }
1124
1130 template<class t_type>
1132 {
1133 Buffer<t_type> values(size);
1134 values.setSize(size);
1135 if (GetTypeInfo<t_type>() == type())
1136 {
1137 memcpy(values.begin(), ((const t_type*)begin()) + start, size * sizeof(t_type));
1138 }
1139 else
1140 {
1141 for (uint04 i = 0; i < size; ++i)
1142 get(i + start, values[i]);
1143 }
1144 return values;
1145 }
1146
1151
1156 Buffer<TableChange> changesSince(const Time& time, const Bounds<1, uint04>& range) const;
1157
1162 bool hasChangesSince(const Time& time, const Bounds<1, uint04>& range) const;
1163
1166 virtual uint04 size() const = 0;
1167
1170 virtual void* begin() = 0;
1171
1174 virtual void* end() = 0;
1175
1178 virtual const void* begin() const = 0;
1179
1182 virtual const void* end() const = 0;
1183
1187 {
1188 return m_reference_table;
1189 }
1190
1193 void setReferenceTable(const UUID table)
1194 {
1195 m_reference_table = table;
1196 }
1197 private:
1204 template<uint01 t_dims>
1205 void _setAll(uint04 to_location, uint04 from_location, uint04 size, const TableColumn& from_column)
1206 {
1207 if constexpr (t_dims == 1)
1208 {
1209 if (type().is_number)
1210 {
1211 if (type().is_float)
1212 {
1213 if (type().byte_size == 4)
1214 setAll<fltp04>(to_location, from_location, size, from_column);
1215 if (type().byte_size == 8)
1216 setAll<fltp08>(to_location, from_location, size, from_column);
1217 }
1218 else if (type().is_unsigned)
1219 {
1220 if (type().byte_size == 1)
1221 setAll<uint01>(to_location, from_location, size, from_column);
1222 if (type().byte_size == 2)
1223 setAll<uint02>(to_location, from_location, size, from_column);
1224 if (type().byte_size == 4)
1225 setAll<uint04>(to_location, from_location, size, from_column);
1226 if (type().byte_size == 8)
1227 setAll<uint08>(to_location, from_location, size, from_column);
1228 }
1229 else
1230 {
1231 if (type().byte_size == 1)
1232 setAll<sint01>(to_location, from_location, size, from_column);
1233 if (type().byte_size == 2)
1234 setAll<sint02>(to_location, from_location, size, from_column);
1235 if (type().byte_size == 4)
1236 setAll<sint04>(to_location, from_location, size, from_column);
1237 if (type().byte_size == 8)
1238 setAll<sint08>(to_location, from_location, size, from_column);
1239 }
1240 }
1241 else
1242 {
1243 lib_assert(false, "Table copy type not supported");
1244 }
1245 }
1246 else
1247 {
1248 if (type().is_number)
1249 {
1250 if (type().is_float)
1251 {
1252 if (type().byte_size == 4)
1253 setAll<Vector<t_dims, fltp04>>(to_location, from_location, size, from_column);
1254 if (type().byte_size == 8)
1255 setAll<Vector<t_dims, fltp08>>(to_location, from_location, size, from_column);
1256 }
1257 else if (type().is_unsigned)
1258 {
1259 if (type().byte_size == 1)
1260 setAll<Vector<t_dims, uint01>>(to_location, from_location, size, from_column);
1261 if (type().byte_size == 2)
1262 setAll<Vector<t_dims, uint02>>(to_location, from_location, size, from_column);
1263 if (type().byte_size == 4)
1264 setAll<Vector<t_dims, uint04>>(to_location, from_location, size, from_column);
1265 if (type().byte_size == 8)
1266 setAll<Vector<t_dims, uint08>>(to_location, from_location, size, from_column);
1267 }
1268 else
1269 {
1270 if (type().byte_size == 1)
1271 setAll<Vector<t_dims, sint01>>(to_location, from_location, size, from_column);
1272 if (type().byte_size == 2)
1273 setAll<Vector<t_dims, sint02>>(to_location, from_location, size, from_column);
1274 if (type().byte_size == 4)
1275 setAll<Vector<t_dims, sint04>>(to_location, from_location, size, from_column);
1276 if (type().byte_size == 8)
1277 setAll<Vector<t_dims, sint08>>(to_location, from_location, size, from_column);
1278 }
1279 }
1280 else if (type().is_color)
1281 {
1282 setAll<RGBColor>(to_location, from_location, size, from_column);
1283 }
1284 else
1285 {
1286 lib_assert(false, "Table copy type not supported");
1287 }
1288 }
1289 };
1290
1293 virtual uint08 tableHash() const
1294 {
1295 uint08 result = 2166136261U;
1296 uint01* start = (uint01*)begin();
1297 uint01* stop = (uint01*)end();
1298 for (uint01* c = start; c < stop; c++)
1299 result = (127 * result) ^ *c;
1300 return result;
1301 }
1302
1303 protected:
1306 UUID m_reference_table = Constant<UUID>::Invalid;
1309 };
1310}
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:55
A convenience class used with Buffers or Vectors of bools for referencing or acting on a single bit.
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:54
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
This class is like a string view, but may optionally store the data internally Useful if the return t...
Definition String.h:1278
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
A virtual storage type that is used with Table class to store data where the actual mechanism for sto...
Definition TableColumn.h:86
virtual void removeRows(uint04 index, uint04 size)=0
Removes a contiguous block of rows starting at the given index.
virtual void get(uint04 index, uint04 vector_pos, uint04 &value) const =0
Retrieves a uint04 value at a specific vector position within a row.
void set(uint04 index, const char *string)
Sets the value at the given row index from a C-string pointer.
virtual void get(uint04 index, StringAllocatingView &value) const =0
Retrieves a string value at the given row index as a StringAllocatingView.
virtual void get(uint04 index, uint04 vector_pos, StringAllocatingView &value) const =0
Retrieves a string value at a specific vector position within a row.
virtual void get(uint04 index, fltp04 &value) const =0
Retrieves a fltp04 value at the given row index.
std::enable_if< IsVec< t_class >::value >::type set(uint04 index, const t_class &value)
Sets a vector value at the given row index.
virtual void swapIndices(uint04 a, uint04 b)=0
Swaps two index entries.
virtual void set(uint04 index, fltp04 value)=0
Sets a fltp04 value at the given row index.
virtual void set(uint04 index, uint04 vector_pos, const StringView &value)=0
Sets a string value at a specific vector position within a row.
bool hasChangesSince(const Time &time, const Bounds< 1, uint04 > &range) const
Checks whether any changes have been recorded since the given time within a row range.
virtual void get(uint04 index, UUID &vector) const
Retrieves a UUID value at the given row index by reading 16 bytes.
virtual bool isSame(uint04 index, const StringView &value) const =0
Checks whether the stored string at the given row is exactly equal to the given value.
virtual void removeRow(uint04 index)=0
Removes a single row at the given index.
virtual void mapToFile(BinaryFileTableInfo &, BinaryCompressionObject &)
Maps this column to a binary file using compression.
virtual void removeRows(uint04 offset, const Buffer< bool > &indices)=0
Removes rows indicated by a boolean mask starting from a given offset.
virtual void setDefaultValueFrom(const TableColumn &column)=0
Copies the default value from another column.
virtual const void * begin() const =0
Returns a const pointer to the beginning of the underlying raw data.
virtual void set(uint04 index, const Matrix< fltp08 > &transform)
Sets a 4x4 fltp08 matrix value at the given row index.
void setReferenceTable(const UUID table)
Sets the UUID of a table that this column references.
std::enable_if< IsVec< t_class >::value &&t_class::NumberOfDimensions()!=1 >::type get(uint04 index, t_class &vector) const
Retrieves a multi-dimensional vector value at the given row index.
virtual uint04 size() const =0
Returns the number of rows in this column.
virtual void set(uint04 index, RGBColor value)=0
Sets an RGBColor value at the given row index.
std::enable_if< ObjectInfo< t_class >::Enum >::type set(uint04 index, const t_class &value)
Sets an enum value at the given row index by casting to uint04.
void getVector(uint04 index, Vector< t_dims, t_type > &value) const
Retrieves a generic vector from the given row index by reading each component from consecutive vector...
Time getModifiedTime() const
Returns the last modification time of this column.
virtual void set(uint04 index, uint04 vector_pos, sint02 value)=0
Sets a sint02 value at a specific vector position within a row.
virtual void get(uint04 index, uint02 &value) const =0
Retrieves a uint02 value at the given row index.
void setLabel(const StringView &label)
Sets the label (name) for this column.
virtual void get(uint04 index, uint04 vector_pos, bool &value) const =0
Retrieves a bool value at a specific vector position within a row.
void get(uint04 index, Bounds< t_dims, t_type > &bounds) const
Retrieves a Bounds value at the given row index by reading min and max components from contiguous vec...
virtual const void * end() const =0
Returns a const pointer to one past the end of the underlying raw data.
virtual void mapFromFile(BinaryFileTableInfo &)
Maps this column from a binary file for deserialization.
virtual void set(uint04 index, uint04 vector_pos, uint02 value)=0
Sets a uint02 value at a specific vector position within a row.
virtual void get(uint04 index, StringView &value) const =0
Retrieves a string value at the given row index as a StringView.
void clearUpdates()
Clears all recorded changes and resets the modified time to zero.
void get(uint04 index, File &file) const
Retrieves a File value at the given row index.
void set(uint04 index, const Time &time)
Sets a Time value at the given row index by storing its underlying uint08.
void set(uint04 index, const BitReference &val)
Sets the value at the given row index from a BitReference.
virtual void set(uint04 index, uint02 value)=0
Sets a uint02 value at the given row index.
virtual void compress(BinaryCompressionObject &object)=0
Compresses the column data into the given compression object.
virtual void copyRows(uint04 source, uint04 destination, uint04 size)=0
Copies a contiguous block of rows from one location to another within this column.
virtual void get(uint04 index, Bounds< 3, fltp08 > &bounds) const
Retrieves a 3D fltp08 bounding box from the given row index.
void get(uint04 index, Triangle< t_dims, t_type > &tri) const
Retrieves a Triangle value at the given row index by reading vertex components from contiguous vector...
void setCompressionMode(CompressionMode compression_mode)
Sets the compression mode used when serializing this column.
std::enable_if<!std::is_enum< t_type >::value >::type setDefault(const t_type &value)
Sets the default value for new rows from a non-enum value.
void get(uint04 index, const String &value) const =delete
Deleted overload to prevent accidentally passing a const String by reference as an output parameter.
virtual void get(uint04 index, uint04 vector_pos, fltp08 &value) const =0
Retrieves a fltp08 value at a specific vector position within a row.
virtual void get(uint04 index, uint01 &value) const =0
Retrieves a uint01 value at the given row index.
void get(uint04 index, Matrix< t_type, t_col, t_row > &matrix) const
Retrieves a generic matrix from the given row index by reading each element from contiguous vector po...
virtual void getVector(uint04 index, Vector< 3, fltp08 > &vector) const
Retrieves a 3D fltp08 vector from the given row index.
virtual void finishMapFromFile(BinaryFileTableInfo &)
Completes any deferred work after mapping from a binary file.
t_class get(uint04 index, uint04 sub_index) const
Convenience template that returns a value by type from a specific vector position within a row.
void setVector(uint04 index, const Vector< t_dims, t_type > &value)
Sets a vector value at the given row index, writing each component individually.
virtual void get(uint04 index, uint04 vector_pos, fltp04 &value) const =0
Retrieves a fltp04 value at a specific vector position within a row.
virtual void set(uint04 index, fltp08 value)=0
Sets a fltp08 value at the given row index.
String m_label
The display name or identifier for this column.
virtual void get(uint04 index, sint08 &value) const =0
Retrieves a sint08 value at the given row index.
virtual void set(uint04 index, uint04 vector_pos, sint08 value)=0
Sets a sint08 value at a specific vector position within a row.
void set(uint04 index, const String &value)
Sets a String value at the given row index.
void set(t_type *values, uint04 start_index, uint04 size)
Bulk-sets values from a raw pointer array into this column.
void set(uint04 index, const t_pointer_type *pointer)
Sets the value at the given row index from a const pointer, stored as uint08.
void set(uint04 index, const TranslatedString &value)
Sets a TranslatedString value at the given row index.
void insert(uint04 index, const t_type &value)
Inserts a new row at the given index and immediately sets its value.
virtual void get(uint04 index, sint04 &value) const =0
Retrieves a sint04 value at the given row index.
virtual void get(uint04 index, uint04 vector_pos, uint01 &value) const =0
Retrieves a uint01 value at a specific vector position within a row.
virtual void set(uint04 index, sint04 value)=0
Sets a sint04 value at the given row index.
virtual void set(uint04 index, sint08 value)=0
Sets a sint08 value at the given row index.
virtual void get(uint04 index, uint04 vector_pos, uint08 &value) const =0
Retrieves a uint08 value at a specific vector position within a row.
virtual uint04 getRowSize(uint04) const
Returns the size of an array-typed row at the given index.
virtual void set(uint04 index, bool value)=0
Sets a bool value at the given row index.
virtual void get(uint04 index, uint08 &value) const =0
Retrieves a uint08 value at the given row index.
virtual TypeInfo type() const =0
Returns the TypeInfo describing the data type stored in this column.
virtual void get(uint04 index, Bounds< 3, fltp04 > &bounds) const
Retrieves a 3D fltp04 bounding box from the given row index.
virtual void swap(uint04 a, uint04 b)=0
Swaps the values at two row indices.
virtual void setRowSize(uint04, uint04)
Sets the size of an array-typed row at the given index.
void set(uint04 index, const Bounds< t_dims, t_type > &value)
Sets a Bounds value at the given row index by writing min and max components into contiguous vector p...
virtual void set(uint04 index, const Bounds< 3, fltp08 > &bounds)
Sets a 3D fltp08 bounding box at the given row index.
void setAll(uint04 to_location, uint04 from_location, uint04 size, const TableColumn &from_column)
Copies a range of values from another column into this column using a specific type.
virtual void get(uint04 index, uint04 vector_pos, sint08 &value) const =0
Retrieves a sint08 value at a specific vector position within a row.
virtual void setAll(uint04 to_location, uint04 from_location, uint04 size, const TableColumn &from_column)
Copies a range of values from another column into this column.
virtual void set(uint04 index, uint01 value)=0
Sets a uint01 value at the given row index.
void get(uint04 index, TranslatedString &string) const
Retrieves a TranslatedString value at the given row index.
std::enable_if<!ObjectInfo< t_class >::Enum >::type set(uint04 index, const t_class &value)
Sets the value at the given row index from a non-enum type.
void set(uint04 index, const BitFlag &bitflag)
Sets a BitFlag value at the given row index by storing its underlying bits.
void update(const TableChange &change)
Records a change to this column and updates the modification time.
virtual void set(uint04 index, uint04 vector_pos, uint01 value)=0
Sets a uint01 value at a specific vector position within a row.
virtual void set(uint04 index, const UUID &value)
Sets a UUID value at the given row index.
Buffer< TableChange > changesSince(const Time &time, const Bounds< 1, uint04 > &range) const
Returns all changes recorded since the given time within a specific row range.
void get(uint04 index, BitFlag &bitflag) const
Retrieves a BitFlag value at the given row index.
virtual void set(uint04 index, sint02 value)=0
Sets a sint02 value at the given row index.
void get(uint04 index, Vector< 32, bool > &value) const
Retrieves a 32-element boolean vector at the given row index by reading the stored uint04 and reinter...
Buffer< t_type > getAll(uint04 start, uint04 size) const
Retrieves a contiguous range of values as a typed buffer.
virtual void set(uint04 index, uint04 value)=0
Sets a uint04 value at the given row index.
virtual void set(uint04 index, uint04 vector_pos, fltp04 value)=0
Sets a fltp04 value at a specific vector position within a row.
virtual void get(uint04 index, uint04 vector_pos, sint04 &value) const =0
Retrieves a sint04 value at a specific vector position within a row.
void set(uint04 index, const Vector< 32, bool > &value)
Sets a 32-element boolean vector at the given row index.
std::enable_if< std::is_pointer< t_class >::value >::type get(uint04 index, t_class &vector) const
Retrieves a pointer value at the given row index by reading a stored uint08.
virtual void mapToFile(BinaryFileTableInfo &, int)
Maps this column to a binary file for serialization.
void get(uint04 index, Time &time) const
Retrieves a Time value at the given row index.
virtual void get(uint04 index, uint04 &value) const =0
Retrieves a uint04 value at the given row index.
virtual const StringAllocatingView getDefaultValue() const =0
Returns the default value for new rows as a string representation.
virtual void set(uint04 index, uint08 value)=0
Sets a uint08 value at the given row index.
void set(uint04 index, const std::nullptr_t &)
Sets the value at the given row index to zero (nullptr overload).
virtual void get(uint04 index, Matrix< fltp08 > &transform) const
Retrieves a 4x4 fltp08 matrix from the given row index.
virtual void getVector(uint04 index, Vector< 3, fltp04 > &vector) const
Retrieves a 3D fltp04 vector from the given row index.
Buffer< TableChange > m_changes
The list of recorded changes for change-tracking and synchronization.
virtual ~TableColumn()
Virtual destructor.
UUID m_reference_table
UUID of a table this column references, or Invalid if none.
virtual void set(uint04 index, uint04 vector_pos, bool value)=0
Sets a bool value at a specific vector position within a row.
virtual void set(uint04 index, uint04 vector_pos, fltp08 value)=0
Sets a fltp08 value at a specific vector position within a row.
virtual void removeRows(const Buffer< uint04 > &sorted_remove_indices)=0
Removes multiple rows identified by a sorted list of indices.
virtual void addRow()
Appends a single default-initialized row at the end of the column.
virtual uint08 tableHash() const
Computes a hash of the column's raw data using a variant of the FNV hash algorithm.
virtual void get(uint04 index, RGBColor &value) const =0
Retrieves an RGBColor value at the given row index.
virtual void removeIndices(const Buffer< uint04 > &offset_lookup_list)=0
Removes index entries using an offset lookup list.
virtual void get(uint04 index, uint04 vector_pos, uint02 &value) const =0
Retrieves a uint02 value at a specific vector position within a row.
virtual void get(uint04 index, bool &value) const =0
Retrieves a bool value at the given row index.
t_class get(uint04 index) const
Convenience template that returns a value by type from the given row index.
virtual void get(uint04 index, sint02 &value) const =0
Retrieves a sint02 value at the given row index.
void set(uint04 index, const char(&string)[N])
Sets the value at the given row index from a string literal.
Buffer< TableChange > changesSince(const Time &time) const
Returns all changes recorded since the given time.
virtual void set(uint04 index, const Matrix< fltp04 > &transform)
Sets a 4x4 fltp04 matrix value at the given row index.
void get(uint04 index, Vector< 1, t_class > &vector) const
Retrieves a 1D vector value at the given row index by delegating to the scalar get.
virtual void getVector(uint04 index, Vector< 1, uint04 > &vector) const
Retrieves a 1D uint04 vector from the given row index.
virtual void getVector(uint04 index, Vector< 3, uint04 > &vector) const
Retrieves a 3D uint04 vector from the given row index.
virtual bool beginsWith(uint04 index, const StringView &value, bool ignore_case) const =0
Checks whether the stored string at the given row begins with the given prefix.
virtual void get(uint04 index, sint01 &value) const =0
Retrieves a sint01 value at the given row index.
virtual void updateFrom(const TableColumn &column)
Updates this column's data from another column, typically used for synchronization or mirroring.
void set(uint04 index, const File &value)
Sets a File value at the given row index.
virtual void get(uint04 index, uint04 vector_pos, sint02 &value) const =0
Retrieves a sint02 value at a specific vector position within a row.
CompressionMode m_compression_mode
The compression mode used when serializing this column.
const String & label() const
Returns the label (name) of this column.
virtual void * begin()=0
Returns a mutable pointer to the beginning of the underlying raw data.
const Buffer< TableChange > & changes() const
Returns the list of all recorded changes for this column.
virtual void set(uint04 index, uint04 vector_pos, uint08 value)=0
Sets a uint08 value at a specific vector position within a row.
virtual void removeIndices(uint04 location, uint04 size)=0
Removes a contiguous block of index entries at the given location.
void set(uint04 index, const Triangle< t_dims, t_type > &value)
Sets a Triangle value at the given row index by writing each vertex component into contiguous vector ...
virtual void set(uint04 index, sint01 value)=0
Sets a sint01 value at the given row index.
virtual void get(uint04 index, Matrix< fltp04 > &transform) const
Retrieves a 4x4 fltp04 matrix from the given row index.
std::enable_if< ObjectInfo< t_class >::Enum >::type get(uint04 index, t_class &enum_value) const
Retrieves an enum value at the given row index by reading a stored uint04.
virtual void setDefaultValue(const StringAllocatingView &value)=0
Sets the default value for new rows from a string representation.
virtual void getVector(uint04 index, Vector< 2, uint04 > &vector) const
Retrieves a 2D uint04 vector from the given row index.
virtual void set(uint04 index, uint04 vector_pos, sint04 value)=0
Sets a sint04 value at a specific vector position within a row.
virtual void resetRow(uint04)
Resets a row to its default state.
UUID referenceTable() const
Returns the UUID of a table that this column references, if any.
virtual void set(uint04 index, uint04 vector_pos, sint01 value)=0
Sets a sint01 value at a specific vector position within a row.
virtual void setSize(uint04 size)=0
Sets the number of rows in this column.
TableColumn(const StringView &label)
Constructs a TableColumn with the given label.
virtual void copyRow(uint04 source, uint04 destination)=0
Copies the value from one row to another within this column.
uint04 getIndexOf(const t_type &object) const
Searches for the first row containing the given value.
virtual void insertRows(uint04 location, uint04 size)=0
Inserts a contiguous block of default-initialized rows at the given location.
virtual bool contains(uint04 index, const StringView &value, bool ignore_case) const =0
Checks whether the stored string at the given row contains the given substring.
virtual void get(uint04 index, fltp08 &value) const =0
Retrieves a fltp08 value at the given row index.
std::enable_if< std::is_enum< t_type >::value >::type setDefault(const t_type &value)
Sets the default value for new rows from an enum value by casting to uint04.
void set(uint04 index, t_pointer_type *pointer)
Sets the value at the given row index from a non-const pointer, stored as uint08.
void set(uint04 index, const Matrix< t_type, t_col, t_row > &matrix)
Sets a Matrix value at the given row index by writing each element column-major into contiguous vecto...
virtual void set(uint04 index, uint04 vector_pos, uint04 value)=0
Sets a uint04 value at a specific vector position within a row.
virtual void insertIndices(uint04 location, uint04 size)=0
Inserts a contiguous block of index entries at the given location.
virtual void set(uint04 index, const Bounds< 3, fltp04 > &bounds)
Sets a 3D fltp04 bounding box at the given row index.
virtual TableColumn * getSelected(const Buffer< bool > &selected_indices) const =0
Creates a new TableColumn containing only the rows where the corresponding selected_indices entry is ...
void set(uint04 index, const StringAllocatingView &string)
Sets the value at the given row index from a StringAllocatingView.
Time m_modified_time
The timestamp of the most recent modification to this column.
void updateAll()
Marks the entire column as updated by recording a change spanning all rows.
virtual void * end()=0
Returns a mutable pointer to one past the end of the underlying raw data.
virtual void set(uint04 index, const StringView &value)=0
Sets a string value at the given row index.
virtual void insert(uint04 index)=0
Inserts a default-initialized row at the given index, shifting subsequent rows.
virtual void get(uint04 index, uint04 vector_pos, sint01 &value) const =0
Retrieves a sint01 value at a specific vector position within a row.
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
static Time SystemTime()
Retrieves the current system time which is a combination of std::chrono::steady_clock to ensure smoot...
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A three-vertex polygon representing a triangle in N-dimensional space.
Definition Triangle.hpp:142
Stores information about a type, relevant for certain templated functions.
Definition TypeInfo.h:43
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
The primary namespace for the NDEVR SDK.
@ type
The type identifier string for this model node.
Definition Model.h:58
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator Author: Tyler Parke Date: 2017-11-05...
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
constexpr std::enable_if<!ObjectInfo< t_type >::Buffer, TypeInfo >::type GetTypeInfo()
Constructs a TypeInfo for a non-buffer type at compile time using ObjectInfo traits.
Definition TypeInfo.h:125
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
CompressionMode
Forward declaration of the Module struct for module metadata.
Definition Compressor.h:17
@ e_default_compression
Uses a sensible default compression strategy.
Definition Compressor.h:19
int16_t sint02
-Defines an alias representing a 2 byte, signed integer.
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
constexpr t_to & rcast(t_from &value)
Casts the given value.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
@ file
The source file path associated with this object.
int8_t sint01
-Defines an alias representing a 1 byte, signed integer.
int64_t sint08
-Defines an alias representing an 8 byte, signed integer -Can represent exact integer values -9223372...
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
Definition Angle.h:408
A container for storing compressed data, typically used for File IO operations.
Definition Compressor.h:53
Extended file table information for reading and writing NDV binary files.
Information about the object.
Definition ObjectInfo.h:55
Records changes to a table or column noting the bounds of the data adjusted.
Definition TableColumn.h:54
TableChange(TableChangeType type, uint04 start, uint04 size, Time time=Time::SystemTime())
Constructs a TableChange recording a specific modification.
Definition TableColumn.h:68
TableChangeType
Enumerates the types of changes that can be recorded for a table or column.
Definition TableColumn.h:57
@ e_insertion
New rows were inserted.
Definition TableColumn.h:59
@ e_update
An existing row range was modified in place.
Definition TableColumn.h:58
@ e_full_update
The entire column or table was replaced or rebuilt.
Definition TableColumn.h:61
@ e_deletion
Rows were deleted.
Definition TableColumn.h:60
Time time
The timestamp when the change occurred.
Definition TableColumn.h:74
uint04 size
The number of rows affected by the change.
Definition TableColumn.h:76
uint04 start
The starting row index of the affected range.
Definition TableColumn.h:75
TableChangeType type
The kind of change that was recorded.
Definition TableColumn.h:77