NDEVR
API Documentation
GraphicsBuffer.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: Graphics
28File: GraphicsBuffer
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/TableColumn.h>
35
36namespace NDEVR
37{
47 {
48 public:
58
59 public:
62 NDEVR_GRAPHICS_API GraphicsBuffer(const StringView& label);
65 NDEVR_GRAPHICS_API GraphicsBuffer(GraphicsBuffer&& buffer) noexcept;
66
69 NDEVR_GRAPHICS_API virtual TypeInfo type() const override
70 {
71 return m_type;
72 }
73
74 virtual void cleanup() = 0;
78 virtual void setAccessable(bool is_accessable, bool copy_existing)
79 {
80 if (m_allocated_size == 0)
81 {
82 m_is_accessable = is_accessable;
83 return;
84 }
85 if (m_is_accessable == is_accessable)
86 return;
87 if (!is_accessable)
88 sendToVideoCard(copy_existing);
89 else
90 getFromVideoCard(copy_existing);
91 m_is_accessable = is_accessable;
92 }
93 virtual void setDefaultValue(const StringAllocatingView&) override
94 {}
96 {
97 return StringAllocatingView();
98 }
99
101 bool isAccessable() const { return m_is_accessable; };
105 {
107 }
108 virtual void compress(BinaryCompressionObject& object) override
109 {
110 UNUSED(object);
111 }
113 {
114 UNUSED(file);
115 UNUSED(object);
116 }
117 virtual void mapToFile(BinaryFileTableInfo& file, int compression) override
118 {
119 UNUSED(file);
120 UNUSED(compression);
121 }
122 virtual void mapFromFile(BinaryFileTableInfo& file) override
123 {
124 UNUSED(file);
125 }
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; }
129 virtual TableColumn* getSelected(const Buffer<bool>&) const override { return nullptr; }
130 template<class t_type_a, class t_type_b>
131 void move(void* memory, const t_type_b& value) const
132 {
133 t_type_a new_value = cast<t_type_a>(value);
134 memcpy(memory, &new_value, sizeof(t_type_a));
135 }
136
137 template<class t_type_a, class t_type_b>
138 void move(t_type_b& value, void* memory) const
139 {
140 t_type_a new_value;
141 memcpy(&new_value, memory, sizeof(t_type_a));
142 value = cast<t_type_b>(new_value);
143 }
144
145 template<class t_type_a>
146 void move(void* memory, const String& value) const
147 {
148 t_type_a new_value = value.getAs<t_type_a>();
149 memcpy(memory, &new_value, sizeof(t_type_a));
150 }
151
152 template<class t_type_a, class t_type_b>
153 void get(void* memory, t_type_b& value)
154 {
155 t_type_a new_value;
156 memcpy(&new_value, memory, sizeof(t_type_a));
157 value = cast<t_type_b>(new_value);
158 }
159
160 template<class t_type_a>
161 void get(void* memory, String& value)
162 {
163 t_type_a new_value;
164 memcpy(&new_value, memory, sizeof(t_type_a));
165 value = String(new_value);
166 }
167
168 template<class t_type>
169 void setMemory(uint04 index, uint04 vector_pos, const t_type& value)
170 {
171 size_t byte_offset = index * type().total_size + vector_pos * type().byte_size;
172
173 lib_assert(m_is_accessable, "Tried to edit inaccessible vertex");
174 void* temp_value = mapMemory(byte_offset, type().total_size);
175 setMemory(temp_value, value);
176 unmapMemory(byte_offset, type().total_size);
177 }
178
179 template<class t_type>
180 void setMemory(void* temp_value, const t_type& value)
181 {
182 switch (type().byte_size)
183 {
184 case 1:
185 if (type().is_unsigned)
186 move<uint01>(temp_value, value);
187 else
188 move<sint01>(temp_value, value);
189 break;
190 case 2:
191 if (type().is_unsigned)
192 move<uint02>(temp_value, value);
193 else
194 move<sint02>(temp_value, value);
195 break;
196 case 4:
197 if (type().is_float)
198 move<fltp04>(temp_value, value);
199 else if (type().is_unsigned)
200 move<uint04>(temp_value, value);
201 else
202 move<sint04>(temp_value, value);
203 break;
204 case 8:
205 if (type().is_float)
206 move<fltp08>(temp_value, value);
207 else if (type().is_unsigned)
208 move<uint08>(temp_value, value);
209 else
210 move<sint08>(temp_value, value);
211 break;
212 default:
213 lib_assert(false, "Bad type");
214 }
215 }
216
217 template<class t_type>
218 void setMemory(const t_type* data_to_insert, uint04 offset, uint04 size)
219 {
220 lib_assert(m_is_accessable, "Tried to edit unaccessible vertex");
221 switch (type().byte_size)
222 {
223 case 1:
224 if (type().is_unsigned)
225 _setRawData<uint01, t_type>(data_to_insert, offset, size);
226 else
227 _setRawData<sint01, t_type>(data_to_insert, offset, size);
228 break;
229 case 2:
230 if (type().is_unsigned)
231 _setRawData<uint02, t_type>(data_to_insert, offset, size);
232 else
233 _setRawData<sint02, t_type>(data_to_insert, offset, size);
234 break;
235 case 4:
236 if (type().is_float)
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);
240 else
241 _setRawData<sint04, t_type>(data_to_insert, offset, size);
242 break;
243 case 8:
244 if (type().is_float)
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);
248 else
249 _setRawData<sint08, t_type>(data_to_insert, offset, size);
250 break;
251 case 16:
252 if (type().is_float)
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);
256 else
257 _setRawData<sint04, t_type>(data_to_insert, offset, size);
258 break;
259 default:
260 lib_assert(false, "unknown type");
261 }
262 lib_assert(m_is_accessable, "Tried to edit unaccessible vertex");
263 }
264
265 template<class t_type>
266 void getMemory(uint04 index, uint04 vector_pos, t_type& value) const
267 {
268 lib_assert(m_is_accessable, "Tried to edit unaccessible vertex");
269 void* temp_value = mapMemory(index * type().total_size + vector_pos * type().byte_size, type().byte_size);
270 switch (type().byte_size)
271 {
272 case 1:
273 if (type().is_unsigned)
274 move<uint01>(value, temp_value);
275 else
276 move<sint01>(value, temp_value);
277 break;
278 case 2:
279 if (type().is_unsigned)
280 move<uint02>(value, temp_value);
281 else
282 move<sint02>(value, temp_value);
283 break;
284 case 4:
285 if (type().is_float)
286 move<fltp04>(value, temp_value);
287 else if (type().is_unsigned)
288 move<uint04>(value, temp_value);
289 else
290 move<sint04>(value, temp_value);
291 break;
292 case 8:
293 if (type().is_float)
294 move<fltp08>(value, temp_value);
295 else if (type().is_unsigned)
296 move<uint08>(value, temp_value);
297 else
298 move<sint08>(value, temp_value);
299 break;
300 default:
301 lib_assert(false, "Bad type");
302 }
303 unmapMemory(index * type().total_size + vector_pos * type().byte_size, type().byte_size);
304 lib_assert(m_is_accessable, "Tried to edit unaccessible vertex");
305 }
306 template<class t_type>
307 void setRawMemory(uint04 index, const t_type& value)
308 {
309 lib_assert(m_is_accessable, "Tried to edit unaccessible vertex");
310 void* temp_value = mapMemory(index * type().total_size, type().total_size);
311 move<t_type>(temp_value, value);
312 unmapMemory(index * type().total_size, type().total_size);
313 }
314 template<class t_type>
315 void getMemory(uint04 index, t_type& value) const
316 {
317 getMemory(index, 0, value);
318 }
319 template<class t_type>
320 void setMemory(uint04 index, const t_type& value)
321 {
322 setMemory(index, 0, value);
323 }
324
325 void set(uint04 index, uint04 vector_pos, bool value) final override { setMemory(index, vector_pos, value); };
326 void set(uint04 index, uint04 vector_pos, uint01 value) final override { setMemory(index, vector_pos, value); };
327 void set(uint04 index, uint04 vector_pos, uint02 value) final override { setMemory(index, vector_pos, value); };
328 void set(uint04 index, uint04 vector_pos, uint04 value) final override { setMemory(index, vector_pos, value); };
329 void set(uint04 index, uint04 vector_pos, uint08 value) final override { setMemory(index, vector_pos, value); };
330 void set(uint04 index, uint04 vector_pos, sint01 value) final override { setMemory(index, vector_pos, value); };
331 void set(uint04 index, uint04 vector_pos, sint02 value) final override { setMemory(index, vector_pos, value); };
332 void set(uint04 index, uint04 vector_pos, sint04 value) final override { setMemory(index, vector_pos, value); };
333 void set(uint04 index, uint04 vector_pos, sint08 value) final override { setMemory(index, vector_pos, value); };
334 void set(uint04 index, uint04 vector_pos, fltp04 value) final override { setMemory(index, vector_pos, value); };
335 void set(uint04 index, uint04 vector_pos, fltp08 value) final override { setMemory(index, vector_pos, value); };
336
337 void set(uint04, uint04, const StringView&) final override { lib_assert(false, "unimplemented"); };
338
339 void set(uint04 index, bool value) final override { setMemory(index, value); };
340 void set(uint04 index, uint01 value) final override { setMemory(index, value); };
341 void set(uint04 index, uint02 value) final override { setMemory(index, value); };
342 void set(uint04 index, uint04 value) final override { setMemory(index, value); };
343 void set(uint04 index, uint08 value) final override { setMemory(index, value); };
344 void set(uint04 index, sint01 value) final override { setMemory(index, value); };
345 void set(uint04 index, sint02 value) final override { setMemory(index, value); };
346 void set(uint04 index, sint04 value) final override { setMemory(index, value); };
347 void set(uint04 index, sint08 value) final override { setMemory(index, value); };
348 void set(uint04 index, fltp04 value) final override { setMemory(index, value); };
349 void set(uint04 index, fltp08 value) final override { setMemory(index, value); };
350 void set(uint04, const StringView&) final override { lib_assert(false, "Unimplmented"); };
351 void set(uint04 index, RGBColor value) final override { UNUSED(index); UNUSED(value);/*setMemory(index, value);*/ };
352
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); };
364 void get(uint04, uint04, StringAllocatingView&) const final override { lib_assert(false, "unimplemented"); };
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); };
376 void get(uint04, StringView&) const final override { lib_assert(false, "unimplemented"); };
377 void get(uint04, StringAllocatingView&) const final override { lib_assert(false, "unimplemented"); };
378 void get(uint04 index, RGBColor& value) const final override { UNUSED(index); UNUSED(value);/*getMemory(index, value);*/ };
379
380 virtual void copyRow(uint04 source, uint04 destination) override
381 {
382 UNUSED(source);
383 UNUSED(destination);
384 lib_assert(false, "Not yet implemented");
385 }
386 virtual void copyRows(uint04 source, uint04 destination, uint04 size) override
387 {
388 UNUSED(source);
389 UNUSED(destination);
390 UNUSED(size);
391 lib_assert(false, "Not yet implemented");
392 }
393 virtual void insertIndices(uint04 location, uint04 size) override
394 {
395 UNUSED(location);
396 UNUSED(size);
397 lib_assert(false, "Not yet implemented");
398 }
399 virtual void removeIndices(uint04 location, uint04 size) override
400 {
401 UNUSED(location);
402 UNUSED(size);
403 lib_assert(false, "Not yet implemented");
404 }
405 virtual void swap(uint04 a, uint04 b) override
406 {
407 UNUSED(a);
408 UNUSED(b);
409 lib_assert(false, "Not yet implemented");
410 }
411 virtual void swapIndices(uint04 a, uint04 b) override
412 {
413 UNUSED(a);
414 UNUSED(b);
415 lib_assert(false, "Not yet implemented");
416 }
417 void removeIndices(const Buffer<uint04>& offset_lookup_list) override final { UNUSED(offset_lookup_list); };
418 uint04 size() const final override { return cast<uint04>(m_size); }
419
422 NDEVR_GRAPHICS_API virtual void updateFrom(const TableColumn& column) override;
423 void removeRow(uint04 index) override final { UNUSED(index); };
424 void removeRows(uint04 index, uint04 size) override final { UNUSED(index); UNUSED(size); };
425 void removeRows(const Buffer<uint04>& indices) override final { UNUSED(indices); };
426 void removeRows(uint04 offset, const Buffer<bool>& indices) override { UNUSED(offset); UNUSED(indices); }
427 void insert(uint04 index) override final { insertRows(index, 1); };
431 virtual void copyData(const TableColumn& reference_data, bool set_type) = 0;
434 NDEVR_GRAPHICS_API void setType(const TypeInfo& type);
438 template<class t_type>
439 void setData(const t_type* begin, const t_type* end, bool set_type, uint04 dest_offset = 0)
440 {
441 if (set_type && m_type != GetTypeInfo<t_type>())
442 {
443 //cleanup();
445 }
447 setSize(dest_offset + size);
448 if (size != 0)
449 {
450 TypeInfo insertion_type = GetTypeInfo<t_type>();
451 if (insertion_type.is_number)
452 {
453 if (insertion_type.vector_size > 0)
454 size = size * insertion_type.vector_size;
455 switch (insertion_type.byte_size)
456 {
457 case 1:
458 if (insertion_type.is_unsigned)
459 setMemory((uint01*)begin, dest_offset, size);
460 else
461 setMemory((sint01*)begin, dest_offset, size);
462 break;
463 case 2:
464 if (insertion_type.is_unsigned)
465 setMemory((uint02*)begin, dest_offset, size);
466 else
467 setMemory((sint02*)begin, dest_offset, size);
468 break;
469 case 4:
470 if (insertion_type.is_float)
471 setMemory((fltp04*)begin, dest_offset, size);
472 else if (insertion_type.is_unsigned)
473 setMemory((uint04*)begin, dest_offset, size);
474 else
475 setMemory((sint04*)begin, dest_offset, size);
476 break;
477 case 8:
478 if (insertion_type.is_float)
479 setMemory((fltp08*)begin, dest_offset, size);
480 else if (insertion_type.is_unsigned)
481 setMemory((uint08*)begin, dest_offset, size);
482 else
483 setMemory((sint08*)begin, dest_offset, size);
484 break;
485 case 16://
486 if (insertion_type.is_float)
487 setMemory((fltp04*)begin, dest_offset, size);
488 else if (insertion_type.is_unsigned)
489 setMemory((uint04*)begin, dest_offset, size);
490 else
491 setMemory((sint04*)begin, dest_offset, size);
492 break;
493 default:
494 lib_assert(false, "unknown buffer format");
495 break;
496 }
497 }
498 else
499 {
500 lib_assert(insertion_type == m_type, "unexpected vertex insertion");
501 _setRawData<t_type, t_type>(begin, dest_offset, size);
502 }
503 }
504 lib_assert(m_is_accessable, "Tried to edit unaccessible vertex");
505 }
506
507
508 void* begin() final { return nullptr; };
509 void* end() final { return nullptr; };
510
511 const void* begin() const final { return nullptr; };
512 const void* end() const final { return nullptr; };
513 protected:
516 virtual void getFromVideoCard(bool copy_existing) = 0;
519 virtual void sendToVideoCard(bool copy_existing) = 0;
520 template<class t_type>
521 void getData(t_type* data_to_get, uint04 offset, uint04 size)
522 {
523 size_t byte_offset = offset * type().total_size;
524 size_t byte_size = size * type().total_size;
525 void* data = mapMemory(byte_offset, byte_size);
526 memcpy(data_to_get, data, byte_size);
527 unmapMemory(byte_offset, byte_size);
528 }
529
534 virtual void* mapMemory(size_t offset, size_t size) const = 0;
538 virtual void unmapMemory(size_t offset, size_t size) const = 0;
543 virtual void updateRegion(const TableColumn& reference_data, uint04 offset, uint04 size) = 0;
544
545 private:
546#if _MSC_VER
547#pragma warning( disable : 4244)
548#endif
549 template<class t_convert_type, class t_type>
550 void _setRawData(const t_type* begin, uint04 offset, uint04 size)
551 {
552 size_t byte_offset = offset * type().byte_size;
553 size_t byte_size = size * type().byte_size;
554 void* data = mapMemory(byte_offset, byte_size);
555 if constexpr (std::is_same<t_convert_type, t_type>())
556 {
557 memcpy((uint01*)data, (uint01*)begin, byte_size);
558 }
559 else
560 {
561 for (uint04 i = 0; i < size; i++)
562 {
563 t_convert_type conversion(*(begin + i));
564 memcpy((uint01*)(data)+type().byte_size * i, &conversion, sizeof(t_convert_type));
565 }
566 }
567 unmapMemory(byte_offset, byte_size);
568 }
569#if _MSC_VER
570#pragma warning( default : 4244)
571#endif
572 protected:
580 };
581}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
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.
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
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.
Definition TypeInfo.h:43
uint02 byte_size
The size in bytes of a single element within the type.
Definition TypeInfo.h:61
uint04 total_size
The total size of the type in bytes.
Definition TypeInfo.h:60
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.
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.
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.
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.