isce3 0.25.0
Loading...
Searching...
No Matches
Buffer.icc
1#ifndef ISCE_IO_GDAL_BUFFER_ICC
2#error "Buffer.icc is an implementation detail of Buffer.h"
3#endif
4
5#include <isce3/except/Error.h>
6
7namespace isce3 { namespace io { namespace gdal {
8
9constexpr
10Buffer::Buffer(const void * data,
11 GDALDataType datatype,
12 const std::array<int, 2> & shape)
13:
14 Buffer(data, datatype, shape, {shape[1] * detail::getSize(datatype), detail::getSize(datatype)})
15{}
16
17constexpr
19 GDALDataType datatype,
20 const std::array<int, 2> & shape,
21 GDALAccess access)
22:
23 Buffer(data, datatype, shape, {shape[1] * detail::getSize(datatype), detail::getSize(datatype)}, access)
24{}
25
26constexpr
27Buffer::Buffer(const void * data,
28 GDALDataType datatype,
29 const std::array<int, 2> & shape,
30 const std::array<std::size_t, 2> & strides)
31:
32 _data(const_cast<void *>(data)),
33 _datatype(datatype),
34 _shape(shape),
35 _strides(strides),
36 _access(GA_ReadOnly)
37{
38 if (shape[0] < 0 || shape[1] < 0) {
39 throw isce3::except::InvalidArgument(ISCE_SRCINFO(), "shape[n] must be >= 0");
40 }
41}
42
43constexpr
45 GDALDataType datatype,
46 const std::array<int, 2> & shape,
47 const std::array<std::size_t, 2> & strides,
48 GDALAccess access)
49:
50 _data(data),
51 _datatype(datatype),
52 _shape(shape),
53 _strides(strides),
54 _access(access)
55{
56 if (shape[0] < 0 || shape[1] < 0) {
57 throw isce3::except::InvalidArgument(ISCE_SRCINFO(), "shape[n] must be >= 0");
58 }
59}
60
61template<typename T>
62constexpr
64{
65 if (detail::Type2GDALDataType<T>::datatype != datatype()) {
66 throw isce3::except::RuntimeError(ISCE_SRCINFO(), "requested type must match the underlying data type");
67 }
68
69 return TypedBuffer<T>(static_cast<T *>(_data), _shape, _strides, _access);
70}
71
72template<typename T>
73constexpr
75 const std::array<int, 2> & shape)
76:
77 TypedBuffer(data, shape, {shape[1] * sizeof(T), sizeof(T)})
78{}
79
80template<typename T>
81constexpr
83 const std::array<int, 2> & shape,
84 GDALAccess access)
85:
86 TypedBuffer(data, shape, {shape[1] * sizeof(T), sizeof(T)}, access)
87{}
88
89template<typename T>
90constexpr
92 const std::array<int, 2> & shape,
93 const std::array<std::size_t, 2> & strides)
94:
95 _data(const_cast<T *>(data)),
96 _shape(shape),
97 _strides(strides),
98 _access(GA_ReadOnly)
99{
100 if (shape[0] < 0 || shape[1] < 0) {
101 throw isce3::except::InvalidArgument(ISCE_SRCINFO(), "shape[n] must be >= 0");
102 }
103}
104
105template<typename T>
106constexpr
108 const std::array<int, 2> & shape,
109 const std::array<std::size_t, 2> & strides,
110 GDALAccess access)
111:
112 _data(data),
113 _shape(shape),
114 _strides(strides),
115 _access(access)
116{
117 if (shape[0] < 0 || shape[1] < 0) {
118 throw isce3::except::InvalidArgument(ISCE_SRCINFO(), "shape[n] must be >= 0");
119 }
120}
121
122}}}
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 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 GDALAccess access() const
Access mode.
Definition Buffer.h:230
constexpr const std::array< int, 2 > & shape() const
Buffer dims (nrows, ncols)
Definition Buffer.h:206
constexpr T * data()
Pointer to the start of the data buffer.
Definition Buffer.h:190
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.