IOLink IOL_v1.8.0_release
Loading...
Searching...
No Matches
DataFrameView.h
1#pragma once
2
3#include <string>
4
5#include <iolink/DataType.h>
6#include <iolink/FlagSet.h>
7#include <iolink/IOLinkAPI.h>
8#include <iolink/VectorX.h>
9#include <iolink/view/View.h>
10
11namespace iolink
12{
13
20{
21 READ = 0x1,
22 WRITE = 0x2,
23 RESHAPE = 0x4,
24};
25
26extern template class IOLINK_API_IMPORT FlagSet<DataFrameCapability>;
27
32
33// Define bitwise operators for DataFrameCapability
34IOLINK_DEFINE_ENUM_BITWISE_OPERATORS(DataFrameCapability)
35
36
46class IOLINK_API DataFrameView : public View
47{
48public:
55
61 virtual const Vector2u64& shape() const = 0;
62
72 virtual const std::string& columnName(size_t index) const = 0;
73
81 virtual size_t columnIndex(const std::string& name) const = 0;
82
90 virtual DataType columnDataType(size_t index) const = 0;
91
92 // ==== //
93 // READ //
94 // ==== //
95
120 virtual void read(size_t column, size_t offset, size_t count, void* dst) const;
121
134 template <typename T>
135 inline T at(size_t column, size_t row) const
136 {
137 T value;
138 this->read(column, row, 1, &value);
139 return value;
140 }
141
155 template <typename T>
156 inline T at(const std::string& columnName, size_t row) const
157 {
158 return this->at<T>(this->columnIndex(columnName), row);
159 }
160
161 // ===== //
162 // WRITE //
163 // ===== //
164
189 virtual void write(size_t column, size_t offset, size_t count, const void* src);
190
203 template <typename T>
204 inline void setAt(size_t column, size_t row, T value)
205 {
206 this->write(column, row, 1, &value);
207 }
208
221 template <typename T>
222 inline void setAt(const std::string& columnName, size_t row, T value)
223 {
224 this->setAt<T>(this->columnIndex(columnName), row, value);
225 }
226
227 // ======= //
228 // RESHAPE //
229 // ======= //
230
245 virtual void addColumn(const std::string& name, DataType dtype);
246
263 virtual void addRows(size_t offset, size_t count);
264
276 virtual void removeColumn(size_t index);
277
290 virtual void removeRows(size_t offset, size_t count);
291
295 std::string toString() const;
296};
297
298} // end namespace iolink