Rerun C++ SDK
Loading...
Searching...
No Matches
image_buffer.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/store/re_types/definitions/rerun/components/image_buffer.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_descriptor.hpp"
8#include "../datatypes/blob.hpp"
9#include "../result.hpp"
10
11#include <cstdint>
12#include <memory>
13#include <utility>
14
15namespace rerun::components {
16 /// **Component**: A buffer that is known to store image data.
17 ///
18 /// To interpret the contents of this buffer, see, `components::ImageFormat`.
19 struct ImageBuffer {
21
22 public: // START of extensions from image_buffer_ext.cpp:
23 /// Number of bytes
24 size_t size() const {
25 return buffer.size();
26 }
27
28 // END of extensions from image_buffer_ext.cpp, start of generated code:
29
30 public:
31 ImageBuffer() = default;
32
33 ImageBuffer(rerun::datatypes::Blob buffer_) : buffer(std::move(buffer_)) {}
34
35 ImageBuffer& operator=(rerun::datatypes::Blob buffer_) {
36 buffer = std::move(buffer_);
37 return *this;
38 }
39
40 ImageBuffer(rerun::Collection<uint8_t> data_) : buffer(std::move(data_)) {}
41
42 ImageBuffer& operator=(rerun::Collection<uint8_t> data_) {
43 buffer = std::move(data_);
44 return *this;
45 }
46
47 /// Cast to the underlying Blob datatype
48 operator rerun::datatypes::Blob() const {
49 return buffer;
50 }
51 };
52} // namespace rerun::components
53
54namespace rerun {
55 static_assert(sizeof(rerun::datatypes::Blob) == sizeof(components::ImageBuffer));
56
57 /// \private
58 template <>
59 struct Loggable<components::ImageBuffer> {
60 static constexpr ComponentDescriptor Descriptor = "rerun.components.ImageBuffer";
61
62 /// Returns the arrow data type this type corresponds to.
63 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
64 return Loggable<rerun::datatypes::Blob>::arrow_datatype();
65 }
66
67 /// Serializes an array of `rerun::components::ImageBuffer` into an arrow array.
68 static Result<std::shared_ptr<arrow::Array>> to_arrow(
69 const components::ImageBuffer* instances, size_t num_instances
70 ) {
71 if (num_instances == 0) {
72 return Loggable<rerun::datatypes::Blob>::to_arrow(nullptr, 0);
73 } else if (instances == nullptr) {
74 return rerun::Error(
75 ErrorCode::UnexpectedNullArgument,
76 "Passed array instances is null when num_elements> 0."
77 );
78 } else {
79 return Loggable<rerun::datatypes::Blob>::to_arrow(
80 &instances->buffer,
81 num_instances
82 );
83 }
84 }
85 };
86} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:95
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:80
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Component: A buffer that is known to store image data.
Definition image_buffer.hpp:19
size_t size() const
Number of bytes.
Definition image_buffer.hpp:24
Datatype: A binary blob of data.
Definition blob.hpp:22
size_t size() const
Number of bytes.
Definition blob.hpp:27