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 "../datatypes/blob.hpp"
8#include "../result.hpp"
9
10#include <cstdint>
11#include <memory>
12#include <utility>
13
14namespace rerun::components {
15 /// **Component**: A buffer that is known to store image data.
16 ///
17 /// To interpret the contents of this buffer, see, `components::ImageFormat`.
18 struct ImageBuffer {
20
21 public: // START of extensions from image_buffer_ext.cpp:
22 /// Number of bytes
23 size_t size() const {
24 return buffer.size();
25 }
26
27 // END of extensions from image_buffer_ext.cpp, start of generated code:
28
29 public:
30 ImageBuffer() = default;
31
32 ImageBuffer(rerun::datatypes::Blob buffer_) : buffer(std::move(buffer_)) {}
33
34 ImageBuffer& operator=(rerun::datatypes::Blob buffer_) {
35 buffer = std::move(buffer_);
36 return *this;
37 }
38
39 ImageBuffer(rerun::Collection<uint8_t> data_) : buffer(std::move(data_)) {}
40
41 ImageBuffer& operator=(rerun::Collection<uint8_t> data_) {
42 buffer = std::move(data_);
43 return *this;
44 }
45
46 /// Cast to the underlying Blob datatype
47 operator rerun::datatypes::Blob() const {
48 return buffer;
49 }
50 };
51} // namespace rerun::components
52
53namespace rerun {
54 static_assert(sizeof(rerun::datatypes::Blob) == sizeof(components::ImageBuffer));
55
56 /// \private
57 template <>
58 struct Loggable<components::ImageBuffer> {
59 static constexpr const char Name[] = "rerun.components.ImageBuffer";
60
61 /// Returns the arrow data type this type corresponds to.
62 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
63 return Loggable<rerun::datatypes::Blob>::arrow_datatype();
64 }
65
66 /// Serializes an array of `rerun::components::ImageBuffer` into an arrow array.
67 static Result<std::shared_ptr<arrow::Array>> to_arrow(
68 const components::ImageBuffer* instances, size_t num_instances
69 ) {
70 if (num_instances == 0) {
71 return Loggable<rerun::datatypes::Blob>::to_arrow(nullptr, 0);
72 } else if (instances == nullptr) {
73 return rerun::Error(
74 ErrorCode::UnexpectedNullArgument,
75 "Passed array instances is null when num_elements> 0."
76 );
77 } else {
78 return Loggable<rerun::datatypes::Blob>::to_arrow(
79 &instances->buffer,
80 num_instances
81 );
82 }
83 }
84 };
85} // 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:79
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:22
Component: A buffer that is known to store image data.
Definition image_buffer.hpp:18
size_t size() const
Number of bytes.
Definition image_buffer.hpp:23
Datatype: A binary blob of data.
Definition blob.hpp:21
size_t size() const
Number of bytes.
Definition blob.hpp:26