API Documentation
Loading...
Searching...
No Matches
Table.h
Go to the documentation of this file.
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: Database
28File: Table
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/TableColumn.h>
35#include <NDEVR/Dictionary.h>
36#include <NDEVR/Pointer.h>
37namespace NDEVR
38{
39 class BinaryFile;
40
41 /**--------------------------------------------------------------------------------------------------
42 \brief Provides access to a set of named columns all with the same number of rows. Columns can also
43 be floating, meaning they do not share the same number of rows as the table, but can still be accessed.
44 **/
46 {
47 public:
49 explicit Table(const String& name);
50 virtual ~Table();
51 bool validate() const;
52 virtual uint04 size() const;
53 void setAll(uint04 to_location, uint04 from_location, uint04 size, ConstPointer<Table> from_table);
55 virtual uint04 createChannel(const String& name, const TypeInfo& type_info, bool is_floating = false) = 0;
56 public:
57 virtual void addIndexChannel(const DynamicPointer<TableColumn>& channel);
58 virtual uint04 addChannel(const DynamicPointer<TableColumn>& channel, bool is_floating = false);
59
60 template<class t_type>
61 void set(uint04 channel_index, uint04 value_index, const t_type& value)
62 {
63 lib_assert(!m_data_channels[channel_index].isNull(), "Invalid Channel Selected");
64 m_data_channels[channel_index]->set(value_index, value);
65 }
66 template<uint01 t_dims, class t_type>
67 void set(uint04 channel_index, uint04 value_index, const Vector<t_dims, t_type>& value)
68 {
69 lib_assert(!m_data_channels[channel_index].isNull(), "Invalid Channel Selected");
70 m_data_channels[channel_index]->set(value_index, value);
71 }
72 virtual uint04 rowSize() const;
73 virtual uint04 columnSize() const;
74 void clear();
75 void setSize(uint04 size);
76 void addRow();
77 void copyRow(uint04 source, uint04 destination);
78 void copyRows(uint04 source, uint04 destination, uint04 size);
79 void appendRows(uint04 size);
80 void insertRow(uint04 index);
81 void insertRows(uint04 index, uint04 size);
82 void removeColumn(uint04 channel);
83 void removeColumn(const String& channel);
84 void removeRow(uint04 index);
85 void removeRows(uint04 index, uint04 size);
86 void removeRows(const Buffer<uint04>& sorted_romove_indices);
87 void removeRows(uint04 offset, const Buffer<bool>& remove_mask);
88 bool hasColumn(const String& column_name) const;
89 void renameColumn(uint04 column_index, const String& new_name);
90 bool hasColumn(uint04 index) const;
91 uint04 indexOf(const String& column_name) const;
92
93 const TableColumn& operator[](uint04 channel_index) const
94 {
95 return get(channel_index);
96 }
98 {
99 return get(channel_index);
100 }
101
102 const TableColumn& operator[](const String& channel) const
103 {
104 return get(channel);
105 }
107 {
108 return get(channel);
109 }
110
111 TableColumn& get(uint04 channel_index);
112 const TableColumn& get(uint04 channel_index) const;
114 {
115 return m_data_channels[channel_index];
116 }
117 TableColumn& get(const String& channel)
118 {
119 return m_name_channels[channel].get();
120 }
121 const TableColumn& get(const String& channel) const
122 {
123 return m_name_channels[channel].get();
124 }
126 {
127 return m_name_channels[channel];
128 }
129 bool hasMatchingColumns(const Table& table) const;
130
131 auto begin()
132 {
133 return m_name_channels.begin();
134 }
135
136 auto end()
137 {
138 return m_name_channels.end();
139 }
140
141 bool operator==(const Table& table) const
142 {
143 return table.m_uuid == m_uuid;
144 }
145 virtual UUID GUID() const
146 {
147 return m_uuid;
148 }
150 const String& name() const;
151 void mapToFile(BinaryFile& file, const Buffer<String>& exclusion_list = {}) const;
152 void mapFromFile(BinaryFile& file, uint08 version_number);
154 void updateAll(bool update_floating);
155 void update(const TableChange& change, bool update_floating);
156 protected:
164 };
165}
#define NDEVR_DATABASE_API
Definition DLLInfo.h:50
#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
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition GraphicsPipeline.h:42
A hash-based key-value store, useful for quick associative lookups. Key features include:
Definition Dictionary.h:61
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:320
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
void get(uint04 index, Vector< 1, t_class > &vector) const
Definition TableColumn.h:236
Provides access to a set of named columns all with the same number of rows. Columns can also be float...
Definition Table.h:46
void removeRow(uint04 index)
void setSize(uint04 size)
TableColumn & operator[](uint04 channel_index)
Definition Table.h:97
virtual UUID GUID() const
Definition Table.h:145
Table(const String &name)
Buffer< DynamicPointer< TableColumn > > m_data_channels
Definition Table.h:160
TableColumn & get(const String &channel)
Definition Table.h:117
const TableColumn & get(uint04 channel_index) const
Buffer< String > getColumnNames() const
virtual uint04 rowSize() const
const DynamicPointer< TableColumn > & getPtr(uint04 channel_index)
Definition Table.h:113
void set(uint04 channel_index, uint04 value_index, const Vector< t_dims, t_type > &value)
Definition Table.h:67
virtual uint04 size() const
const TableColumn & get(const String &channel) const
Definition Table.h:121
void mapToFile(BinaryFile &file, const Buffer< String > &exclusion_list={}) const
bool validate() const
bool hasColumn(const String &column_name) const
void removeColumn(uint04 channel)
Dictionary< String, DynamicPointer< TableColumn > > m_name_channels
Definition Table.h:158
Buffer< DynamicPointer< TableColumn > > m_index_channels
Definition Table.h:161
void copyRow(uint04 source, uint04 destination)
const TableColumn & operator[](uint04 channel_index) const
Definition Table.h:93
void mapFromFile(BinaryFile &file, uint08 version_number)
void set(uint04 channel_index, uint04 value_index, const t_type &value)
Definition Table.h:61
uint04 m_size
Definition Table.h:162
TableColumn & get(uint04 channel_index)
void setAll(uint04 to_location, uint04 from_location, uint04 size, ConstPointer< Table > from_table)
auto end()
Definition Table.h:136
void removeColumn(const String &channel)
void update(const TableChange &change, bool update_floating)
virtual uint04 addChannel(const DynamicPointer< TableColumn > &channel, bool is_floating=false)
TableColumn & operator[](const String &channel)
Definition Table.h:106
void removeRows(uint04 index, uint04 size)
bool hasColumn(uint04 index) const
void fetchDataColumns(Buffer< DynamicPointer< TableColumn > > &columns, const Buffer< String > &exclusion_list)
virtual uint04 columnSize() const
void removeRows(uint04 offset, const Buffer< bool > &remove_mask)
void renameColumn(uint04 column_index, const String &new_name)
uint04 indexOf(const String &column_name) const
virtual ~Table()
void removeRows(const Buffer< uint04 > &sorted_romove_indices)
void updateAll(bool update_floating)
void fixIndexLinking(const DynamicPointer< TableColumn > &channel)
void insertRow(uint04 index)
virtual uint04 createChannel(const String &name, const TypeInfo &type_info, bool is_floating=false)=0
const DynamicPointer< TableColumn > & getPtr(const String &channel)
Definition Table.h:125
bool operator==(const Table &table) const
Definition Table.h:141
const String & name() const
String m_name
Definition Table.h:163
virtual void addIndexChannel(const DynamicPointer< TableColumn > &channel)
const TableColumn & operator[](const String &channel) const
Definition Table.h:102
bool hasMatchingColumns(const Table &table) const
void copyRows(uint04 source, uint04 destination, uint04 size)
void insertRows(uint04 index, uint04 size)
Buffer< bool > m_is_floating
Definition Table.h:159
auto begin()
Definition Table.h:131
void appendRows(uint04 size)
UUID m_uuid
Definition Table.h:157
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
Definition ACIColor.h:37
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
Records changes to a table or column noting the bounds of the data adjusted. Useful for optimized sav...
Definition TableColumn.h:53