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>
145 m_compression_valid =
true;
146 m_compression_object = object;
147 m_compression_hash = tableHash();
156 template<u
int01 t_dims,
class t_type>
159 lib_assert(type().vector_size == t_dims * 3,
"Unexpected vector size write to column");
160 for (
uint01 i = 0; i < 3; i++)
161 for (
uint01 n = 0; n < t_dims; n++)
162 set(index, 3 * i + n, value[i][n]);
166 template<u
int01 t_dims,
class t_type>
169 lib_assert(type().vector_size == t_dims * 2,
"Unexpected vector size write to column");
170 for (
uint01 i = 0; i < 2; i++)
171 for (
uint01 n = 0; n < t_dims; n++)
172 set(index, t_dims * i + n, value[i][n]);
175 template<
class t_type, u
int01 t_col, u
int01 t_row>
178 lib_assert(type().vector_size == t_col * t_row,
"Unexpected vector size write to column");
179 for (
uint01 col = 0; col < t_col; col++)
180 for (
uint01 row = 0; row < t_row; row++)
181 set(index, col * t_row + row, matrix[col][row]);
183 template<
class t_
class>
184 typename std::enable_if<IsVec<t_class>::value>::type
set(
uint04 index,
const t_class& value)
186 if (t_class::NumberOfDimensions() == 1)
187 set(index, value[0]);
189 setVector(index, value);
191 template<
class t_
class>
192 typename std::enable_if<ObjectInfo<t_class>::Enum>::type
set(
uint04 index,
const t_class& value)
194 lib_assert(type().vector_size == 0,
"Unexpected vector size write to column");
195 set(index, cast<uint04>(value));
199 set(index, bitflag.
bits());
201 template<
class t_
class>
204 lib_assert(type().vector_size == 0,
"Unexpected vector size write to column");
205 set(index,
String(value));
208 template<
class t_type>
211 if (GetTypeInfo<t_type>() == type())
213 memcpy(((t_type*)begin()) + start_index, values, size *
sizeof(t_type));
215 else for (
uint04 i = 0; i < size; i++)
217 set(i + start_index, values[i]);
220 template<u
int01 t_dims,
class t_type>
223 const uint01 dim_size =
getMin(cast<uint01>(type().vector_size), t_dims);
224 for (
uint01 i = 0; i < dim_size; i++)
225 set(index, i, value[i]);
231 virtual bool contains(
uint04 index,
const char* value,
bool ignore_case)
const = 0;
235 template<
class t_
class>
238 get(index, vector[0]);
248 template<
class t_
class>
249 typename std::enable_if<IsVec<t_class>::value && t_class::NumberOfDimensions() != 1>::type
get(
uint04 index, t_class& vector)
const
251 getVector(index, vector);
253 template<
class t_
class>
254 typename std::enable_if<ObjectInfo<t_class>::Enum>::type
get(
uint04 index, t_class& enum_value)
const
258 enum_value = cast<t_class>(value);
262 template<
class t_type>
265 for (
uint04 i = 0; i < size(); i++)
267 if (
object == get<t_type>(i))
274 if (m_compression_mode != compression_mode)
276 m_compression_mode = compression_mode;
277 m_compression_valid =
false;
315 template<
class t_type, u
int01 t_col, u
int01 t_row>
318 for (
uint01 col = 0; col < t_col; col++)
319 for (
uint01 row = 0; row < t_row; row++)
320 get(index, col * t_row + row, matrix[col][row]);
332 for (
uint01 i = 0; i < 16; i++)
333 get(index, i, vector[i]);
353 get(index, int_value);
354 value = rcast<Vector<32, bool>>(int_value);
358 template<u
int01 t_dims,
class t_type>
361 for (
uint01 i = 0; i < 2; i++)
362 for (
uint01 n = 0; n < t_dims; n++)
363 get(index, t_dims * i + n, bounds[i][n]);
366 template<u
int01 t_dims,
class t_type>
369 for (
uint01 i = 0; i < 3; i++)
370 for (
uint01 n = 0; n < 3 * t_dims; n++)
371 get(index, 3 * i + n, tri[i][n]);
374 template<
class t_
class>
381 template<
class t_
class>
385 get(index, sub_index, value);
388 template<u
int01 t_dims,
class t_type>
391 for (
uint01 i = 0; i < t_dims; i++)
392 get(index, i, value[i]);
394 template<
class t_type>
403 switch (type().vector_size)
408 if (type().is_string)
409 setAll<String>(to_location, from_location, size, from_column);
411 _setAll<1>(to_location, from_location, size, from_column);
414 case 2: _setAll<2>(to_location, from_location, size, from_column);
break;
415 case 3: _setAll<3>(to_location, from_location, size, from_column);
break;
416 case 4: _setAll<4>(to_location, from_location, size, from_column);
break;
417 case 16: _setAll<16>(to_location, from_location, size, from_column);
break;
418 default: setAll<String>(to_location, from_location, size, from_column);
break;
422 template<
class t_type>
427 can_copy &= type() == GetTypeInfo<t_type>();
428 can_copy &= from_column.
type() == type();
429 can_copy &= begin() !=
nullptr;
430 can_copy &= from_column.
begin() !=
nullptr;
434 (
uint01*)(begin()) + to_location *
sizeof(t_type)
435 , (
uint01*)(from_column.
begin()) + from_location *
sizeof(t_type)
436 , size *
sizeof(t_type));
440 for (
uint04 i = 0; i < size; i++)
442 set(to_location + i, from_column.
get<t_type>(from_location + i));
448 virtual void addRow() { insertRows(size(), 1); }
456 return m_modified_time;
460 m_modified_time =
Time(0);
465 update(
TableChange(TableChange::e_update, 0, size()));
475 template<
class t_type>
480 template<
class t_type>
489 template<
class t_type>
494 if (GetTypeInfo<t_type>() == type())
496 memcpy(values.
begin(), ((
const t_type*)begin()) + start, size *
sizeof(t_type));
500 for (
uint04 i = 0; i < size; ++i)
501 get(i + start, values[i]);
513 virtual const void*
begin()
const = 0;
514 virtual const void*
end()
const = 0;
518 template<u
int01 t_dims>
521 if constexpr (t_dims == 1)
523 if (type().is_number)
527 if (type().byte_size == 4)
528 setAll<fltp04>(to_location, from_location, size, from_column);
529 if (type().byte_size == 8)
530 setAll<fltp08>(to_location, from_location, size, from_column);
532 else if (type().is_unsigned)
534 if (type().byte_size == 1)
535 setAll<uint01>(to_location, from_location, size, from_column);
536 if (type().byte_size == 2)
537 setAll<uint02>(to_location, from_location, size, from_column);
538 if (type().byte_size == 4)
539 setAll<uint04>(to_location, from_location, size, from_column);
540 if (type().byte_size == 8)
541 setAll<uint08>(to_location, from_location, size, from_column);
545 if (type().byte_size == 1)
546 setAll<sint01>(to_location, from_location, size, from_column);
547 if (type().byte_size == 2)
548 setAll<sint02>(to_location, from_location, size, from_column);
549 if (type().byte_size == 4)
550 setAll<sint04>(to_location, from_location, size, from_column);
551 if (type().byte_size == 8)
552 setAll<sint08>(to_location, from_location, size, from_column);
557 lib_assert(
false,
"Table copy type not supported");
562 if (type().is_number)
566 if (type().byte_size == 4)
567 setAll<Vector<t_dims, fltp04>>(to_location, from_location, size, from_column);
568 if (type().byte_size == 8)
569 setAll<Vector<t_dims, fltp08>>(to_location, from_location, size, from_column);
571 else if (type().is_unsigned)
573 if (type().byte_size == 1)
574 setAll<Vector<t_dims, uint01>>(to_location, from_location, size, from_column);
575 if (type().byte_size == 2)
576 setAll<Vector<t_dims, uint02>>(to_location, from_location, size, from_column);
577 if (type().byte_size == 4)
578 setAll<Vector<t_dims, uint04>>(to_location, from_location, size, from_column);
579 if (type().byte_size == 8)
580 setAll<Vector<t_dims, uint08>>(to_location, from_location, size, from_column);
584 if (type().byte_size == 1)
585 setAll<Vector<t_dims, sint01>>(to_location, from_location, size, from_column);
586 if (type().byte_size == 2)
587 setAll<Vector<t_dims, sint02>>(to_location, from_location, size, from_column);
588 if (type().byte_size == 4)
589 setAll<Vector<t_dims, sint04>>(to_location, from_location, size, from_column);
590 if (type().byte_size == 8)
591 setAll<Vector<t_dims, sint08>>(to_location, from_location, size, from_column);
594 else if (type().is_color)
596 setAll<RGBColor>(to_location, from_location, size, from_column);
600 lib_assert(
false,
"Table copy type not supported");
604 virtual uint08 tableHash()
const
606 uint08 result = 2166136261U;
609 for (uint01* c = start; c < stop; c++)
610 result = (127 * result) ^ *c;
#define lib_assert(expression, message)
Definition LibAssert.h:61
Logic for reading or writing to a binary file including logic for.
Definition BinaryFile.h:59
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:55
uint01 bits() const
Definition BitFlag.hpp:237
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:52
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
void setSize(t_index_type new_size)
Definition Buffer.hpp:803
decltype(auto) begin()
Definition Buffer.hpp:402
Logic for reading or writing to a file as well as navigating filesystems.
Definition File.h:48
Definition Matrix.hpp:176
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:54
The core String class for the NDEVR API.
Definition String.h:69
A virtual storage type that is used with Table class to store data where the actual mechanism for sto...
Definition TableColumn.h:76
virtual void get(uint04 index, uint04 vector_pos, uint01 &value) const =0
t_type getDefaultValue() const
Definition TableColumn.h:481
void updateAll()
Definition TableColumn.h:463
virtual void get(uint04 index, Matrix< fltp08 > &transform) const
virtual void removeIndices(const Buffer< uint04 > &offset_lookup_list)=0
virtual void get(uint04 index, Matrix< fltp04 > &transform) const
Buffer< TableChange > changesSince(const Time &time) const
String m_label
Definition TableColumn.h:616
virtual void get(uint04 index, uint04 vector_pos, sint04 &value) const =0
void insert(uint04 index, const t_type &value)
Definition TableColumn.h:395
virtual void getVector(uint04 index, Vector< 1, uint04 > &vector) const
virtual uint04 getRowSize(uint04) const
Definition TableColumn.h:85
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:350
Buffer< t_type > getAll(uint04 start, uint04 size) const
Definition TableColumn.h:490
virtual void set(uint04 index, const UUID &value)
void setVector(uint04 index, const Vector< t_dims, t_type > &value)
Definition TableColumn.h:221
std::enable_if< ObjectInfo< t_class >::Enum >::type get(uint04 index, t_class &enum_value) const
Definition TableColumn.h:254
virtual void getVector(uint04 index, Vector< 3, fltp04 > &vector) const
virtual void set(uint04 index, uint04 vector_pos, fltp04 value)=0
virtual void removeRows(uint04 index, uint04 size)=0
void set(uint04 index, const Vector< 32, bool > &value)
void setLabel(const String &label)
virtual void addRow()
Definition TableColumn.h:448
void get(uint04 index, Bounds< t_dims, t_type > &bounds) const
Definition TableColumn.h:359
virtual TableColumn * getSelected(const Buffer< bool > &selected_indices) const =0
virtual void get(uint04 index, UUID &vector) const
Definition TableColumn.h:330
virtual bool beginsWith(uint04 index, const String &value, bool ignore_case) const =0
BinaryCompressionObject & compressionObject()
Definition TableColumn.h:515
virtual bool contains(uint04 index, const char *value, bool ignore_case) const =0
virtual void set(uint04 index, sint01 value)=0
TableColumn(const String &label, const TypeInfo type)
void set(uint04 index, const Bounds< t_dims, t_type > &value)
Definition TableColumn.h:167
bool m_compression_valid
Definition TableColumn.h:621
void set(t_type *values, uint04 start_index, uint04 size)
Definition TableColumn.h:209
virtual void get(uint04 index, uint08 &value) const =0
TableColumn(const String &label)
virtual bool isSame(uint04 index, const String &value) const =0
virtual void getVector(uint04 index, Vector< 2, uint04 > &vector) const
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:375
virtual void get(uint04 index, uint04 vector_pos, uint08 &value) const =0
bool hasChangesSince(const Time &time, const Bounds< 1, uint04 > &range) const
virtual void get(uint04 index, uint04 vector_pos, sint02 &value) const =0
TypeInfo m_type
Definition TableColumn.h:617
void get(uint04 index, TranslatedString &string) const
Definition TableColumn.h:343
virtual void compressIfNeeded(BinaryCompressionObject &object)
Definition TableColumn.h:119
Time m_modified_time
Definition TableColumn.h:615
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:176
virtual void insertIndices(uint04 location, uint04 size)=0
virtual void set(uint04 index, const Matrix< fltp04 > &transform)
virtual void set(uint04 index, const Matrix< fltp08 > &transform)
virtual void set(uint04 index, uint01 value)=0
void setDefaultValue(const t_type &value)
Definition TableColumn.h:476
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:316
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:249
virtual void compress(BinaryCompressionObject &object)=0
virtual void get(uint04 index, String &value) const =0
const Buffer< TableChange > & changes() const
Definition TableColumn.h:485
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:202
virtual void set(uint04 index, uint04 vector_pos, sint04 value)=0
Buffer< TableChange > changesSince(const Time &time, const Bounds< 1, uint04 > &range) const
void clearUpdates()
Definition TableColumn.h:458
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:382
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:367
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 update(const TableChange &change)
void get(uint04 index, BitFlag &bitflag) const
Definition TableColumn.h:241
uint04 getIndexOf(const t_type &object) const
Definition TableColumn.h:263
virtual void get(uint04 index, sint08 &value) const =0
void set(uint04 index, const BitFlag &bitflag)
Definition TableColumn.h:197
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:157
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:423
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:401
virtual void set(uint04 index, uint04 vector_pos, uint08 value)=0
void setCompressionMode(CompressionMode compression_mode)
Definition TableColumn.h:272
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:614
uint08 m_compression_hash
Definition TableColumn.h:618
virtual void insert(uint04 index)=0
std::enable_if< IsVec< t_class >::value >::type set(uint04 index, const t_class &value)
Definition TableColumn.h:184
virtual void copyRow(uint04 source, uint04 destination)=0
virtual void get(uint04 index, uint04 vector_pos, sint01 &value) const =0
virtual void getVector(uint04 index, Vector< 3, uint04 > &vector) const
const String & label() const
virtual TypeInfo type() const
Definition TableColumn.h:86
virtual void getVector(uint04 index, Vector< 3, fltp08 > &vector) const
virtual void get(uint04 index, uint04 vector_pos, uint02 &value) const =0
virtual void setRowSize(uint04, uint04)
Definition TableColumn.h:84
void get(uint04 index, Time &time) const
Definition TableColumn.h:336
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 updateFrom(const TableColumn &column)
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:236
void getVector(uint04 index, Vector< t_dims, t_type > &value) const
Definition TableColumn.h:389
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:454
virtual void set(uint04 index, bool value)=0
void updateCompressionInfo(BinaryCompressionObject &object)
Definition TableColumn.h:143
Buffer< TableChange > m_changes
Definition TableColumn.h:619
virtual void get(uint04 index, uint04 vector_pos, sint08 &value) const =0
void set(uint04 index, const Time &time)
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:192
void get(uint04 index, File &file) const
Definition TableColumn.h:323
virtual const void * begin() const =0
bool compressionValid() const
Definition TableColumn.h:516
virtual void set(uint04 index, uint04 vector_pos, sint08 value)=0
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
Definition TranslatedString.h:13
A triangle is a polygon with three edges and three vertices. It is one of the basic shapes in geometr...
Definition Triangle.hpp:138
Stores information about a type, relevant for certain templated functions. To get information about a...
Definition TypeInfo.h:43
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:60
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:64
int64_t sint08
-Defines an alias representing an 8 byte, signed integer -Can represent exact integer values -9223372...
Definition BaseValues.hpp:71
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
Definition BaseValues.hpp:127
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
int8_t sint01
-Defines an alias representing a 1 byte, signed integer. -Can represent exact integer values -127 thr...
Definition BaseValues.hpp:50
CompressionMode
Logical information about the type of compression implemented or requested.
Definition Compressor.h:16
int16_t sint02
-Defines an alias representing a 2 byte, signed integer. -Can represent exact integer values -32767 t...
Definition BaseValues.hpp:57
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
Definition BaseValues.hpp:106
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:88
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
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...
Definition BaseFunctions.hpp:56
A container for storing compressed data, typically used for File IO operations. Responsible for stori...
Definition Compressor.h:52
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233
Definition Vector.hpp:768
Information about the object.
Definition ObjectInfo.h:54
Records changes to a table or column noting the bounds of the data adjusted. Useful for optimized sav...
Definition TableColumn.h:53
TableChange(TableChangeType type, uint04 start, uint04 size, Time time=Time::SystemTime())
Definition TableColumn.h:60
uint04 size
Definition TableColumn.h:68
uint04 start
Definition TableColumn.h:67
TableChangeType
Definition TableColumn.h:55
TableChangeType type
Definition TableColumn.h:69
Time time
Definition TableColumn.h:66