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;
41 {
42 public:
43 Table();
44 explicit Table(const String& name);
45 virtual ~Table();
46 bool validate() const;
47 virtual uint04 size() const;
48 void setAll(uint04 to_location, uint04 from_location, uint04 size, ConstPointer<Table> from_table);
49 void fixIndexLinking(const DynamicPointer<TableColumn>& channel);
50 virtual uint04 createChannel(const String& name, const TypeInfo& type_info, bool is_floating = false) = 0;
51 public:
52 virtual void addIndexChannel(const DynamicPointer<TableColumn>& channel);
53 virtual uint04 addChannel(const DynamicPointer<TableColumn>& channel, bool is_floating = false);
54
55 template<class t_type>
56 void set(uint04 channel_index, uint04 value_index, const t_type& value)
57 {
58 lib_assert(!m_data_channels[channel_index].isNull(), "Invalid Channel Selected");
59 m_data_channels[channel_index]->set(value_index, value);
60 }
61 template<uint01 t_dims, class t_type>
62 void set(uint04 channel_index, uint04 value_index, const Vector<t_dims, t_type>& value)
63 {
64 lib_assert(!m_data_channels[channel_index].isNull(), "Invalid Channel Selected");
65 m_data_channels[channel_index]->set(value_index, value);
66 }
67 virtual uint04 rowSize() const;
68 virtual uint04 columnSize() const;
69 void clear();
70 void setSize(uint04 size);
71 void addRow();
72 void copyRow(uint04 source, uint04 destination);
73 void copyRows(uint04 source, uint04 destination, uint04 size);
74 void appendRows(uint04 size);
75 void insertRow(uint04 index);
76 void insertRows(uint04 index, uint04 size);
77 void removeColumn(uint04 channel);
78 void removeColumn(const String& channel);
79 void removeRow(uint04 index);
80 void removeRows(uint04 index, uint04 size);
81 void removeRows(const Buffer<uint04>& sorted_romove_indices);
82 void removeRows(uint04 offset, const Buffer<bool>& remove_mask);
83 bool hasColumn(const String& column_name) const;
84 void renameColumn(uint04 column_index, const String& new_name);
85 bool hasColumn(uint04 index) const;
86 uint04 indexOf(const String& column_name) const;
87
88 const TableColumn& operator[](uint04 channel_index) const
89 {
90 return get(channel_index);
91 }
93 {
94 return get(channel_index);
95 }
96
97 const TableColumn& operator[](const String& channel) const
98 {
99 return get(channel);
100 }
102 {
103 return get(channel);
104 }
105
106 TableColumn& get(uint04 channel_index);
107 const TableColumn& get(uint04 channel_index) const;
109 {
110 return m_data_channels[channel_index];
111 }
112 TableColumn& get(const String& channel)
113 {
114 return m_name_channels[channel].get();
115 }
116 const TableColumn& get(const String& channel) const
117 {
118 return m_name_channels[channel].get();
119 }
121 {
122 return m_name_channels[channel];
123 }
124 bool hasMatchingColumns(const Table& table) const;
125
126 auto begin()
127 {
128 return m_name_channels.begin();
129 }
130
131 auto end()
132 {
133 return m_name_channels.end();
134 }
135
136 bool operator==(const Table& table) const
137 {
138 return table.m_uuid == m_uuid;
139 }
140 virtual UUID GUID() const
141 {
142 return m_uuid;
143 }
144 void fetchDataColumns(Buffer<DynamicPointer<TableColumn>>& columns, const Buffer<String>& exclusion_list);
145 const String& name() const;
146 void mapToFile(BinaryFile& file, const Buffer<String>& exclusion_list = {}) const;
147 void mapFromFile(BinaryFile& file, uint08 version_number);
148 Buffer<String> getColumnNames() const;
149 void updateAll(bool update_floating);
150 void update(const TableChange& change, bool update_floating);
151 protected:
159 };
160}
#define NDEVR_DATABASE_API
Definition DLLInfo.h:71
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
Definition BinaryFile.h:51
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
Definition GraphicsPipeline.h:42
Definition Dictionary.h:48
Definition Pointer.hpp:303
Definition String.h:40
Definition TableColumn.h:68
void get(uint04 index, Vector< 1, t_class > &vector) const
Definition TableColumn.h:228
Definition Table.h:41
TableColumn & operator[](uint04 channel_index)
Definition Table.h:92
virtual UUID GUID() const
Definition Table.h:140
Buffer< DynamicPointer< TableColumn > > m_data_channels
Definition Table.h:155
TableColumn & get(const String &channel)
Definition Table.h:112
const DynamicPointer< TableColumn > & getPtr(uint04 channel_index)
Definition Table.h:108
void set(uint04 channel_index, uint04 value_index, const Vector< t_dims, t_type > &value)
Definition Table.h:62
const TableColumn & get(const String &channel) const
Definition Table.h:116
Dictionary< String, DynamicPointer< TableColumn > > m_name_channels
Definition Table.h:153
Buffer< DynamicPointer< TableColumn > > m_index_channels
Definition Table.h:156
const TableColumn & operator[](uint04 channel_index) const
Definition Table.h:88
void set(uint04 channel_index, uint04 value_index, const t_type &value)
Definition Table.h:56
uint04 m_size
Definition Table.h:157
auto end()
Definition Table.h:131
TableColumn & operator[](const String &channel)
Definition Table.h:101
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:120
bool operator==(const Table &table) const
Definition Table.h:136
String m_name
Definition Table.h:158
const TableColumn & operator[](const String &channel) const
Definition Table.h:97
Buffer< bool > m_is_floating
Definition Table.h:154
auto begin()
Definition Table.h:126
UUID m_uuid
Definition Table.h:152
Definition TypeInfo.h:39
Definition UUID.h:66
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120