Rerun C++ SDK
Loading...
Searching...
No Matches
resolution.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/resolution.fbs".
3
4#pragma once
5
6#include "../component_descriptor.hpp"
7#include "../datatypes/vec2d.hpp"
8#include "../rerun_sdk_export.hpp"
9#include "../result.hpp"
10
11#include <array>
12#include <cstdint>
13#include <memory>
14
15namespace rerun::components {
16 /// **Component**: Pixel resolution width & height, e.g. of a camera sensor.
17 ///
18 /// Typically in integer units, but for some use cases floating point may be used.
19 struct Resolution {
20 rerun::datatypes::Vec2D resolution;
21
22 public: // START of extensions from resolution_ext.cpp:
23 /// Construct resolution from width and height floats.
24 Resolution(float width, float height) : resolution{width, height} {}
25
26 /// Construct resolution from width and height integers.
27 Resolution(int width, int height)
28 : resolution{static_cast<float>(width), static_cast<float>(height)} {}
29
30 // END of extensions from resolution_ext.cpp, start of generated code:
31
32 public:
33 Resolution() = default;
34
35 Resolution(rerun::datatypes::Vec2D resolution_) : resolution(resolution_) {}
36
37 Resolution& operator=(rerun::datatypes::Vec2D resolution_) {
38 resolution = resolution_;
39 return *this;
40 }
41
42 Resolution(std::array<float, 2> xy_) : resolution(xy_) {}
43
44 Resolution& operator=(std::array<float, 2> xy_) {
45 resolution = xy_;
46 return *this;
47 }
48
49 /// Cast to the underlying Vec2D datatype
50 operator rerun::datatypes::Vec2D() const {
51 return resolution;
52 }
53 };
54} // namespace rerun::components
55
56namespace rerun {
57 static_assert(sizeof(rerun::datatypes::Vec2D) == sizeof(components::Resolution));
58
59 /// \private
60 template <>
61 struct Loggable<components::Resolution> {
62 static constexpr ComponentDescriptor Descriptor = "rerun.components.Resolution";
63
64 /// Returns the arrow data type this type corresponds to.
65 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
66 return Loggable<rerun::datatypes::Vec2D>::arrow_datatype();
67 }
68
69 /// Serializes an array of `rerun::components::Resolution` into an arrow array.
70 static Result<std::shared_ptr<arrow::Array>> to_arrow(
71 const components::Resolution* instances, size_t num_instances
72 ) {
73 if (num_instances == 0) {
74 return Loggable<rerun::datatypes::Vec2D>::to_arrow(nullptr, 0);
75 } else if (instances == nullptr) {
76 return rerun::Error(
77 ErrorCode::UnexpectedNullArgument,
78 "Passed array instances is null when num_elements> 0."
79 );
80 } else {
81 return Loggable<rerun::datatypes::Vec2D>::to_arrow(
82 &instances->resolution,
83 num_instances
84 );
85 }
86 }
87 };
88} // namespace rerun
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: Pixel resolution width & height, e.g.
Definition resolution.hpp:19
Resolution(float width, float height)
Construct resolution from width and height floats.
Definition resolution.hpp:24
Resolution(int width, int height)
Construct resolution from width and height integers.
Definition resolution.hpp:27
Datatype: A vector in 2D space.
Definition vec2d.hpp:21