Rerun C++ SDK
Loading...
Searching...
No Matches
bar_chart.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/archetypes/bar_chart.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/color.hpp"
10#include "../components/tensor_data.hpp"
11#include "../result.hpp"
12
13#include <cstdint>
14#include <optional>
15#include <utility>
16#include <vector>
17
18namespace rerun::archetypes {
19 /// **Archetype**: A bar chart.
20 ///
21 /// The x values will be the indices of the array, and the bar heights will be the provided values.
22 ///
23 /// ## Example
24 ///
25 /// ### Simple bar chart
26 /// ![image](https://static.rerun.io/barchart_simple/cf6014b18265edfcaa562c06526c0716b296b193/full.png)
27 ///
28 /// ```cpp
29 /// #include <rerun.hpp>
30 ///
31 /// int main() {
32 /// const auto rec = rerun::RecordingStream("rerun_example_bar_chart");
33 /// rec.spawn().exit_on_failure();
34 ///
35 /// rec.log("bar_chart", rerun::BarChart::i64({8, 4, 0, 9, 1, 4, 1, 6, 9, 0}));
36 /// }
37 /// ```
38 struct BarChart {
39 /// The values. Should always be a 1-dimensional tensor (i.e. a vector).
40 std::optional<ComponentBatch> values;
41
42 /// The color of the bar chart
43 std::optional<ComponentBatch> color;
44
45 public:
46 /// The name of the archetype as used in `ComponentDescriptor`s.
47 static constexpr const char ArchetypeName[] = "rerun.archetypes.BarChart";
48
49 /// `ComponentDescriptor` for the `values` field.
50 static constexpr auto Descriptor_values = ComponentDescriptor(
52 );
53 /// `ComponentDescriptor` for the `color` field.
54 static constexpr auto Descriptor_color = ComponentDescriptor(
56 );
57
58 public: // START of extensions from bar_chart_ext.cpp:
60 // Forwarding like this can spuriously fail, since the move might be evaluated before `num_elems`:
61 //BarChart(rerun::components::TensorData({buffer.num_elems()}, std::move(buffer)));
62
63 auto num_elems = buffer.num_elems();
64 *this = std::move(*this).with_values(
65 rerun::components::TensorData({num_elems}, std::move(buffer))
66 );
67 }
68
69 // --------------------------------------------------------------------
70 // Implicit constructors:
71
72 /// Construct a `BarChart` from a `Collection<uint8_t>`.
74 : BarChart(rerun::datatypes::TensorBuffer::u8(std::move(u8))) {}
75
76 /// Construct a `BarChart` from a `Collection<uint16_t>`.
78 : BarChart(rerun::datatypes::TensorBuffer::u16(std::move(u16))) {}
79
80 /// Construct a `BarChart` from a `Collection<uint32_t>`.
82 : BarChart(rerun::datatypes::TensorBuffer::u32(std::move(u32))) {}
83
84 /// Construct a `BarChart` from a `Collection<uint64_t>`.
86 : BarChart(rerun::datatypes::TensorBuffer::u64(std::move(u64))) {}
87
88 /// Construct a `BarChart` from a `Collection<int8_t>`.
90 : BarChart(rerun::datatypes::TensorBuffer::i8(std::move(i8))) {}
91
92 /// Construct a `BarChart` from a `Collection<int16_t>`.
94 : BarChart(rerun::datatypes::TensorBuffer::i16(std::move(i16))) {}
95
96 /// Construct a `BarChart` from a `Collection<int32_t>`.
98 : BarChart(rerun::datatypes::TensorBuffer::i32(std::move(i32))) {}
99
100 /// Construct a `BarChart` from a `Collection<int64_t>`.
102 : BarChart(rerun::datatypes::TensorBuffer::i64(std::move(i64))) {}
103
104 /// Construct aBarChart` from a `Collection<half>`.
106 : BarChart(rerun::datatypes::TensorBuffer::f16(std::move(f16))) {}
107
108 /// Construct a `BarChart` from a `Collection<float>`.
110 : BarChart(rerun::datatypes::TensorBuffer::f32(std::move(f32))) {}
111
112 /// Construct a `BarChart` from a `Collection<double>`.
114 : BarChart(rerun::datatypes::TensorBuffer::f64(std::move(f64))) {}
115
116 // --------------------------------------------------------------------
117 // Explicit static constructors:
118
119 /// Construct a `BarChart` from a `Collection<uint8_t>`.
121 return BarChart(std::move(u8));
122 }
123
124 /// Construct a `BarChart` from a `Collection<uint16_t>`.
126 return BarChart(std::move(u16));
127 }
128
129 /// Construct a `BarChart` from a `Collection<uint32_t>`.
131 return BarChart(std::move(u32));
132 }
133
134 /// Construct a `BarChart` from a `Collection<uint64_t>`.
136 return BarChart(std::move(u64));
137 }
138
139 /// Construct a `BarChart` from a `Collection<int8_t>`.
141 return BarChart(std::move(i8));
142 }
143
144 /// Construct a `BarChart` from a `Collection<int16_t>`.
146 return BarChart(std::move(i16));
147 }
148
149 /// Construct a `BarChart` from a `Collection<int32_t>`.
151 return BarChart(std::move(i32));
152 }
153
154 /// Construct a `BarChart` from a `Collection<int64_t>`.
156 return BarChart(std::move(i64));
157 }
158
159 /// Construct a `BarChart` from a `Collection<half>`.
161 return BarChart(std::move(f16));
162 }
163
164 /// Construct a `BarChart` from a `Collection<float>`.
166 return BarChart(std::move(f32));
167 }
168
169 /// Construct a `BarChart` from a `Collection<double>`.
171 return BarChart(std::move(f64));
172 }
173
174 // END of extensions from bar_chart_ext.cpp, start of generated code:
175
176 public:
177 BarChart() = default;
178 BarChart(BarChart&& other) = default;
179 BarChart(const BarChart& other) = default;
180 BarChart& operator=(const BarChart& other) = default;
181 BarChart& operator=(BarChart&& other) = default;
182
184 : values(ComponentBatch::from_loggable(std::move(_values), Descriptor_values)
185 .value_or_throw()) {}
186
187 /// Update only some specific fields of a `BarChart`.
189 return BarChart();
190 }
191
192 /// Clear all the fields of a `BarChart`.
194
195 /// The values. Should always be a 1-dimensional tensor (i.e. a vector).
197 values = ComponentBatch::from_loggable(_values, Descriptor_values).value_or_throw();
198 return std::move(*this);
199 }
200
201 /// This method makes it possible to pack multiple `values` in a single component batch.
202 ///
203 /// This only makes sense when used in conjunction with `columns`. `with_values` should
204 /// be used when logging a single row's worth of data.
206 values = ComponentBatch::from_loggable(_values, Descriptor_values).value_or_throw();
207 return std::move(*this);
208 }
209
210 /// The color of the bar chart
212 color = ComponentBatch::from_loggable(_color, Descriptor_color).value_or_throw();
213 return std::move(*this);
214 }
215
216 /// This method makes it possible to pack multiple `color` in a single component batch.
217 ///
218 /// This only makes sense when used in conjunction with `columns`. `with_color` should
219 /// be used when logging a single row's worth of data.
221 color = ComponentBatch::from_loggable(_color, Descriptor_color).value_or_throw();
222 return std::move(*this);
223 }
224
225 /// Partitions the component data into multiple sub-batches.
226 ///
227 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
228 /// instead, via `ComponentBatch::partitioned`.
229 ///
230 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
231 ///
232 /// The specified `lengths` must sum to the total length of the component batch.
234
235 /// Partitions the component data into unit-length sub-batches.
236 ///
237 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
238 /// where `n` is automatically guessed.
240 };
241
242} // namespace rerun::archetypes
243
244namespace rerun {
245 /// \private
246 template <typename T>
247 struct AsComponents;
248
249 /// \private
250 template <>
251 struct AsComponents<archetypes::BarChart> {
252 /// Serialize all set component batches.
253 static Result<Collection<ComponentBatch>> as_batches(const archetypes::BarChart& archetype);
254 };
255} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
A class for representing either a usable value, or an error.
Definition result.hpp:14
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:76
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Arrow-encoded data of a single batch of components together with a component descriptor.
Definition component_batch.hpp:28
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:46
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:16
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Archetype: A bar chart.
Definition bar_chart.hpp:38
BarChart(Collection< double > f64)
Construct a BarChart from a Collection<double>.
Definition bar_chart.hpp:113
BarChart with_many_values(const Collection< rerun::components::TensorData > &_values) &&
This method makes it possible to pack multiple values in a single component batch.
Definition bar_chart.hpp:205
BarChart(Collection< int64_t > i64)
Construct a BarChart from a Collection<int64_t>.
Definition bar_chart.hpp:101
static BarChart update_fields()
Update only some specific fields of a BarChart.
Definition bar_chart.hpp:188
static BarChart u32(Collection< uint32_t > u32)
Construct a BarChart from a Collection<uint32_t>.
Definition bar_chart.hpp:130
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
static BarChart f16(Collection< rerun::half > f16)
Construct a BarChart from a Collection<half>.
Definition bar_chart.hpp:160
static constexpr auto Descriptor_values
ComponentDescriptor for the values field.
Definition bar_chart.hpp:50
BarChart(Collection< int32_t > i32)
Construct a BarChart from a Collection<int32_t>.
Definition bar_chart.hpp:97
static BarChart i64(Collection< int64_t > i64)
Construct a BarChart from a Collection<int64_t>.
Definition bar_chart.hpp:155
static BarChart i16(Collection< int16_t > i16)
Construct a BarChart from a Collection<int16_t>.
Definition bar_chart.hpp:145
static BarChart f64(Collection< double > f64)
Construct a BarChart from a Collection<double>.
Definition bar_chart.hpp:170
static BarChart u64(Collection< uint64_t > u64)
Construct a BarChart from a Collection<uint64_t>.
Definition bar_chart.hpp:135
static BarChart f32(Collection< float > f32)
Construct a BarChart from a Collection<float>.
Definition bar_chart.hpp:165
BarChart with_color(const rerun::components::Color &_color) &&
The color of the bar chart.
Definition bar_chart.hpp:211
static BarChart u16(Collection< uint16_t > u16)
Construct a BarChart from a Collection<uint16_t>.
Definition bar_chart.hpp:125
static BarChart clear_fields()
Clear all the fields of a BarChart.
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition bar_chart.hpp:47
BarChart with_many_color(const Collection< rerun::components::Color > &_color) &&
This method makes it possible to pack multiple color in a single component batch.
Definition bar_chart.hpp:220
BarChart(Collection< rerun::half > f16)
Construct aBarChartfrom aCollection<half>`.
Definition bar_chart.hpp:105
BarChart(Collection< uint16_t > u16)
Construct a BarChart from a Collection<uint16_t>.
Definition bar_chart.hpp:77
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
static BarChart u8(Collection< uint8_t > u8)
Construct a BarChart from a Collection<uint8_t>.
Definition bar_chart.hpp:120
BarChart(Collection< uint8_t > u8)
Construct a BarChart from a Collection<uint8_t>.
Definition bar_chart.hpp:73
BarChart(Collection< float > f32)
Construct a BarChart from a Collection<float>.
Definition bar_chart.hpp:109
BarChart(Collection< int8_t > i8)
Construct a BarChart from a Collection<int8_t>.
Definition bar_chart.hpp:89
BarChart with_values(const rerun::components::TensorData &_values) &&
The values. Should always be a 1-dimensional tensor (i.e. a vector).
Definition bar_chart.hpp:196
BarChart(Collection< uint32_t > u32)
Construct a BarChart from a Collection<uint32_t>.
Definition bar_chart.hpp:81
static BarChart i32(Collection< int32_t > i32)
Construct a BarChart from a Collection<int32_t>.
Definition bar_chart.hpp:150
BarChart(Collection< uint64_t > u64)
Construct a BarChart from a Collection<uint64_t>.
Definition bar_chart.hpp:85
BarChart(Collection< int16_t > i16)
Construct a BarChart from a Collection<int16_t>.
Definition bar_chart.hpp:93
static constexpr auto Descriptor_color
ComponentDescriptor for the color field.
Definition bar_chart.hpp:54
static BarChart i8(Collection< int8_t > i8)
Construct a BarChart from a Collection<int8_t>.
Definition bar_chart.hpp:140
std::optional< ComponentBatch > color
The color of the bar chart.
Definition bar_chart.hpp:43
std::optional< ComponentBatch > values
The values. Should always be a 1-dimensional tensor (i.e. a vector).
Definition bar_chart.hpp:40
Component: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition color.hpp:17
Component: An N-dimensional array of numbers.
Definition tensor_data.hpp:22
Datatype: The underlying storage for archetypes::Tensor.
Definition tensor_buffer.hpp:98
size_t num_elems() const
Number of elements in the buffer.