34#include <NDEVR/TableColumn.h>
35#include <NDEVR/Dictionary.h>
36#include <NDEVR/Pointer.h>
39 template<
class t_type>
59 class NDEVR_DATABASE_API Table
71 explicit Table(
const StringView& name);
82 bool validate()
const;
95 void fixIndexLinking(TableColumn* channel);
103 template<
class t_column_type>
104 std::pair<uint04, TableColumn*> createColumn(
const StringView& name)
106 auto iter = m_name_channels.find(name);
107 if (iter != m_name_channels.end())
109 t_column_type* channel =
new t_column_type(name);
110 m_generated_channels.add(channel);
111 return { addChannel(channel), channel };
121 template<
class t_column_type,
class t_default_type>
122 std::pair<uint04, TableColumn*> createColumn(
const StringView& name,
const t_default_type& default_value)
124 auto iter = m_name_channels.find(name);
125 if (iter != m_name_channels.end())
127 t_column_type* channel =
new t_column_type(name);
128 channel->setDefault(default_value);
129 m_generated_channels.add(channel);
130 return { addChannel(channel), channel };
140 std::pair<uint04, TableColumn*> createColumn(
const StringView& name,
const TypeInfo& type_info);
147 void addIndexChannel(TableColumn* channel);
153 void link(
const Dictionary<UUID, Table*>& tables);
160 uint04 addChannel(TableColumn* channel);
172 uint04 columnSize()
const;
183 void setSize(uint04 size);
194 void resetRow(uint04 row);
201 void copyRow(uint04 source, uint04 destination);
209 void copyRows(uint04 source, uint04 destination, uint04 size);
215 void appendRows(uint04 size);
221 void insertRow(uint04 index);
228 void swapRows(uint04 a, uint04 b);
235 void swapColumns(uint04 a, uint04 b);
242 void swapColumns(TableColumn* a, TableColumn* b);
249 void insertRows(uint04 index, uint04 size);
255 void removeColumn(uint04 channel);
261 void removeColumn(TableColumn* channel);
267 void removeColumn(
const StringView& channel);
273 void removeRow(uint04 index);
280 void removeRows(uint04 index, uint04 size);
286 void removeRows(
const Buffer<uint04>& sorted_remove_indices);
293 void removeRows(uint04 offset,
const Buffer<bool>& remove_mask);
300 bool hasColumn(
const StringView& column_name)
const;
307 void renameColumn(uint04 column_index,
const StringView& new_name);
314 void renameColumn(TableColumn* column,
const StringView& new_name);
321 bool hasColumn(uint04 index)
const;
328 uint04 indexOf(
const StringView& column_name)
const;
335 uint04 indexOf(TableColumn* column)
const;
342 inline TableColumn& get(uint04 channel_index)
344 lib_assert(channel_index < m_data_channels.size() && m_data_channels[channel_index] !=
nullptr,
"Tried to access non-existent table");
345 return *m_data_channels[channel_index];
353 inline const TableColumn& get(uint04 channel_index)
const
355 lib_assert(channel_index < m_data_channels.size() && m_data_channels[channel_index] !=
nullptr,
"Tried to access non-existent table");
356 return *m_data_channels[channel_index];
364 inline TableColumn& get(
const StringView& channel)
366 return *m_name_channels.get(channel).second;
374 inline const TableColumn& get(
const StringView& channel)
const
376 return *m_name_channels.get(channel).second;
384 inline const TableColumn& operator[](uint04 channel_index)
const
386 return get(channel_index);
394 inline TableColumn& operator[](uint04 channel_index)
396 return get(channel_index);
404 template<
class t_enum_type>
405 inline const TableColumn& operator[](t_enum_type channel_index)
const
407 return get(eint04<t_enum_type>(channel_index));
416 template<
class t_enum_type>
417 inline typename std::enable_if<ObjectInfo<t_enum_type>::Enum, TableColumn&>::type operator[](t_enum_type channel_index)
419 return get(eint04<t_enum_type>(channel_index));
432 template<
class t_enum_type>
433 inline typename std::enable_if<ObjectInfo<t_enum_type>::Enum,
const TableColumn&>::type operator[](
const StringView& channel)
const
443 inline TableColumn& operator[](
const StringView& channel)
453 bool hasMatchingColumns(
const Table& table)
const;
461 return m_name_channels.begin();
470 return m_name_channels.end();
478 bool operator==(
const Table& table)
const
480 return table.m_uuid == m_uuid;
497 void fetchDataColumns(Buffer<TableColumn*>& columns,
const Set<StringAllocatingView>& exclusion_list);
503 const String&
name()
const;
509 void mapToFile(BinaryFileTableInfo& file)
const;
515 static void SkipTable(BinaryFileTableInfo& file);
521 void mapFromFile(BinaryFileTableInfo& file);
528 void finishMapFromFile(BinaryFileTableInfo& file);
534 Buffer<StringView> getColumnNames()
const;
545 void update(
const TableChange& change);
551 uint08 approximateMemorySize()
const;
560 void setAll(uint04 to_row, uint04 from_row, uint04 size,
const Table& from_table);
568 template<u
int01 t_dims>
569 std::pair<uint04, TableColumn*> createScalarChannel(
const StringView& name,
const TypeInfo& type_info);
578 void writeColumnHeaders(BinaryFileTableInfo& file,
const Buffer<uint08>& locations, uint08 start, uint08 end)
const;
587 std::pair<uint04, TableColumn*> createBufferChannel(
const StringView& name,
const TypeInfo& type_info,
bool is_floating =
false);
590 Dictionary<StringView, std::pair<uint04, TableColumn*>> m_name_channels;
591 Buffer<TableColumn*> m_data_channels;
592 Buffer<TableColumn*> m_generated_channels;
593 Buffer<TableColumn*> m_index_channels;
Container that stores unique elements in no particular order, and which allow for fast retrieval or i...
The primary namespace for the NDEVR SDK.
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...
@ name
The display name of the object.
Extended file table information for reading and writing NDV binary files.