Rerun C++ SDK
Loading...
Searching...
No Matches
bar_chart.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/archetypes/bar_chart.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../components/tensor_data.hpp"
8#include "../data_cell.hpp"
9#include "../indicator_component.hpp"
10#include "../result.hpp"
11
12#include <cstdint>
13#include <utility>
14#include <vector>
15
16namespace rerun::archetypes {
17 /// **Archetype**: A bar chart.
18 ///
19 /// The x values will be the indices of the array, and the bar heights will be the provided values.
20 ///
21 /// ## Example
22 ///
23 /// ### Simple bar chart
24 /// ![image](https://static.rerun.io/barchart_simple/cf6014b18265edfcaa562c06526c0716b296b193/full.png)
25 ///
26 /// ```cpp
27 /// #include <rerun.hpp>
28 ///
29 /// int main() {
30 /// const auto rec = rerun::RecordingStream("rerun_example_bar_chart");
31 /// rec.spawn().exit_on_failure();
32 ///
33 /// rec.log("bar_chart", rerun::BarChart::i64({8, 4, 0, 9, 1, 4, 1, 6, 9, 0}));
34 /// }
35 /// ```
36 struct BarChart {
37 /// The values. Should always be a rank-1 tensor.
39
40 public:
41 static constexpr const char IndicatorComponentName[] = "rerun.components.BarChartIndicator";
42
43 /// Indicator component, used to identify the archetype when converting to a list of components.
45
46 public:
47 // Extensions to generated type defined in 'bar_chart_ext.cpp'
48
50 auto num_elems = buffer.num_elems();
51 this->values = rerun::components::TensorData({num_elems}, std::move(buffer));
52 }
53
54 // --------------------------------------------------------------------
55 // Implicit constructors:
56
57 /// Construct a `BarChart` from a `Collection<uint8_t>`.
59 : BarChart(rerun::datatypes::TensorBuffer::u8(std::move(u8))) {}
60
61 /// Construct a `BarChart` from a `Collection<uint16_t>`.
63 : BarChart(rerun::datatypes::TensorBuffer::u16(std::move(u16))) {}
64
65 /// Construct a `BarChart` from a `Collection<uint32_t>`.
67 : BarChart(rerun::datatypes::TensorBuffer::u32(std::move(u32))) {}
68
69 /// Construct a `BarChart` from a `Collection<uint64_t>`.
71 : BarChart(rerun::datatypes::TensorBuffer::u64(std::move(u64))) {}
72
73 /// Construct a `BarChart` from a `Collection<int8_t>`.
75 : BarChart(rerun::datatypes::TensorBuffer::i8(std::move(i8))) {}
76
77 /// Construct a `BarChart` from a `Collection<int16_t>`.
79 : BarChart(rerun::datatypes::TensorBuffer::i16(std::move(i16))) {}
80
81 /// Construct a `BarChart` from a `Collection<int32_t>`.
83 : BarChart(rerun::datatypes::TensorBuffer::i32(std::move(i32))) {}
84
85 /// Construct a `BarChart` from a `Collection<int64_t>`.
87 : BarChart(rerun::datatypes::TensorBuffer::i64(std::move(i64))) {}
88
89 /// Construct aBarChart` from a `Collection<half>`.
91 : BarChart(rerun::datatypes::TensorBuffer::f16(std::move(f16))) {}
92
93 /// Construct a `BarChart` from a `Collection<float>`.
95 : BarChart(rerun::datatypes::TensorBuffer::f32(std::move(f32))) {}
96
97 /// Construct a `BarChart` from a `Collection<double>`.
99 : BarChart(rerun::datatypes::TensorBuffer::f64(std::move(f64))) {}
100
101 // --------------------------------------------------------------------
102 // Explicit static constructors:
103
104 /// Construct a `BarChart` from a `Collection<uint8_t>`.
106 return BarChart(std::move(u8));
107 }
108
109 /// Construct a `BarChart` from a `Collection<uint16_t>`.
111 return BarChart(std::move(u16));
112 }
113
114 /// Construct a `BarChart` from a `Collection<uint32_t>`.
116 return BarChart(std::move(u32));
117 }
118
119 /// Construct a `BarChart` from a `Collection<uint64_t>`.
121 return BarChart(std::move(u64));
122 }
123
124 /// Construct a `BarChart` from a `Collection<int8_t>`.
126 return BarChart(std::move(i8));
127 }
128
129 /// Construct a `BarChart` from a `Collection<int16_t>`.
131 return BarChart(std::move(i16));
132 }
133
134 /// Construct a `BarChart` from a `Collection<int32_t>`.
136 return BarChart(std::move(i32));
137 }
138
139 /// Construct a `BarChart` from a `Collection<int64_t>`.
141 return BarChart(std::move(i64));
142 }
143
144 /// Construct a `BarChart` from a `Collection<half>`.
146 return BarChart(std::move(f16));
147 }
148
149 /// Construct a `BarChart` from a `Collection<float>`.
151 return BarChart(std::move(f32));
152 }
153
154 /// Construct a `BarChart` from a `Collection<double>`.
156 return BarChart(std::move(f64));
157 }
158
159 public:
160 BarChart() = default;
161 BarChart(BarChart&& other) = default;
162
163 explicit BarChart(rerun::components::TensorData _values) : values(std::move(_values)) {}
164
165 /// Returns the number of primary instances of this archetype.
166 size_t num_instances() const {
167 return 1;
168 }
169 };
170
171} // namespace rerun::archetypes
172
173namespace rerun {
174 /// \private
175 template <typename T>
176 struct AsComponents;
177
178 /// \private
179 template <>
180 struct AsComponents<archetypes::BarChart> {
181 /// Serialize all set component batches.
182 static Result<std::vector<DataCell>> serialize(const archetypes::BarChart& archetype);
183 };
184} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:47
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:66
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:20
Archetype: A bar chart.
Definition bar_chart.hpp:36
BarChart(Collection< double > f64)
Construct a BarChart from a Collection<double>.
Definition bar_chart.hpp:98
BarChart(Collection< int64_t > i64)
Construct a BarChart from a Collection<int64_t>.
Definition bar_chart.hpp:86
rerun::components::TensorData values
The values. Should always be a rank-1 tensor.
Definition bar_chart.hpp:38
static BarChart u32(Collection< uint32_t > u32)
Construct a BarChart from a Collection<uint32_t>.
Definition bar_chart.hpp:115
static BarChart f16(Collection< rerun::half > f16)
Construct a BarChart from a Collection<half>.
Definition bar_chart.hpp:145
BarChart(Collection< int32_t > i32)
Construct a BarChart from a Collection<int32_t>.
Definition bar_chart.hpp:82
static BarChart i64(Collection< int64_t > i64)
Construct a BarChart from a Collection<int64_t>.
Definition bar_chart.hpp:140
static BarChart i16(Collection< int16_t > i16)
Construct a BarChart from a Collection<int16_t>.
Definition bar_chart.hpp:130
static BarChart f64(Collection< double > f64)
Construct a BarChart from a Collection<double>.
Definition bar_chart.hpp:155
static BarChart u64(Collection< uint64_t > u64)
Construct a BarChart from a Collection<uint64_t>.
Definition bar_chart.hpp:120
static BarChart f32(Collection< float > f32)
Construct a BarChart from a Collection<float>.
Definition bar_chart.hpp:150
static BarChart u16(Collection< uint16_t > u16)
Construct a BarChart from a Collection<uint16_t>.
Definition bar_chart.hpp:110
BarChart(Collection< rerun::half > f16)
Construct aBarChartfrom aCollection<half>`.
Definition bar_chart.hpp:90
BarChart(Collection< uint16_t > u16)
Construct a BarChart from a Collection<uint16_t>.
Definition bar_chart.hpp:62
static BarChart u8(Collection< uint8_t > u8)
Construct a BarChart from a Collection<uint8_t>.
Definition bar_chart.hpp:105
BarChart(Collection< uint8_t > u8)
Construct a BarChart from a Collection<uint8_t>.
Definition bar_chart.hpp:58
BarChart(Collection< float > f32)
Construct a BarChart from a Collection<float>.
Definition bar_chart.hpp:94
BarChart(Collection< int8_t > i8)
Construct a BarChart from a Collection<int8_t>.
Definition bar_chart.hpp:74
BarChart(Collection< uint32_t > u32)
Construct a BarChart from a Collection<uint32_t>.
Definition bar_chart.hpp:66
static BarChart i32(Collection< int32_t > i32)
Construct a BarChart from a Collection<int32_t>.
Definition bar_chart.hpp:135
BarChart(Collection< uint64_t > u64)
Construct a BarChart from a Collection<uint64_t>.
Definition bar_chart.hpp:70
BarChart(Collection< int16_t > i16)
Construct a BarChart from a Collection<int16_t>.
Definition bar_chart.hpp:78
static BarChart i8(Collection< int8_t > i8)
Construct a BarChart from a Collection<int8_t>.
Definition bar_chart.hpp:125
size_t num_instances() const
Returns the number of primary instances of this archetype.
Definition bar_chart.hpp:166
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:23
Component: A multi-dimensional Tensor with optionally named arguments.
Definition tensor_data.hpp:21
Datatype: The underlying storage for a Tensor.
Definition tensor_buffer.hpp:93
size_t num_elems() const
Number of elements in the buffer.