isce3 0.25.0
Loading...
Searching...
No Matches
Buffer.h
1#pragma once
2
3#include "forward.h"
4
5#include <array>
6#include <gdal_priv.h>
7
8#include "detail/GDALDataTypeUtil.h"
9
10namespace isce3 { namespace io { namespace gdal {
11
13class Buffer {
14public:
15
23 constexpr
24 Buffer(const void * data,
25 GDALDataType datatype,
26 const std::array<int, 2> & shape);
27
36 constexpr
37 Buffer(void * data,
38 GDALDataType datatype,
39 const std::array<int, 2> & shape,
40 GDALAccess access = GA_Update);
41
50 constexpr
51 Buffer(const void * data,
52 GDALDataType datatype,
53 const std::array<int, 2> & shape,
54 const std::array<std::size_t, 2> & strides);
55
65 constexpr
66 Buffer(void * data,
67 GDALDataType datatype,
68 const std::array<int, 2> & shape,
69 const std::array<std::size_t, 2> & strides,
70 GDALAccess access = GA_Update);
71
73 constexpr
74 void * data() { return _data; }
75
77 constexpr
78 const void * data() const { return _data; }
79
81 constexpr
82 GDALDataType datatype() const { return _datatype; }
83
85 constexpr
86 std::size_t itemsize() const { return detail::getSize(_datatype); }
87
89 constexpr
90 const std::array<int, 2> & shape() const { return _shape; }
91
93 constexpr
94 int length() const { return _shape[0]; }
95
97 constexpr
98 int width() const { return _shape[1]; }
99
101 constexpr
102 const std::array<std::size_t, 2> & strides() const { return _strides; }
103
105 constexpr
106 std::size_t rowstride() const { return _strides[0]; }
107
109 constexpr
110 std::size_t colstride() const { return _strides[1]; }
111
113 constexpr
114 GDALAccess access() const { return _access; }
115
122 template<typename T>
123 constexpr
124 TypedBuffer<T> cast() const;
125
126private:
127 void * _data;
128 GDALDataType _datatype;
129 std::array<int, 2> _shape;
130 std::array<std::size_t, 2> _strides;
131 GDALAccess _access;
132};
133
135template<typename T>
137public:
138
145 constexpr
146 TypedBuffer(const T * data,
147 const std::array<int, 2> & shape);
148
156 constexpr
157 TypedBuffer(T * data,
158 const std::array<int, 2> & shape,
159 GDALAccess access = GA_Update);
160
168 constexpr
169 TypedBuffer(const T * data,
170 const std::array<int, 2> & shape,
171 const std::array<std::size_t, 2> & strides);
172
182 constexpr
183 TypedBuffer(T * data,
184 const std::array<int, 2> & shape,
185 const std::array<std::size_t, 2> & strides,
186 GDALAccess access = GA_Update);
187
189 constexpr
190 T * data() { return _data; }
191
193 constexpr
194 const T * data() const { return _data; }
195
197 constexpr
198 GDALDataType datatype() const { return detail::Type2GDALDataType<T>::datatype; }
199
201 constexpr
202 std::size_t itemsize() const { return sizeof(T); }
203
205 constexpr
206 const std::array<int, 2> & shape() const { return _shape; }
207
209 constexpr
210 int length() const { return _shape[0]; }
211
213 constexpr
214 int width() const { return _shape[1]; }
215
217 constexpr
218 const std::array<std::size_t, 2> & strides() const { return _strides; }
219
221 constexpr
222 std::size_t rowstride() const { return _strides[0]; }
223
225 constexpr
226 std::size_t colstride() const { return _strides[1]; }
227
229 constexpr
230 GDALAccess access() const { return _access; }
231
232private:
233 T * _data;
234 std::array<int, 2> _shape;
235 std::array<std::size_t, 2> _strides;
236 GDALAccess _access;
237};
238
239}}}
240
241#define ISCE_IO_GDAL_BUFFER_ICC
242#include "Buffer.icc"
243#undef ISCE_IO_GDAL_BUFFER_ICC
constexpr std::size_t rowstride() const
Stride in bytes between the start of adjacent rows.
Definition Buffer.h:106
constexpr GDALAccess access() const
Access mode.
Definition Buffer.h:114
constexpr Buffer(const void *data, GDALDataType datatype, const std::array< int, 2 > &shape)
Create a buffer object describing a read-only row-major, contiguous data buffer.
Definition Buffer.icc:10
constexpr TypedBuffer< T > cast() const
Cast to typed buffer.
Definition Buffer.icc:63
constexpr const std::array< std::size_t, 2 > & strides() const
Stride in bytes between the start of adjacent elements along each dimension.
Definition Buffer.h:102
constexpr GDALDataType datatype() const
Datatype identifier.
Definition Buffer.h:82
constexpr std::size_t colstride() const
Stride in bytes between the start of adjacent columns.
Definition Buffer.h:110
constexpr std::size_t itemsize() const
Size in bytes of a single element.
Definition Buffer.h:86
constexpr int width() const
Number of columns.
Definition Buffer.h:98
constexpr int length() const
Number of rows.
Definition Buffer.h:94
constexpr const void * data() const
Pointer to the start of the data buffer.
Definition Buffer.h:78
constexpr void * data()
Pointer to the start of the data buffer.
Definition Buffer.h:74
constexpr const std::array< int, 2 > & shape() const
Buffer dims (nrows, ncols)
Definition Buffer.h:90
Buffer with static type information.
Definition Buffer.h:136
constexpr const std::array< std::size_t, 2 > & strides() const
Stride in bytes between the start of adjacent elements along each dimension.
Definition Buffer.h:218
constexpr std::size_t itemsize() const
Size in bytes of a single element.
Definition Buffer.h:202
constexpr const T * data() const
Pointer to the start of the data buffer.
Definition Buffer.h:194
constexpr int width() const
Number of columns.
Definition Buffer.h:214
constexpr GDALAccess access() const
Access mode.
Definition Buffer.h:230
constexpr std::size_t colstride() const
Stride in bytes between the start of adjacent columns.
Definition Buffer.h:226
constexpr const std::array< int, 2 > & shape() const
Buffer dims (nrows, ncols)
Definition Buffer.h:206
constexpr int length() const
Number of rows.
Definition Buffer.h:210
constexpr GDALDataType datatype() const
Datatype identifier.
Definition Buffer.h:198
constexpr T * data()
Pointer to the start of the data buffer.
Definition Buffer.h:190
constexpr std::size_t rowstride() const
Stride in bytes between the start of adjacent rows.
Definition Buffer.h:222
constexpr TypedBuffer(const T *data, const std::array< int, 2 > &shape)
Create a buffer object describing a read-only row-major, contiguous data buffer.
Definition Buffer.icc:74
The isce3::io namespace.
Definition Constants.h:14
base interpolator is an abstract base class
Definition BinarySearchFunc.cpp:5

Generated for ISCE3.0 by doxygen 1.13.2.