Rerun C++ SDK
Loading...
Searching...
No Matches
position2d.hpp
1// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/re_types/definitions/rerun/components/position2d.fbs".
3
4#pragma once
5
6#include "../datatypes/vec2d.hpp"
7#include "../result.hpp"
8
9#include <array>
10#include <cstdint>
11#include <memory>
12
13namespace arrow {
14 class Array;
15 class DataType;
16 class FixedSizeListBuilder;
17} // namespace arrow
18
19namespace rerun::components {
20 /// **Component**: A position in 2D space.
21 struct Position2D {
23
24 public:
25 // Extensions to generated type defined in 'position2d_ext.cpp'
26
27 /// Construct Position2D from x/y values.
28 Position2D(float x, float y) : xy{x, y} {}
29
30 float x() const {
31 return xy.x();
32 }
33
34 float y() const {
35 return xy.y();
36 }
37
38 public:
39 Position2D() = default;
40
41 Position2D(rerun::datatypes::Vec2D xy_) : xy(xy_) {}
42
43 Position2D& operator=(rerun::datatypes::Vec2D xy_) {
44 xy = xy_;
45 return *this;
46 }
47
48 Position2D(std::array<float, 2> xy_) : xy(xy_) {}
49
50 Position2D& operator=(std::array<float, 2> xy_) {
51 xy = xy_;
52 return *this;
53 }
54
55 /// Cast to the underlying Vec2D datatype
56 operator rerun::datatypes::Vec2D() const {
57 return xy;
58 }
59 };
60} // namespace rerun::components
61
62namespace rerun {
63 template <typename T>
64 struct Loggable;
65
66 /// \private
67 template <>
68 struct Loggable<components::Position2D> {
69 static constexpr const char Name[] = "rerun.components.Position2D";
70
71 /// Returns the arrow data type this type corresponds to.
72 static const std::shared_ptr<arrow::DataType>& arrow_datatype();
73
74 /// Fills an arrow array builder with an array of this type.
75 static rerun::Error fill_arrow_array_builder(
76 arrow::FixedSizeListBuilder* builder, const components::Position2D* elements,
77 size_t num_elements
78 );
79
80 /// Serializes an array of `rerun::components::Position2D` into an arrow array.
81 static Result<std::shared_ptr<arrow::Array>> to_arrow(
82 const components::Position2D* instances, size_t num_instances
83 );
84 };
85} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:87
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:69
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:20
Component: A position in 2D space.
Definition position2d.hpp:21
Position2D(float x, float y)
Construct Position2D from x/y values.
Definition position2d.hpp:28
Datatype: A vector in 2D space.
Definition vec2d.hpp:20