34#include <NDEVR/TableColumn.h>
126 [[nodiscard]]
bool isSame(
uint04 index,
const StringView& value)
const override { UNUSED(index); UNUSED(value);
return false; }
127 [[nodiscard]]
bool contains(
uint04 index,
const StringView& value,
bool ignore_case)
const override { UNUSED(index); UNUSED(value); UNUSED(ignore_case);
return false; }
128 [[nodiscard]]
bool beginsWith(
uint04 index,
const StringView& value,
bool ignore_case)
const override { UNUSED(index); UNUSED(value); UNUSED(ignore_case);
return false; }
130 template<
class t_type_a,
class t_type_b>
131 void move(
void* memory,
const t_type_b& value)
const
134 memcpy(memory, &new_value,
sizeof(t_type_a));
137 template<
class t_type_a,
class t_type_b>
138 void move(t_type_b& value,
void* memory)
const
141 memcpy(&new_value, memory,
sizeof(t_type_a));
145 template<
class t_type_a>
146 void move(
void* memory,
const String& value)
const
148 t_type_a new_value = value.getAs<t_type_a>();
149 memcpy(memory, &new_value,
sizeof(t_type_a));
152 template<
class t_type_a,
class t_type_b>
153 void get(
void* memory, t_type_b& value)
156 memcpy(&new_value, memory,
sizeof(t_type_a));
160 template<
class t_type_a>
161 void get(
void* memory, String& value)
164 memcpy(&new_value, memory,
sizeof(t_type_a));
165 value = String(new_value);
168 template<
class t_type>
169 void setMemory(
uint04 index,
uint04 vector_pos,
const t_type& value)
174 void* temp_value =
mapMemory(byte_offset,
type().total_size);
175 setMemory(temp_value, value);
179 template<
class t_type>
180 void setMemory(
void* temp_value,
const t_type& value)
182 switch (
type().byte_size)
185 if (
type().is_unsigned)
186 move<uint01>(temp_value, value);
188 move<sint01>(temp_value, value);
191 if (
type().is_unsigned)
192 move<uint02>(temp_value, value);
194 move<sint02>(temp_value, value);
198 move<fltp04>(temp_value, value);
199 else if (
type().is_unsigned)
200 move<uint04>(temp_value, value);
202 move<sint04>(temp_value, value);
206 move<fltp08>(temp_value, value);
207 else if (
type().is_unsigned)
208 move<uint08>(temp_value, value);
210 move<sint08>(temp_value, value);
213 lib_assert(
false,
"Bad type");
217 template<
class t_type>
221 switch (
type().byte_size)
224 if (
type().is_unsigned)
225 _setRawData<uint01, t_type>(data_to_insert, offset,
size);
227 _setRawData<sint01, t_type>(data_to_insert, offset,
size);
230 if (
type().is_unsigned)
231 _setRawData<uint02, t_type>(data_to_insert, offset,
size);
233 _setRawData<sint02, t_type>(data_to_insert, offset,
size);
237 _setRawData<fltp04, t_type>(data_to_insert, offset,
size);
238 else if (
type().is_unsigned)
239 _setRawData<uint04, t_type>(data_to_insert, offset,
size);
241 _setRawData<sint04, t_type>(data_to_insert, offset,
size);
245 _setRawData<fltp08, t_type>(data_to_insert, offset,
size);
246 else if (
type().is_unsigned)
247 _setRawData<uint08, t_type>(data_to_insert, offset,
size);
249 _setRawData<sint08, t_type>(data_to_insert, offset,
size);
253 _setRawData<fltp04, t_type>(data_to_insert, offset,
size);
254 else if (
type().is_unsigned)
255 _setRawData<uint04, t_type>(data_to_insert, offset,
size);
257 _setRawData<sint04, t_type>(data_to_insert, offset,
size);
260 lib_assert(
false,
"unknown type");
265 template<
class t_type>
266 void getMemory(
uint04 index,
uint04 vector_pos, t_type& value)
const
269 void* temp_value =
mapMemory(index *
type().total_size + vector_pos *
type().byte_size,
type().byte_size);
270 switch (
type().byte_size)
273 if (
type().is_unsigned)
274 move<uint01>(value, temp_value);
276 move<sint01>(value, temp_value);
279 if (
type().is_unsigned)
280 move<uint02>(value, temp_value);
282 move<sint02>(value, temp_value);
286 move<fltp04>(value, temp_value);
287 else if (
type().is_unsigned)
288 move<uint04>(value, temp_value);
290 move<sint04>(value, temp_value);
294 move<fltp08>(value, temp_value);
295 else if (
type().is_unsigned)
296 move<uint08>(value, temp_value);
298 move<sint08>(value, temp_value);
301 lib_assert(
false,
"Bad type");
306 template<
class t_type>
307 void setRawMemory(
uint04 index,
const t_type& value)
311 move<t_type>(temp_value, value);
314 template<
class t_type>
315 void getMemory(
uint04 index, t_type& value)
const
317 getMemory(index, 0, value);
319 template<
class t_type>
320 void setMemory(
uint04 index,
const t_type& value)
322 setMemory(index, 0, value);
325 void set(
uint04 index,
uint04 vector_pos,
bool value)
final override { setMemory(index, vector_pos, value); };
339 void set(
uint04 index,
bool value)
final override { setMemory(index, value); };
353 void get(
uint04 index,
uint04 vector_pos,
bool& value)
const final override { getMemory(index, vector_pos, value); };
354 void get(
uint04 index,
uint04 vector_pos,
uint01& value)
const final override { getMemory(index, vector_pos, value); };
355 void get(
uint04 index,
uint04 vector_pos,
uint02& value)
const final override { getMemory(index, vector_pos, value); };
356 void get(
uint04 index,
uint04 vector_pos,
uint04& value)
const final override { getMemory(index, vector_pos, value); };
357 void get(
uint04 index,
uint04 vector_pos,
uint08& value)
const final override { getMemory(index, vector_pos, value); };
358 void get(
uint04 index,
uint04 vector_pos,
sint01& value)
const final override { getMemory(index, vector_pos, value); };
359 void get(
uint04 index,
uint04 vector_pos,
sint02& value)
const final override { getMemory(index, vector_pos, value); };
360 void get(
uint04 index,
uint04 vector_pos,
sint04& value)
const final override { getMemory(index, vector_pos, value); };
361 void get(
uint04 index,
uint04 vector_pos,
sint08& value)
const final override { getMemory(index, vector_pos, value); };
362 void get(
uint04 index,
uint04 vector_pos,
fltp04& value)
const final override { getMemory(index, vector_pos, value); };
363 void get(
uint04 index,
uint04 vector_pos,
fltp08& value)
const final override { getMemory(index, vector_pos, value); };
365 void get(
uint04 index,
bool& value)
const final override { getMemory(index, value); };
366 void get(
uint04 index,
uint01& value)
const final override { getMemory(index, value); };
367 void get(
uint04 index,
uint02& value)
const final override { getMemory(index, value); };
368 void get(
uint04 index,
uint04& value)
const final override { getMemory(index, value); };
369 void get(
uint04 index,
uint08& value)
const final override { getMemory(index, value); };
370 void get(
uint04 index,
sint01& value)
const final override { getMemory(index, value); };
371 void get(
uint04 index,
sint02& value)
const final override { getMemory(index, value); };
372 void get(
uint04 index,
sint04& value)
const final override { getMemory(index, value); };
373 void get(
uint04 index,
sint08& value)
const final override { getMemory(index, value); };
374 void get(
uint04 index,
fltp04& value)
const final override { getMemory(index, value); };
375 void get(
uint04 index,
fltp08& value)
const final override { getMemory(index, value); };
384 lib_assert(
false,
"Not yet implemented");
391 lib_assert(
false,
"Not yet implemented");
397 lib_assert(
false,
"Not yet implemented");
403 lib_assert(
false,
"Not yet implemented");
409 lib_assert(
false,
"Not yet implemented");
415 lib_assert(
false,
"Not yet implemented");
438 template<
class t_type>
439 void setData(
const t_type*
begin,
const t_type*
end,
bool set_type,
uint04 dest_offset = 0)
451 if (insertion_type.is_number)
453 if (insertion_type.vector_size > 0)
454 size =
size * insertion_type.vector_size;
455 switch (insertion_type.byte_size)
458 if (insertion_type.is_unsigned)
464 if (insertion_type.is_unsigned)
470 if (insertion_type.is_float)
472 else if (insertion_type.is_unsigned)
478 if (insertion_type.is_float)
480 else if (insertion_type.is_unsigned)
486 if (insertion_type.is_float)
488 else if (insertion_type.is_unsigned)
494 lib_assert(
false,
"unknown buffer format");
500 lib_assert(insertion_type ==
m_type,
"unexpected vertex insertion");
501 _setRawData<t_type, t_type>(
begin, dest_offset,
size);
508 void*
begin() final {
return nullptr; };
509 void*
end() final {
return nullptr; };
511 const void*
begin() const final {
return nullptr; };
512 const void*
end() const final {
return nullptr; };
520 template<
class t_type>
525 void* data =
mapMemory(byte_offset, byte_size);
526 memcpy(data_to_get, data, byte_size);
547#pragma warning( disable : 4244)
549 template<
class t_convert_type,
class t_type>
554 void* data =
mapMemory(byte_offset, byte_size);
555 if constexpr (std::is_same<t_convert_type, t_type>())
563 t_convert_type conversion(*(
begin + i));
564 memcpy((
uint01*)(data)+
type().byte_size * i, &conversion,
sizeof(t_convert_type));
570#pragma warning( default : 4244)
The equivelent of std::vector but with a bit more control.
void get(uint04 index, uint02 &value) const final override
Retrieves a uint02 value at the given row index.
void get(uint04 index, bool &value) const final override
Retrieves a bool value at the given row index.
GraphicsBuffer(GraphicsBuffer &&buffer) noexcept
Move constructor.
void get(uint04 index, uint04 vector_pos, sint04 &value) const final override
Retrieves a sint04 value at a specific vector position within a row.
void get(uint04 index, uint01 &value) const final override
Retrieves a uint01 value at the given row index.
virtual void mapToFile(BinaryFileTableInfo &file, int compression) override
Maps this column to a binary file for serialization.
void set(uint04 index, uint04 vector_pos, sint08 value) final override
Sets a sint08 value at a specific vector position within a row.
virtual void getFromVideoCard(bool copy_existing)=0
Retrieves buffer data from the video card into CPU memory.
void get(uint04 index, sint04 &value) const final override
Retrieves a sint04 value at the given row index.
void set(uint04 index, uint04 vector_pos, sint02 value) final override
Sets a sint02 value at a specific vector position within a row.
uint08 m_size
Current number of elements in the buffer.
bool isSame(uint04 index, const StringView &value) const override
Checks whether the stored string at the given row is exactly equal to the given value.
virtual void swapIndices(uint04 a, uint04 b) override
Swaps two index entries.
bool contains(uint04 index, const StringView &value, bool ignore_case) const override
Checks whether the stored string at the given row contains the given substring.
void get(uint04 index, uint04 vector_pos, fltp08 &value) const final override
Retrieves a fltp08 value at a specific vector position within a row.
void set(uint04 index, sint04 value) final override
Sets a sint04 value at the given row index.
void set(uint04 index, uint02 value) final override
Sets a uint02 value at the given row index.
virtual void setAccessable(bool is_accessable, bool copy_existing)
Sets whether the buffer is CPU-accessible.
void get(uint04, StringView &) const final override
Retrieves a string value at the given row index as a StringView.
const void * begin() const final
Returns a const pointer to the beginning of the underlying raw data.
void get(uint04 index, RGBColor &value) const final override
Retrieves an RGBColor value at the given row index.
void get(uint04 index, sint08 &value) const final override
Retrieves a sint08 value at the given row index.
void set(uint04 index, uint04 vector_pos, bool value) final override
Sets a bool value at a specific vector position within a row.
void set(uint04 index, bool value) final override
Sets a bool value at the given row index.
void get(uint04 index, uint04 vector_pos, uint04 &value) const final override
Retrieves a uint04 value at a specific vector position within a row.
virtual void insertIndices(uint04 location, uint04 size) override
Inserts a contiguous block of index entries at the given location.
void set(uint04 index, uint01 value) final override
Sets a uint01 value at the given row index.
virtual void * mapMemory(size_t offset, size_t size) const =0
Maps a region of GPU memory for CPU access.
void set(uint04 index, uint04 vector_pos, sint04 value) final override
Sets a sint04 value at a specific vector position within a row.
GraphicsBuffer(const StringView &label)
Constructs a graphics buffer with the given label.
const StringAllocatingView getDefaultValue() const override
Returns the default value for new rows as a string representation.
virtual void swap(uint04 a, uint04 b) override
Swaps the values at two row indices.
virtual void mapToFile(BinaryFileTableInfo &file, BinaryCompressionObject &object) override
Maps this column to a binary file using compression.
uint08 m_allocated_size
Allocated capacity in elements.
virtual void updateRegion(const TableColumn &reference_data, uint04 offset, uint04 size)=0
Updates a subregion of this buffer from a source column.
void set(uint04 index, RGBColor value) final override
Sets an RGBColor value at the given row index.
void set(uint04 index, uint04 vector_pos, sint01 value) final override
Sets a sint01 value at a specific vector position within a row.
void set(uint04 index, uint04 vector_pos, uint02 value) final override
Sets a uint02 value at a specific vector position within a row.
virtual void sendToVideoCard(bool copy_existing)=0
Sends buffer data from CPU memory to the video card.
void removeIndices(const Buffer< uint04 > &offset_lookup_list) override final
Removes index entries using an offset lookup list.
Type m_internal_type
Video card usage type.
void set(uint04 index, uint04 vector_pos, uint01 value) final override
Sets a uint01 value at a specific vector position within a row.
void removeRow(uint04 index) override final
Removes a single row at the given index.
virtual void mapFromFile(BinaryFileTableInfo &file) override
Maps this column from a binary file for deserialization.
void get(uint04 index, uint04 vector_pos, fltp04 &value) const final override
Retrieves a fltp04 value at a specific vector position within a row.
void set(uint04 index, sint02 value) final override
Sets a sint02 value at the given row index.
void set(uint04 index, uint08 value) final override
Sets a uint08 value at the given row index.
virtual void copyRow(uint04 source, uint04 destination) override
Copies the value from one row to another within this column.
void get(uint04, StringAllocatingView &) const final override
Retrieves a string value at the given row index as a StringAllocatingView.
void get(uint04 index, uint04 &value) const final override
Retrieves a uint04 value at the given row index.
void get(uint04 index, uint04 vector_pos, bool &value) const final override
Retrieves a bool value at a specific vector position within a row.
bool m_is_memory_owner
Whether this buffer owns the underlying memory.
void set(uint04 index, fltp08 value) final override
Sets a fltp08 value at the given row index.
void get(uint04 index, uint04 vector_pos, uint08 &value) const final override
Retrieves a uint08 value at a specific vector position within a row.
void get(uint04, uint04, StringAllocatingView &) const final override
Retrieves a string value at a specific vector position within a row.
uint08 capacity()
Returns the allocated capacity of this buffer.
bool isAccessable() const
Checks whether the buffer is currently CPU-accessible.
void set(uint04 index, uint04 vector_pos, fltp04 value) final override
Sets a fltp04 value at a specific vector position within a row.
void get(uint04 index, sint02 &value) const final override
Retrieves a sint02 value at the given row index.
virtual void cleanup()=0
Releases video card resources associated with this buffer.
bool beginsWith(uint04 index, const StringView &value, bool ignore_case) const override
Checks whether the stored string at the given row begins with the given prefix.
void set(uint04 index, uint04 value) final override
Sets a uint04 value at the given row index.
void get(uint04 index, fltp04 &value) const final override
Retrieves a fltp04 value at the given row index.
void get(uint04 index, uint04 vector_pos, sint02 &value) const final override
Retrieves a sint02 value at a specific vector position within a row.
void set(uint04 index, uint04 vector_pos, uint08 value) final override
Sets a uint08 value at a specific vector position within a row.
void removeRows(uint04 offset, const Buffer< bool > &indices) override
Removes rows indicated by a boolean mask starting from a given offset.
const void * end() const final
Returns a const pointer to one past the end of the underlying raw data.
void get(uint04 index, sint01 &value) const final override
Retrieves a sint01 value at the given row index.
virtual void updateFrom(const TableColumn &column) override
Synchronizes this buffer from a source TableColumn.
void removeRows(uint04 index, uint04 size) override final
Removes a contiguous block of rows starting at the given index.
bool m_is_normalized
Whether values are normalized on the GPU.
virtual TypeInfo type() const override
Returns the type information for this buffer.
virtual void removeIndices(uint04 location, uint04 size) override
Removes a contiguous block of index entries at the given location.
void get(uint04 index, uint04 vector_pos, uint01 &value) const final override
Retrieves a uint01 value at a specific vector position within a row.
void * end() final
Returns a mutable pointer to one past the end of the underlying raw data.
void get(uint04 index, uint04 vector_pos, sint01 &value) const final override
Retrieves a sint01 value at a specific vector position within a row.
void set(uint04 index, uint04 vector_pos, uint04 value) final override
Sets a uint04 value at a specific vector position within a row.
virtual void copyData(const TableColumn &reference_data, bool set_type)=0
Copies data from a reference column into this buffer.
bool m_is_accessable
Whether the buffer is CPU-accessible.
uint04 size() const final override
Returns the number of rows in this column.
void * begin() final
Returns a mutable pointer to the beginning of the underlying raw data.
void get(uint04 index, fltp08 &value) const final override
Retrieves a fltp08 value at the given row index.
void set(uint04, const StringView &) final override
Sets a string value at the given row index.
virtual void unmapMemory(size_t offset, size_t size) const =0
Unmaps a previously mapped memory region.
Type
The usage type for this graphics buffer on the video card.
@ INDIRECT
Indirect draw command data.
@ INDEX
Index data for indexed drawing.
@ VERTEX
Vertex attribute data.
@ INSTANCE
Per-instance attribute data.
@ UNIFORM
Uniform (constant) data.
void get(uint04 index, uint08 &value) const final override
Retrieves a uint08 value at the given row index.
virtual void copyRows(uint04 source, uint04 destination, uint04 size) override
Copies a contiguous block of rows from one location to another within this column.
void get(uint04 index, uint04 vector_pos, sint08 &value) const final override
Retrieves a sint08 value at a specific vector position within a row.
void insert(uint04 index) override final
Inserts a default-initialized row at the given index, shifting subsequent rows.
void set(uint04 index, uint04 vector_pos, fltp08 value) final override
Sets a fltp08 value at a specific vector position within a row.
void removeRows(const Buffer< uint04 > &indices) override final
Removes multiple rows identified by a sorted list of indices.
void set(uint04 index, sint01 value) final override
Sets a sint01 value at the given row index.
void set(uint04 index, fltp04 value) final override
Sets a fltp04 value at the given row index.
virtual void compress(BinaryCompressionObject &object) override
Compresses the column data into the given compression object.
void set(uint04, uint04, const StringView &) final override
Sets a string value at a specific vector position within a row.
void set(uint04 index, sint08 value) final override
Sets a sint08 value at the given row index.
void setUsage(Type type)
Sets the video card usage type for this buffer.
void setType(const TypeInfo &type)
Sets the element type for this buffer.
TypeInfo m_type
Element type information.
virtual void setDefaultValue(const StringAllocatingView &) override
Sets the default value for new rows from a string representation.
virtual TableColumn * getSelected(const Buffer< bool > &) const override
Creates a new TableColumn containing only the rows where the corresponding selected_indices entry is ...
void get(uint04 index, uint04 vector_pos, uint02 &value) const final override
Retrieves a uint02 value at a specific vector position within a row.
Represents a color in the RGB space with optional alpha transparency.
This class is like a string view, but may optionally store the data internally Useful if the return t...
The core String View class for the NDEVR API.
const String & label() const
Returns the label (name) of this column.
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 insertRows(uint04 location, uint04 size)=0
Inserts a contiguous block of default-initialized rows at the given location.
Stores information about a type, relevant for certain templated functions.
uint02 byte_size
The size in bytes of a single element within the type.
uint04 total_size
The total size of the type in bytes.
The primary namespace for the NDEVR SDK.
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.
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.
int16_t sint02
-Defines an alias representing a 2 byte, signed integer.
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
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.
A container for storing compressed data, typically used for File IO operations.
Extended file table information for reading and writing NDV binary files.