7 #ifndef IFM3D_FG_Buffer_H
8 #define IFM3D_FG_Buffer_H
14 #include <ifm3d/common/json.hpp>
16 #include <ifm3d/fg/frame_grabber_export.h>
17 #include <ifm3d/device/device.h>
98 class IFM3D_FRAME_GRABBER_EXPORT
Buffer
108 std::uint32_t nchannel_;
110 ifm3d::pixel_format data_format_;
112 std::size_t data_size_in_bytes_;
116 size_t bytes_per_pixel;
118 size_t bytes_per_row;
122 class BufferAllocator;
123 std::shared_ptr<BufferAllocator> buffer_allocator_;
143 Buffer(
const std::uint32_t cols,
144 const std::uint32_t rows,
145 const std::uint32_t nchannel,
146 ifm3d::pixel_format format,
147 std::optional<ifm3d::json> metadata = std::nullopt);
149 virtual ~
Buffer() =
default;
167 void create(
const std::uint32_t cols,
168 const std::uint32_t rows,
169 const std::uint32_t nchannel,
170 ifm3d::pixel_format format);
177 std::uint32_t height()
const;
178 std::uint32_t width()
const;
179 std::uint32_t nchannels()
const;
180 ifm3d::pixel_format dataFormat()
const;
190 template <
typename T = std::u
int8_t>
191 T* ptr(
const std::uint32_t row);
196 template <
typename T = std::u
int8_t>
197 T
const* ptr(
const std::uint32_t row)
const;
204 template <
typename T = std::u
int8_t>
205 T* ptr(
const std::uint32_t row,
const std::uint32_t col);
212 template <
typename T = std::u
int8_t>
213 T
const* ptr(
const std::uint32_t row,
const std::uint32_t col)
const;
219 template <
typename T>
220 T& at(
const std::size_t index);
225 template <
typename T>
226 T& at(
const std::uint32_t row,
const std::uint32_t col);
232 template <
typename T>
233 T
const& at(
const std::size_t index)
const;
238 template <
typename T>
239 T
const& at(
const std::uint32_t row,
const std::uint32_t col)
const;
247 template <
typename T>
253 template <
typename T>
256 using iterator_category = std::random_access_iterator_tag;
257 using difference_type = std::ptrdiff_t;
258 using value_type = T;
260 using reference = T&;
263 reference operator*()
const;
264 pointer operator->();
271 return a.m_ptr == b.m_ptr;
277 return a.m_ptr != b.m_ptr;
281 operator-(
const Iterator& rhs)
const noexcept
284 return this->m_ptr - rhs.m_ptr;
292 template <
typename T>
295 template <
typename T>
308 template <
typename T>
322 template <
typename Tp>
331 Buffer_(
const std::uint32_t cols,
332 const std::uint32_t rows,
333 std::optional<ifm3d::json> metadata = std::nullopt);
350 void create(
const std::uint32_t cols,
const std::uint32_t rows);
357 std::uint32_t height()
const;
358 std::uint32_t width()
const;
359 std::uint32_t nchannels()
const;
360 ifm3d::pixel_format dataFormat()
const;
366 Tp*
ptr(
const std::uint32_t row);
373 Tp*
ptr(
const std::uint32_t row,
const std::uint32_t col);
379 Tp& at(
const std::size_t index);
384 Tp& at(
const std::uint32_t row,
const std::uint32_t col);
403 template <
typename T,
int n>
407 using value_type = T;
410 template <
typename T>
413 template <
typename T>
420 static_assert(CHAR_BIT *
sizeof(
float) == 32,
"32 bit float required");
429 #include <ifm3d/fg/detail/buffer.hpp>
430 #endif // IFM3D_FG_Buffer_H