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