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