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 /// Construct resolution from width and height floats.
23 Resolution(float width, float height) : resolution{width, height} {}
24
25 /// Construct resolution from width and height integers.
26 Resolution(int width, int height)
27 : resolution{static_cast<float>(width), static_cast<float>(height)} {}
28
29 // END of extensions from resolution_ext.cpp, start of generated code:
30
31 public:
32 Resolution() = default;
33
34 Resolution(rerun::datatypes::Vec2D resolution_) : resolution(resolution_) {}
35
36 Resolution& operator=(rerun::datatypes::Vec2D resolution_) {
37 resolution = resolution_;
38 return *this;
39 }
40
41 Resolution(std::array<float, 2> xy_) : resolution(xy_) {}
42
43 Resolution& operator=(std::array<float, 2> xy_) {
44 resolution = xy_;
45 return *this;
46 }
47
48 /// Cast to the underlying Vec2D datatype
49 operator rerun::datatypes::Vec2D() const {
50 return resolution;
51 }
52 };
53} // namespace rerun::components
54
55namespace rerun {
56 static_assert(sizeof(rerun::datatypes::Vec2D) == sizeof(components::Resolution));
57
58 /// \private
59 template <>
60 struct Loggable<components::Resolution> {
61 static constexpr std::string_view ComponentType = "rerun.components.Resolution";
62
63 /// Returns the arrow data type this type corresponds to.
64 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
65 return Loggable<rerun::datatypes::Vec2D>::arrow_datatype();
66 }
67
68 /// Serializes an array of `rerun::components::Resolution` into an arrow array.
69 static Result<std::shared_ptr<arrow::Array>> to_arrow(
70 const components::Resolution* instances, size_t num_instances
71 ) {
72 if (num_instances == 0) {
73 return Loggable<rerun::datatypes::Vec2D>::to_arrow(nullptr, 0);
74 } else if (instances == nullptr) {
75 return rerun::Error(
76 ErrorCode::UnexpectedNullArgument,
77 "Passed array instances is null when num_elements> 0."
78 );
79 } else {
80 return Loggable<rerun::datatypes::Vec2D>::to_arrow(
81 &instances->resolution,
82 num_instances
83 );
84 }
85 }
86 };
87} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:99
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:23
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:23
Resolution(int width, int height)
Construct resolution from width and height integers.
Definition resolution.hpp:26
Datatype: A vector in 2D space.
Definition vec2d.hpp:20