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