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>
73 const String& label()
const;
74 void setLabel(
const String& label);
137 m_compression_valid =
true;
138 m_compression_object = object;
139 m_compression_hash = tableHash();
144 virtual void set(
uint04 index,
const UUID& value);
148 template<u
int01 t_dims,
class t_type>
151 lib_assert(type().vector_size == t_dims * 3,
"Unexpected vector size write to column");
152 for (
uint01 i = 0; i < 3; i++)
153 for (
uint01 n = 0; n < t_dims; n++)
154 set(index, 3 * i + n, value[i][n]);
158 template<u
int01 t_dims,
class t_type>
161 lib_assert(type().vector_size == t_dims * 2,
"Unexpected vector size write to column");
162 for (
uint01 i = 0; i < 2; i++)
163 for (
uint01 n = 0; n < t_dims; n++)
164 set(index, t_dims * i + n, value[i][n]);
167 template<
class t_type, u
int01 t_col, u
int01 t_row>
170 lib_assert(type().vector_size == t_col * t_row,
"Unexpected vector size write to column");
171 for (
uint01 col = 0; col < t_col; col++)
172 for (
uint01 row = 0; row < t_row; row++)
173 set(index, col * t_row + row, matrix[col][row]);
175 template<
class t_
class>
176 typename std::enable_if<IsVec<t_class>::value>::type
set(
uint04 index,
const t_class& value)
178 if (t_class::NumberOfDimensions() == 1)
179 set(index, value[0]);
181 setVector(index, value);
183 template<
class t_
class>
184 typename std::enable_if<ObjectInfo<t_class>::Enum>::type
set(
uint04 index,
const t_class& value)
186 lib_assert(type().vector_size == 0,
"Unexpected vector size write to column");
187 set(index, cast<uint04>(value));
191 set(index, bitflag.
bits());
193 template<
class t_
class>
196 lib_assert(type().vector_size == 0,
"Unexpected vector size write to column");
197 set(index,
String(value));
200 template<
class t_type>
203 if (GetTypeInfo<t_type>() == type())
205 memcpy(((t_type*)begin()) + start_index, values, size *
sizeof(t_type));
207 else for (
uint04 i = 0; i < size; i++)
209 set(i + start_index, values[i]);
212 template<u
int01 t_dims,
class t_type>
215 const uint01 dim_size =
getMin(cast<uint01>(type().vector_size), t_dims);
216 for (
uint01 i = 0; i < dim_size; i++)
217 set(index, i, value[i]);
223 virtual bool contains(
uint04 index,
const char* value,
bool ignore_case)
const = 0;
227 template<
class t_
class>
230 get(index, vector[0]);
240 template<
class t_
class>
241 typename std::enable_if<IsVec<t_class>::value && t_class::NumberOfDimensions() != 1>::type
get(
uint04 index, t_class& vector)
const
243 getVector(index, vector);
245 template<
class t_
class>
246 typename std::enable_if<ObjectInfo<t_class>::Enum>::type
get(
uint04 index, t_class& enum_value)
const
250 enum_value = cast<t_class>(value);
254 template<
class t_type>
257 for (
uint04 i = 0; i < size(); i++)
259 if (
object == get<t_type>(i))
266 if (m_compression_mode != compression_mode)
268 m_compression_mode = compression_mode;
269 m_compression_valid =
false;
307 template<
class t_type, u
int01 t_col, u
int01 t_row>
310 for (
uint01 col = 0; col < t_col; col++)
311 for (
uint01 row = 0; row < t_row; row++)
312 get(index, col * t_row + row, matrix[col][row]);
324 for (
uint01 i = 0; i < 16; i++)
325 get(index, i, vector[i]);
345 get(index, int_value);
346 value = rcast<Vector<32, bool>>(int_value);
350 template<u
int01 t_dims,
class t_type>
353 for (
uint01 i = 0; i < 2; i++)
354 for (
uint01 n = 0; n < t_dims; n++)
355 get(index, t_dims * i + n, bounds[i][n]);
358 template<u
int01 t_dims,
class t_type>
361 for (
uint01 i = 0; i < 3; i++)
362 for (
uint01 n = 0; n < 3 * t_dims; n++)
363 get(index, 3 * i + n, tri[i][n]);
366 template<
class t_
class>
373 template<
class t_
class>
377 get(index, sub_index, value);
380 template<u
int01 t_dims,
class t_type>
383 for (
uint01 i = 0; i < t_dims; i++)
384 get(index, i, value[i]);
386 template<
class t_type>
395 switch (type().vector_size)
400 if (type().is_string)
401 setAll<String>(to_location, from_location, size, from_column);
403 _setAll<1>(to_location, from_location, size, from_column);
406 case 2: _setAll<2>(to_location, from_location, size, from_column);
break;
407 case 3: _setAll<3>(to_location, from_location, size, from_column);
break;
408 case 4: _setAll<4>(to_location, from_location, size, from_column);
break;
409 case 16: _setAll<16>(to_location, from_location, size, from_column);
break;
410 default: setAll<String>(to_location, from_location, size, from_column);
break;
414 template<
class t_type>
419 can_copy &= type() == GetTypeInfo<t_type>();
420 can_copy &= from_column.
type() == type();
421 can_copy &= begin() !=
nullptr;
422 can_copy &= from_column.
begin() !=
nullptr;
426 (
uint01*)(begin()) + to_location *
sizeof(t_type)
427 , (
uint01*)(from_column.
begin()) + from_location *
sizeof(t_type)
428 , size *
sizeof(t_type));
432 for (
uint04 i = 0; i < size; i++)
434 set(to_location + i, from_column.
get<t_type>(from_location + i));
440 virtual void addRow() { insertRows(size(), 1); }
448 return m_modified_time;
452 m_modified_time =
Time(0);
457 update(
TableChange(TableChange::e_update, 0, size()));
460 virtual void updateFrom(
const TableColumn& column);
467 template<
class t_type>
472 template<
class t_type>
481 template<
class t_type>
486 if (GetTypeInfo<t_type>() == type())
488 memcpy(values.
begin(), ((
const t_type*)begin()) + start, size *
sizeof(t_type));
492 for (
uint04 i = 0; i < size; ++i)
493 get(i + start, values[i]);
505 virtual const void*
begin()
const = 0;
506 virtual const void*
end()
const = 0;
510 template<u
int01 t_dims>
513 if constexpr (t_dims == 1)
515 if (type().is_number)
519 if (type().byte_size == 4)
520 setAll<fltp04>(to_location, from_location, size, from_column);
521 if (type().byte_size == 8)
522 setAll<fltp08>(to_location, from_location, size, from_column);
524 else if (type().is_unsigned)
526 if (type().byte_size == 1)
527 setAll<uint01>(to_location, from_location, size, from_column);
528 if (type().byte_size == 2)
529 setAll<uint02>(to_location, from_location, size, from_column);
530 if (type().byte_size == 4)
531 setAll<uint04>(to_location, from_location, size, from_column);
532 if (type().byte_size == 8)
533 setAll<uint08>(to_location, from_location, size, from_column);
537 if (type().byte_size == 1)
538 setAll<sint01>(to_location, from_location, size, from_column);
539 if (type().byte_size == 2)
540 setAll<sint02>(to_location, from_location, size, from_column);
541 if (type().byte_size == 4)
542 setAll<sint04>(to_location, from_location, size, from_column);
543 if (type().byte_size == 8)
544 setAll<sint08>(to_location, from_location, size, from_column);
549 lib_assert(
false,
"Table copy type not supported");
554 if (type().is_number)
558 if (type().byte_size == 4)
559 setAll<Vector<t_dims, fltp04>>(to_location, from_location, size, from_column);
560 if (type().byte_size == 8)
561 setAll<Vector<t_dims, fltp08>>(to_location, from_location, size, from_column);
563 else if (type().is_unsigned)
565 if (type().byte_size == 1)
566 setAll<Vector<t_dims, uint01>>(to_location, from_location, size, from_column);
567 if (type().byte_size == 2)
568 setAll<Vector<t_dims, uint02>>(to_location, from_location, size, from_column);
569 if (type().byte_size == 4)
570 setAll<Vector<t_dims, uint04>>(to_location, from_location, size, from_column);
571 if (type().byte_size == 8)
572 setAll<Vector<t_dims, uint08>>(to_location, from_location, size, from_column);
576 if (type().byte_size == 1)
577 setAll<Vector<t_dims, sint01>>(to_location, from_location, size, from_column);
578 if (type().byte_size == 2)
579 setAll<Vector<t_dims, sint02>>(to_location, from_location, size, from_column);
580 if (type().byte_size == 4)
581 setAll<Vector<t_dims, sint04>>(to_location, from_location, size, from_column);
582 if (type().byte_size == 8)
583 setAll<Vector<t_dims, sint08>>(to_location, from_location, size, from_column);
586 else if (type().is_color)
588 setAll<RGBColor>(to_location, from_location, size, from_column);
592 lib_assert(
false,
"Table copy type not supported");
598 uint08 result = 2166136261U;
601 for (
uint01* c = start; c < stop; c++)
602 result = (127 * result) ^ *c;
#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
Definition BinaryFile.h:51
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:68
uint01 bits() const
Definition BitFlag.hpp:371
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:57
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
void setSize(t_index_type new_size)
Definition Buffer.hpp:1413
decltype(auto) begin()
Definition Buffer.hpp:504
Definition Matrix.hpp:173
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:53
Definition TableColumn.h:68
virtual void get(uint04 index, uint04 vector_pos, uint01 &value) const =0
t_type getDefaultValue() const
Definition TableColumn.h:473
void updateAll()
Definition TableColumn.h:455
virtual void removeIndices(const Buffer< uint04 > &offset_lookup_list)=0
String m_label
Definition TableColumn.h:608
virtual void get(uint04 index, uint04 vector_pos, sint04 &value) const =0
void insert(uint04 index, const t_type &value)
Definition TableColumn.h:387
virtual uint04 getRowSize(uint04) const
Definition TableColumn.h:77
virtual void set(uint04 index, uint04 vector_pos, sint02 value)=0
virtual void set(uint04 index, uint04 vector_pos, uint04 value)=0
void get(uint04 index, Vector< 32, bool > &value) const
Definition TableColumn.h:342
Buffer< t_type > getAll(uint04 start, uint04 size) const
Definition TableColumn.h:482
void setVector(uint04 index, const Vector< t_dims, t_type > &value)
Definition TableColumn.h:213
std::enable_if< ObjectInfo< t_class >::Enum >::type get(uint04 index, t_class &enum_value) const
Definition TableColumn.h:246
virtual void set(uint04 index, uint04 vector_pos, fltp04 value)=0
virtual void removeRows(uint04 index, uint04 size)=0
virtual void addRow()
Definition TableColumn.h:440
void get(uint04 index, Bounds< t_dims, t_type > &bounds) const
Definition TableColumn.h:351
virtual TableColumn * getSelected(const Buffer< bool > &selected_indices) const =0
virtual void get(uint04 index, UUID &vector) const
Definition TableColumn.h:322
virtual bool beginsWith(uint04 index, const String &value, bool ignore_case) const =0
BinaryCompressionObject & compressionObject()
Definition TableColumn.h:507
virtual bool contains(uint04 index, const char *value, bool ignore_case) const =0
virtual void set(uint04 index, sint01 value)=0
void set(uint04 index, const Bounds< t_dims, t_type > &value)
Definition TableColumn.h:159
bool m_compression_valid
Definition TableColumn.h:613
void set(t_type *values, uint04 start_index, uint04 size)
Definition TableColumn.h:201
virtual void get(uint04 index, uint08 &value) const =0
virtual bool isSame(uint04 index, const String &value) const =0
virtual void get(uint04 index, uint04 vector_pos, uint04 &value) const =0
virtual uint04 size() const =0
virtual void mapToFile(BinaryFile &file, BinaryCompressionObject &object)=0
t_class get(uint04 index) const
Definition TableColumn.h:367
virtual void get(uint04 index, uint04 vector_pos, uint08 &value) const =0
void _setAll(uint04 to_location, uint04 from_location, uint04 size, const TableColumn &from_column)
Definition TableColumn.h:511
virtual void get(uint04 index, uint04 vector_pos, sint02 &value) const =0
TypeInfo m_type
Definition TableColumn.h:609
void get(uint04 index, TranslatedString &string) const
Definition TableColumn.h:335
virtual void compressIfNeeded(BinaryCompressionObject &object)
Definition TableColumn.h:111
Time m_modified_time
Definition TableColumn.h:607
virtual void get(uint04 index, sint04 &value) const =0
virtual void set(uint04 index, uint04 vector_pos, const String &value)=0
virtual void set(uint04 index, uint04 vector_pos, bool value)=0
void set(uint04 index, const Matrix< t_type, t_col, t_row > &matrix)
Definition TableColumn.h:168
virtual void insertIndices(uint04 location, uint04 size)=0
virtual void set(uint04 index, uint01 value)=0
void setDefaultValue(const t_type &value)
Definition TableColumn.h:468
virtual void get(uint04 index, sint01 &value) const =0
void get(uint04 index, Matrix< t_type, t_col, t_row > &matrix) const
Definition TableColumn.h:308
virtual void set(uint04 index, uint04 vector_pos, uint02 value)=0
std::enable_if< IsVec< t_class >::value &&t_class::NumberOfDimensions()!=1 >::type get(uint04 index, t_class &vector) const
Definition TableColumn.h:241
virtual void compress(BinaryCompressionObject &object)=0
virtual void get(uint04 index, String &value) const =0
const Buffer< TableChange > & changes() const
Definition TableColumn.h:477
virtual void set(uint04 index, sint08 value)=0
std::enable_if<!ObjectInfo< t_class >::Enum &&!IsVec< t_class >::value >::type set(uint04 index, const t_class &value)
Definition TableColumn.h:194
virtual void set(uint04 index, uint04 vector_pos, sint04 value)=0
void clearUpdates()
Definition TableColumn.h:450
virtual void set(uint04 index, const String &value)=0
virtual void set(uint04 index, uint08 value)=0
virtual void get(uint04 index, fltp08 &value) const =0
t_class get(uint04 index, uint04 sub_index) const
Definition TableColumn.h:374
virtual void get(uint04 index, bool &value) const =0
virtual void set(uint04 index, uint04 value)=0
virtual void get(uint04 index, uint04 vector_pos, fltp08 &value) const =0
virtual void insertRows(uint04 location, uint04 size)=0
virtual void set(uint04 index, RGBColor value)=0
virtual void copyRows(uint04 source, uint04 destination, uint04 size)=0
virtual bool beginsWith(uint04 index, const char *value, bool ignore_case) const =0
virtual void get(uint04 index, uint04 vector_pos, fltp04 &value) const =0
void get(uint04 index, Triangle< t_dims, t_type > &tri) const
Definition TableColumn.h:359
virtual void set(uint04 index, sint04 value)=0
virtual void set(uint04 index, uint04 vector_pos, fltp08 value)=0
virtual void set(uint04 index, uint02 value)=0
virtual void get(uint04 index, fltp04 &value) const =0
virtual void get(uint04 index, RGBColor &value) const =0
virtual void get(uint04 index, uint04 vector_pos, bool &value) const =0
void get(uint04 index, BitFlag &bitflag) const
Definition TableColumn.h:233
uint04 getIndexOf(const t_type &object) const
Definition TableColumn.h:255
virtual void get(uint04 index, sint08 &value) const =0
void set(uint04 index, const BitFlag &bitflag)
Definition TableColumn.h:189
virtual void setSize(uint04 size)=0
virtual void removeRows(const Buffer< uint04 > &sorted_remove_indices)=0
void set(uint04 index, const Triangle< t_dims, t_type > &value)
Definition TableColumn.h:149
virtual const void * end() const =0
virtual bool contains(uint04 index, const String &value, bool ignore_case) const =0
void setAll(uint04 to_location, uint04 from_location, uint04 size, const TableColumn &from_column)
Definition TableColumn.h:415
virtual uint08 tableHash() const
Definition TableColumn.h:596
virtual void get(uint04 index, sint02 &value) const =0
virtual void get(uint04 index, uint04 &value) const =0
virtual void get(uint04 index, uint01 &value) const =0
virtual void setAll(uint04 to_location, uint04 from_location, uint04 size, const TableColumn &from_column)
Definition TableColumn.h:393
virtual void set(uint04 index, uint04 vector_pos, uint08 value)=0
void setCompressionMode(CompressionMode compression_mode)
Definition TableColumn.h:264
virtual void set(uint04 index, uint04 vector_pos, uint01 value)=0
virtual void set(uint04 index, fltp04 value)=0
BinaryCompressionObject m_compression_object
Definition TableColumn.h:606
uint08 m_compression_hash
Definition TableColumn.h:610
virtual void insert(uint04 index)=0
std::enable_if< IsVec< t_class >::value >::type set(uint04 index, const t_class &value)
Definition TableColumn.h:176
virtual void copyRow(uint04 source, uint04 destination)=0
virtual void get(uint04 index, uint04 vector_pos, sint01 &value) const =0
virtual TypeInfo type() const
Definition TableColumn.h:78
virtual void get(uint04 index, uint04 vector_pos, uint02 &value) const =0
virtual void setRowSize(uint04, uint04)
Definition TableColumn.h:76
void get(uint04 index, Time &time) const
Definition TableColumn.h:328
virtual void removeRow(uint04 index)=0
virtual bool isSame(uint04 index, const char *value) const =0
virtual void removeRows(uint04 offset, const Buffer< bool > &indices)=0
virtual void get(uint04 index, uint04 vector_pos, String &value) const =0
virtual void removeIndices(uint04 location, uint04 size)=0
virtual void mapToFile(BinaryFile &file, int compression)=0
void get(uint04 index, Vector< 1, t_class > &vector) const
Definition TableColumn.h:228
void getVector(uint04 index, Vector< t_dims, t_type > &value) const
Definition TableColumn.h:381
virtual void set(uint04 index, fltp08 value)=0
virtual void mapFromFile(BinaryFile &file, uint08 version_number)=0
virtual void get(uint04 index, uint02 &value) const =0
Time modifiedTime() const
Definition TableColumn.h:446
virtual void set(uint04 index, bool value)=0
void updateCompressionInfo(BinaryCompressionObject &object)
Definition TableColumn.h:135
Buffer< TableChange > m_changes
Definition TableColumn.h:611
virtual void get(uint04 index, uint04 vector_pos, sint08 &value) const =0
virtual void set(uint04 index, uint04 vector_pos, sint01 value)=0
virtual void set(uint04 index, sint02 value)=0
std::enable_if< ObjectInfo< t_class >::Enum >::type set(uint04 index, const t_class &value)
Definition TableColumn.h:184
void get(uint04 index, File &file) const
Definition TableColumn.h:315
virtual const void * begin() const =0
bool compressionValid() const
Definition TableColumn.h:508
virtual void set(uint04 index, uint04 vector_pos, sint08 value)=0
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
Definition TranslatedString.h:9
Definition Triangle.hpp:143
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:76
int64_t sint08
-Defines an alias representing an 8 byte, signed integer -Can represent exact integer values -9223372...
Definition BaseValues.hpp:86
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:157
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
int8_t sint01
-Defines an alias representing a 1 byte, signed integer. -Can represent exact integer values -127 thr...
Definition BaseValues.hpp:56
CompressionMode
Definition Compressor.h:12
int16_t sint02
-Defines an alias representing a 2 byte, signed integer. -Can represent exact integer values -32767 t...
Definition BaseValues.hpp:66
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer -Can represent exact integer values 0 thro...
Definition BaseValues.hpp:132
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:109
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator.
Definition BaseFunctions.hpp:67
Definition Compressor.h:38
Definition BaseValues.hpp:272
Definition Vector.hpp:828
Information about the object.
Definition ObjectInfo.h:56
Definition TableColumn.h:49
TableChange(TableChangeType type, uint04 start, uint04 size, Time time=Time::SystemTime())
Definition TableColumn.h:56
uint04 size
Definition TableColumn.h:64
uint04 start
Definition TableColumn.h:63
TableChangeType
Definition TableColumn.h:51
TableChangeType type
Definition TableColumn.h:65
Time time
Definition TableColumn.h:62