diff --git a/crates/re_types/source_hash.txt b/crates/re_types/source_hash.txt index 218492e881fc..415e1a5e6c22 100644 --- a/crates/re_types/source_hash.txt +++ b/crates/re_types/source_hash.txt @@ -1,4 +1,4 @@ # This is a sha256 hash for all direct and indirect dependencies of this crate's build script. # It can be safely removed at anytime to force the build script to run again. # Check out build.rs to see how it's computed. -d52bf64a55c34eaf6080c0b95ef0f2407fd0c768dad400bb40a29730e8fe6921 +691d89977c42da0bd4ee074ed641969b12f7c2ef173f10bd1f2e1ee81402ed84 diff --git a/crates/re_types_builder/src/codegen/cpp/mod.rs b/crates/re_types_builder/src/codegen/cpp/mod.rs index c3065885e5b6..43d2a9d550af 100644 --- a/crates/re_types_builder/src/codegen/cpp/mod.rs +++ b/crates/re_types_builder/src/codegen/cpp/mod.rs @@ -540,7 +540,8 @@ impl QuotedObject { }); } - methods.push(archetype_to_data_cells( + methods.push(archetype_as_component_batches( + &type_ident, obj, &mut hpp_includes, &mut cpp_includes, @@ -1221,89 +1222,53 @@ fn component_to_data_cell_method( } } -fn archetype_to_data_cells( +fn archetype_as_component_batches( + type_ident: &Ident, obj: &Object, hpp_includes: &mut Includes, cpp_includes: &mut Includes, ) -> Method { hpp_includes.insert_rerun("data_cell.hpp"); - hpp_includes.insert_rerun("result.hpp"); hpp_includes.insert_rerun("arrow.hpp"); + hpp_includes.insert_rerun("component_batch.hpp"); + cpp_includes.insert_rerun("indicator_component.hpp"); hpp_includes.insert_system("vector"); // std::vector - // TODO(andreas): Splats need to be handled separately. - let num_fields = quote_integer(obj.fields.len()); - let push_cells = obj.fields.iter().map(|field| { - let field_type_fqname = match &field.typ { - Type::Vector { elem_type } => elem_type.fqname().unwrap(), - Type::Object(fqname) => fqname, - _ => unreachable!( - "Archetypes are not expected to have any fields other than objects and vectors" - ), - }; - let field_type = quote_fqname_as_type_path(cpp_includes, field_type_fqname); + let push_batches = obj.fields.iter().map(|field| { let field_name = format_ident!("{}", field.name); - if field.is_nullable { - let to_data_cell = if field.typ.is_plural() { - quote!(#field_type::to_data_cell(value.data(), value.size())) - } else { - quote!(#field_type::to_data_cell(&value, 1)) - }; quote! { if (#field_name.has_value()) { - const auto& value = #field_name.value(); - const auto result = #to_data_cell; - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(#field_name.value()); } } } else { - let to_data_cell = if field.typ.is_plural() { - quote!(#field_type::to_data_cell(#field_name.data(), #field_name.size())) - } else { - quote!(#field_type::to_data_cell(&#field_name, 1)) - }; quote! { - { - const auto result = #to_data_cell; - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + comp_batches.emplace_back(#field_name); } } }); - let indicator_fqname = format!("rerun.components.{}Indicator", obj.name); Method { - docs: "Creates a list of Rerun DataCell from this archetype.".into(), + docs: "Collections all component lists into a list of component collections. \ + *Attention:* The returned vector references this instance and does not take ownership of any data. \ + Adding any new components to this archetype will invalidate the returned component lists!".into(), declaration: MethodDeclaration { is_static: false, - return_type: quote!(Result>), - name_and_parameters: quote!(to_data_cells() const), + return_type: quote!(std::vector), + name_and_parameters: quote!(as_component_batches() const), }, definition_body: quote! { - std::vector cells; - cells.reserve(#num_fields); + std::vector comp_batches; + comp_batches.reserve(#num_fields); #NEWLINE_TOKEN #NEWLINE_TOKEN - #(#push_cells)* - { - const auto result = - create_indicator_component(#indicator_fqname, num_instances()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + #(#push_batches)* + comp_batches.emplace_back(ComponentBatch>(nullptr, num_instances())); #NEWLINE_TOKEN #NEWLINE_TOKEN - return cells; + return comp_batches; }, inline: false, } @@ -1762,11 +1727,25 @@ fn quote_constants_header_and_cpp( #NEWLINE_TOKEN #NEWLINE_TOKEN #comment - static const char* NAME + static const char NAME[] }); - cpp.push(quote!(const char* #obj_type_ident::NAME = #legacy_fqname)); + cpp.push(quote!(const char #obj_type_ident::NAME[] = #legacy_fqname)); + } + ObjectKind::Archetype => { + let indicator_fqname = + format!("{}Indicator", obj.fqname).replace("archetypes", "components"); + let comment = quote_doc_comment("Name of the indicator component, used to identify the archetype when converting to a list of components."); + hpp.push(quote! { + #NEWLINE_TOKEN + #NEWLINE_TOKEN + #comment + static const char INDICATOR_COMPONENT_NAME[] + }); + cpp.push( + quote!(const char #obj_type_ident::INDICATOR_COMPONENT_NAME[] = #indicator_fqname), + ); } - ObjectKind::Archetype | ObjectKind::Datatype => {} + ObjectKind::Datatype => {} } (hpp, cpp) diff --git a/examples/cpp/minimal/main.cpp b/examples/cpp/minimal/main.cpp index c32a3c6565e7..703c0c968a61 100644 --- a/examples/cpp/minimal/main.cpp +++ b/examples/cpp/minimal/main.cpp @@ -31,8 +31,9 @@ int main(int argc, char** argv) { // Log points with the components api - this is the advanced way of logging components in a // fine-grained matter. It supports passing various types of containers. rrc::Text c_style_array[3] = {rrc::Text("hello"), rrc::Text("friend"), rrc::Text("yo")}; - rr_stream.log_components( + rr_stream.log_component_batches( "2d/points", + 3, std::vector{rrc::Point2D(0.0f, 0.0f), rrc::Point2D(1.0f, 3.0f), rrc::Point2D(5.0f, 5.0f)}, std::array{rrc::Color(0xFF0000FF), rrc::Color(0x00FF00FF), rrc::Color(0x0000FFFF)}, c_style_array diff --git a/rerun_cpp/src/rerun/archetypes/annotation_context.cpp b/rerun_cpp/src/rerun/archetypes/annotation_context.cpp index 0993af736853..d57b644ba128 100644 --- a/rerun_cpp/src/rerun/archetypes/annotation_context.cpp +++ b/rerun_cpp/src/rerun/archetypes/annotation_context.cpp @@ -3,33 +3,27 @@ #include "annotation_context.hpp" -#include "../components/annotation_context.hpp" +#include "../indicator_component.hpp" namespace rerun { namespace archetypes { - Result> AnnotationContext::to_data_cells() const { - std::vector cells; - cells.reserve(1); + const char AnnotationContext::INDICATOR_COMPONENT_NAME[] = + "rerun.components.AnnotationContextIndicator"; - { - const auto result = rerun::components::AnnotationContext::to_data_cell(&context, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = create_indicator_component( - "rerun.components.AnnotationContextIndicator", + std::vector AnnotationContext::as_component_batches() const { + std::vector comp_batches; + comp_batches.reserve(1); + + comp_batches.emplace_back(context); + comp_batches.emplace_back( + ComponentBatch< + components::IndicatorComponent>( + nullptr, num_instances() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + ) + ); - return cells; + return comp_batches; } } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/annotation_context.hpp b/rerun_cpp/src/rerun/archetypes/annotation_context.hpp index 863a2e9ce9b1..8cd383b6cc8a 100644 --- a/rerun_cpp/src/rerun/archetypes/annotation_context.hpp +++ b/rerun_cpp/src/rerun/archetypes/annotation_context.hpp @@ -4,6 +4,7 @@ #pragma once #include "../arrow.hpp" +#include "../component_batch.hpp" #include "../components/annotation_context.hpp" #include "../data_cell.hpp" #include "../result.hpp" @@ -54,6 +55,10 @@ namespace rerun { struct AnnotationContext { rerun::components::AnnotationContext context; + /// Name of the indicator component, used to identify the archetype when converting to a + /// list of components. + static const char INDICATOR_COMPONENT_NAME[]; + public: AnnotationContext() = default; @@ -65,8 +70,11 @@ namespace rerun { return 1; } - /// Creates a list of Rerun DataCell from this archetype. - Result> to_data_cells() const; + /// Collections all component lists into a list of component collections. *Attention:* + /// The returned vector references this instance and does not take ownership of any + /// data. Adding any new components to this archetype will invalidate the returned + /// component lists! + std::vector as_component_batches() const; }; } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/arrows3d.cpp b/rerun_cpp/src/rerun/archetypes/arrows3d.cpp index 1e79a01c4a96..ed37c95385a2 100644 --- a/rerun_cpp/src/rerun/archetypes/arrows3d.cpp +++ b/rerun_cpp/src/rerun/archetypes/arrows3d.cpp @@ -3,94 +3,43 @@ #include "arrows3d.hpp" -#include "../components/class_id.hpp" -#include "../components/color.hpp" -#include "../components/instance_key.hpp" -#include "../components/origin3d.hpp" -#include "../components/radius.hpp" -#include "../components/text.hpp" -#include "../components/vector3d.hpp" +#include "../indicator_component.hpp" namespace rerun { namespace archetypes { - Result> Arrows3D::to_data_cells() const { - std::vector cells; - cells.reserve(7); + const char Arrows3D::INDICATOR_COMPONENT_NAME[] = "rerun.components.Arrows3DIndicator"; - { - const auto result = - rerun::components::Vector3D::to_data_cell(vectors.data(), vectors.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + std::vector Arrows3D::as_component_batches() const { + std::vector comp_batches; + comp_batches.reserve(7); + + comp_batches.emplace_back(vectors); if (origins.has_value()) { - const auto& value = origins.value(); - const auto result = - rerun::components::Origin3D::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(origins.value()); } if (radii.has_value()) { - const auto& value = radii.value(); - const auto result = - rerun::components::Radius::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(radii.value()); } if (colors.has_value()) { - const auto& value = colors.value(); - const auto result = - rerun::components::Color::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(colors.value()); } if (labels.has_value()) { - const auto& value = labels.value(); - const auto result = - rerun::components::Text::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(labels.value()); } if (class_ids.has_value()) { - const auto& value = class_ids.value(); - const auto result = - rerun::components::ClassId::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(class_ids.value()); } if (instance_keys.has_value()) { - const auto& value = instance_keys.value(); - const auto result = - rerun::components::InstanceKey::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(instance_keys.value()); } - { - const auto result = create_indicator_component( - "rerun.components.Arrows3DIndicator", + comp_batches.emplace_back( + ComponentBatch>( + nullptr, num_instances() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + ) + ); - return cells; + return comp_batches; } } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/arrows3d.hpp b/rerun_cpp/src/rerun/archetypes/arrows3d.hpp index 54f7913a39ae..adad5d9ade81 100644 --- a/rerun_cpp/src/rerun/archetypes/arrows3d.hpp +++ b/rerun_cpp/src/rerun/archetypes/arrows3d.hpp @@ -4,6 +4,7 @@ #pragma once #include "../arrow.hpp" +#include "../component_batch.hpp" #include "../components/class_id.hpp" #include "../components/color.hpp" #include "../components/instance_key.hpp" @@ -81,6 +82,10 @@ namespace rerun { /// Unique identifiers for each individual point in the batch. std::optional> instance_keys; + /// Name of the indicator component, used to identify the archetype when converting to a + /// list of components. + static const char INDICATOR_COMPONENT_NAME[]; + public: Arrows3D() = default; @@ -177,8 +182,11 @@ namespace rerun { return vectors.size(); } - /// Creates a list of Rerun DataCell from this archetype. - Result> to_data_cells() const; + /// Collections all component lists into a list of component collections. *Attention:* + /// The returned vector references this instance and does not take ownership of any + /// data. Adding any new components to this archetype will invalidate the returned + /// component lists! + std::vector as_component_batches() const; }; } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/depth_image.cpp b/rerun_cpp/src/rerun/archetypes/depth_image.cpp index 066ad275e5f6..549f69e83406 100644 --- a/rerun_cpp/src/rerun/archetypes/depth_image.cpp +++ b/rerun_cpp/src/rerun/archetypes/depth_image.cpp @@ -3,51 +3,32 @@ #include "depth_image.hpp" -#include "../components/depth_meter.hpp" -#include "../components/draw_order.hpp" -#include "../components/tensor_data.hpp" +#include "../indicator_component.hpp" namespace rerun { namespace archetypes { - Result> DepthImage::to_data_cells() const { - std::vector cells; - cells.reserve(3); + const char DepthImage::INDICATOR_COMPONENT_NAME[] = "rerun.components.DepthImageIndicator"; - { - const auto result = rerun::components::TensorData::to_data_cell(&data, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + std::vector DepthImage::as_component_batches() const { + std::vector comp_batches; + comp_batches.reserve(3); + + comp_batches.emplace_back(data); if (meter.has_value()) { - const auto& value = meter.value(); - const auto result = rerun::components::DepthMeter::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(meter.value()); } if (draw_order.has_value()) { - const auto& value = draw_order.value(); - const auto result = rerun::components::DrawOrder::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(draw_order.value()); } - { - const auto result = create_indicator_component( - "rerun.components.DepthImageIndicator", + comp_batches.emplace_back( + ComponentBatch< + components::IndicatorComponent>( + nullptr, num_instances() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + ) + ); - return cells; + return comp_batches; } } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/depth_image.hpp b/rerun_cpp/src/rerun/archetypes/depth_image.hpp index 8c76616b5dab..b26d4a854067 100644 --- a/rerun_cpp/src/rerun/archetypes/depth_image.hpp +++ b/rerun_cpp/src/rerun/archetypes/depth_image.hpp @@ -4,6 +4,7 @@ #pragma once #include "../arrow.hpp" +#include "../component_batch.hpp" #include "../components/depth_meter.hpp" #include "../components/draw_order.hpp" #include "../components/tensor_data.hpp" @@ -36,6 +37,10 @@ namespace rerun { /// Objects with higher values are drawn on top of those with lower values. std::optional draw_order; + /// Name of the indicator component, used to identify the archetype when converting to a + /// list of components. + static const char INDICATOR_COMPONENT_NAME[]; + public: DepthImage() = default; @@ -63,8 +68,11 @@ namespace rerun { return 1; } - /// Creates a list of Rerun DataCell from this archetype. - Result> to_data_cells() const; + /// Collections all component lists into a list of component collections. *Attention:* + /// The returned vector references this instance and does not take ownership of any + /// data. Adding any new components to this archetype will invalidate the returned + /// component lists! + std::vector as_component_batches() const; }; } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/disconnected_space.cpp b/rerun_cpp/src/rerun/archetypes/disconnected_space.cpp index 5b4666261304..ba35c6b9f796 100644 --- a/rerun_cpp/src/rerun/archetypes/disconnected_space.cpp +++ b/rerun_cpp/src/rerun/archetypes/disconnected_space.cpp @@ -3,34 +3,27 @@ #include "disconnected_space.hpp" -#include "../components/disconnected_space.hpp" +#include "../indicator_component.hpp" namespace rerun { namespace archetypes { - Result> DisconnectedSpace::to_data_cells() const { - std::vector cells; - cells.reserve(1); + const char DisconnectedSpace::INDICATOR_COMPONENT_NAME[] = + "rerun.components.DisconnectedSpaceIndicator"; - { - const auto result = - rerun::components::DisconnectedSpace::to_data_cell(&disconnected_space, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = create_indicator_component( - "rerun.components.DisconnectedSpaceIndicator", + std::vector DisconnectedSpace::as_component_batches() const { + std::vector comp_batches; + comp_batches.reserve(1); + + comp_batches.emplace_back(disconnected_space); + comp_batches.emplace_back( + ComponentBatch< + components::IndicatorComponent>( + nullptr, num_instances() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + ) + ); - return cells; + return comp_batches; } } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/disconnected_space.hpp b/rerun_cpp/src/rerun/archetypes/disconnected_space.hpp index e42320147fe1..8d4bc4cb1e13 100644 --- a/rerun_cpp/src/rerun/archetypes/disconnected_space.hpp +++ b/rerun_cpp/src/rerun/archetypes/disconnected_space.hpp @@ -4,6 +4,7 @@ #pragma once #include "../arrow.hpp" +#include "../component_batch.hpp" #include "../components/disconnected_space.hpp" #include "../data_cell.hpp" #include "../result.hpp" @@ -47,6 +48,10 @@ namespace rerun { struct DisconnectedSpace { rerun::components::DisconnectedSpace disconnected_space; + /// Name of the indicator component, used to identify the archetype when converting to a + /// list of components. + static const char INDICATOR_COMPONENT_NAME[]; + public: DisconnectedSpace() = default; @@ -58,8 +63,11 @@ namespace rerun { return 1; } - /// Creates a list of Rerun DataCell from this archetype. - Result> to_data_cells() const; + /// Collections all component lists into a list of component collections. *Attention:* + /// The returned vector references this instance and does not take ownership of any + /// data. Adding any new components to this archetype will invalidate the returned + /// component lists! + std::vector as_component_batches() const; }; } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/image.cpp b/rerun_cpp/src/rerun/archetypes/image.cpp index 858f24e8b0f2..b0a1549c2fff 100644 --- a/rerun_cpp/src/rerun/archetypes/image.cpp +++ b/rerun_cpp/src/rerun/archetypes/image.cpp @@ -3,40 +3,28 @@ #include "image.hpp" -#include "../components/draw_order.hpp" -#include "../components/tensor_data.hpp" +#include "../indicator_component.hpp" namespace rerun { namespace archetypes { - Result> Image::to_data_cells() const { - std::vector cells; - cells.reserve(2); + const char Image::INDICATOR_COMPONENT_NAME[] = "rerun.components.ImageIndicator"; - { - const auto result = rerun::components::TensorData::to_data_cell(&data, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + std::vector Image::as_component_batches() const { + std::vector comp_batches; + comp_batches.reserve(2); + + comp_batches.emplace_back(data); if (draw_order.has_value()) { - const auto& value = draw_order.value(); - const auto result = rerun::components::DrawOrder::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = - create_indicator_component("rerun.components.ImageIndicator", num_instances()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(draw_order.value()); } + comp_batches.emplace_back( + ComponentBatch>( + nullptr, + num_instances() + ) + ); - return cells; + return comp_batches; } } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/image.hpp b/rerun_cpp/src/rerun/archetypes/image.hpp index 786f5b02d049..817ef35305d1 100644 --- a/rerun_cpp/src/rerun/archetypes/image.hpp +++ b/rerun_cpp/src/rerun/archetypes/image.hpp @@ -4,6 +4,7 @@ #pragma once #include "../arrow.hpp" +#include "../component_batch.hpp" #include "../components/draw_order.hpp" #include "../components/tensor_data.hpp" #include "../data_cell.hpp" @@ -33,6 +34,10 @@ namespace rerun { /// Objects with higher values are drawn on top of those with lower values. std::optional draw_order; + /// Name of the indicator component, used to identify the archetype when converting to a + /// list of components. + static const char INDICATOR_COMPONENT_NAME[]; + public: Image() = default; @@ -50,8 +55,11 @@ namespace rerun { return 1; } - /// Creates a list of Rerun DataCell from this archetype. - Result> to_data_cells() const; + /// Collections all component lists into a list of component collections. *Attention:* + /// The returned vector references this instance and does not take ownership of any + /// data. Adding any new components to this archetype will invalidate the returned + /// component lists! + std::vector as_component_batches() const; }; } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/line_strips2d.cpp b/rerun_cpp/src/rerun/archetypes/line_strips2d.cpp index 5a9a8a61fad7..829d67f6c8ff 100644 --- a/rerun_cpp/src/rerun/archetypes/line_strips2d.cpp +++ b/rerun_cpp/src/rerun/archetypes/line_strips2d.cpp @@ -3,93 +3,45 @@ #include "line_strips2d.hpp" -#include "../components/class_id.hpp" -#include "../components/color.hpp" -#include "../components/draw_order.hpp" -#include "../components/instance_key.hpp" -#include "../components/line_strip2d.hpp" -#include "../components/radius.hpp" -#include "../components/text.hpp" +#include "../indicator_component.hpp" namespace rerun { namespace archetypes { - Result> LineStrips2D::to_data_cells() const { - std::vector cells; - cells.reserve(7); + const char LineStrips2D::INDICATOR_COMPONENT_NAME[] = + "rerun.components.LineStrips2DIndicator"; - { - const auto result = - rerun::components::LineStrip2D::to_data_cell(strips.data(), strips.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + std::vector LineStrips2D::as_component_batches() const { + std::vector comp_batches; + comp_batches.reserve(7); + + comp_batches.emplace_back(strips); if (radii.has_value()) { - const auto& value = radii.value(); - const auto result = - rerun::components::Radius::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(radii.value()); } if (colors.has_value()) { - const auto& value = colors.value(); - const auto result = - rerun::components::Color::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(colors.value()); } if (labels.has_value()) { - const auto& value = labels.value(); - const auto result = - rerun::components::Text::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(labels.value()); } if (draw_order.has_value()) { - const auto& value = draw_order.value(); - const auto result = rerun::components::DrawOrder::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(draw_order.value()); } if (class_ids.has_value()) { - const auto& value = class_ids.value(); - const auto result = - rerun::components::ClassId::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(class_ids.value()); } if (instance_keys.has_value()) { - const auto& value = instance_keys.value(); - const auto result = - rerun::components::InstanceKey::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(instance_keys.value()); } - { - const auto result = create_indicator_component( - "rerun.components.LineStrips2DIndicator", + comp_batches.emplace_back( + ComponentBatch< + components::IndicatorComponent>( + nullptr, num_instances() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + ) + ); - return cells; + return comp_batches; } } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/line_strips2d.hpp b/rerun_cpp/src/rerun/archetypes/line_strips2d.hpp index b0b4907ff8a8..923b9dde8553 100644 --- a/rerun_cpp/src/rerun/archetypes/line_strips2d.hpp +++ b/rerun_cpp/src/rerun/archetypes/line_strips2d.hpp @@ -4,6 +4,7 @@ #pragma once #include "../arrow.hpp" +#include "../component_batch.hpp" #include "../components/class_id.hpp" #include "../components/color.hpp" #include "../components/draw_order.hpp" @@ -104,6 +105,10 @@ namespace rerun { /// Unique identifiers for each individual line strip in the batch. std::optional> instance_keys; + /// Name of the indicator component, used to identify the archetype when converting to a + /// list of components. + static const char INDICATOR_COMPONENT_NAME[]; + public: LineStrips2D() = default; @@ -190,8 +195,11 @@ namespace rerun { return strips.size(); } - /// Creates a list of Rerun DataCell from this archetype. - Result> to_data_cells() const; + /// Collections all component lists into a list of component collections. *Attention:* + /// The returned vector references this instance and does not take ownership of any + /// data. Adding any new components to this archetype will invalidate the returned + /// component lists! + std::vector as_component_batches() const; }; } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/line_strips3d.cpp b/rerun_cpp/src/rerun/archetypes/line_strips3d.cpp index 92435c8625f0..78bf90a1a921 100644 --- a/rerun_cpp/src/rerun/archetypes/line_strips3d.cpp +++ b/rerun_cpp/src/rerun/archetypes/line_strips3d.cpp @@ -3,84 +3,42 @@ #include "line_strips3d.hpp" -#include "../components/class_id.hpp" -#include "../components/color.hpp" -#include "../components/instance_key.hpp" -#include "../components/line_strip3d.hpp" -#include "../components/radius.hpp" -#include "../components/text.hpp" +#include "../indicator_component.hpp" namespace rerun { namespace archetypes { - Result> LineStrips3D::to_data_cells() const { - std::vector cells; - cells.reserve(6); + const char LineStrips3D::INDICATOR_COMPONENT_NAME[] = + "rerun.components.LineStrips3DIndicator"; - { - const auto result = - rerun::components::LineStrip3D::to_data_cell(strips.data(), strips.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + std::vector LineStrips3D::as_component_batches() const { + std::vector comp_batches; + comp_batches.reserve(6); + + comp_batches.emplace_back(strips); if (radii.has_value()) { - const auto& value = radii.value(); - const auto result = - rerun::components::Radius::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(radii.value()); } if (colors.has_value()) { - const auto& value = colors.value(); - const auto result = - rerun::components::Color::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(colors.value()); } if (labels.has_value()) { - const auto& value = labels.value(); - const auto result = - rerun::components::Text::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(labels.value()); } if (class_ids.has_value()) { - const auto& value = class_ids.value(); - const auto result = - rerun::components::ClassId::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(class_ids.value()); } if (instance_keys.has_value()) { - const auto& value = instance_keys.value(); - const auto result = - rerun::components::InstanceKey::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(instance_keys.value()); } - { - const auto result = create_indicator_component( - "rerun.components.LineStrips3DIndicator", + comp_batches.emplace_back( + ComponentBatch< + components::IndicatorComponent>( + nullptr, num_instances() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + ) + ); - return cells; + return comp_batches; } } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/line_strips3d.hpp b/rerun_cpp/src/rerun/archetypes/line_strips3d.hpp index 56683b729686..f4a0fff6a867 100644 --- a/rerun_cpp/src/rerun/archetypes/line_strips3d.hpp +++ b/rerun_cpp/src/rerun/archetypes/line_strips3d.hpp @@ -4,6 +4,7 @@ #pragma once #include "../arrow.hpp" +#include "../component_batch.hpp" #include "../components/class_id.hpp" #include "../components/color.hpp" #include "../components/instance_key.hpp" @@ -111,6 +112,10 @@ namespace rerun { /// Unique identifiers for each individual line strip in the batch. std::optional> instance_keys; + /// Name of the indicator component, used to identify the archetype when converting to a + /// list of components. + static const char INDICATOR_COMPONENT_NAME[]; + public: LineStrips3D() = default; @@ -190,8 +195,11 @@ namespace rerun { return strips.size(); } - /// Creates a list of Rerun DataCell from this archetype. - Result> to_data_cells() const; + /// Collections all component lists into a list of component collections. *Attention:* + /// The returned vector references this instance and does not take ownership of any + /// data. Adding any new components to this archetype will invalidate the returned + /// component lists! + std::vector as_component_batches() const; }; } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/points2d.cpp b/rerun_cpp/src/rerun/archetypes/points2d.cpp index fec8aefb8ee6..1942ba61dabf 100644 --- a/rerun_cpp/src/rerun/archetypes/points2d.cpp +++ b/rerun_cpp/src/rerun/archetypes/points2d.cpp @@ -3,103 +3,46 @@ #include "points2d.hpp" -#include "../components/class_id.hpp" -#include "../components/color.hpp" -#include "../components/draw_order.hpp" -#include "../components/instance_key.hpp" -#include "../components/keypoint_id.hpp" -#include "../components/point2d.hpp" -#include "../components/radius.hpp" -#include "../components/text.hpp" +#include "../indicator_component.hpp" namespace rerun { namespace archetypes { - Result> Points2D::to_data_cells() const { - std::vector cells; - cells.reserve(8); + const char Points2D::INDICATOR_COMPONENT_NAME[] = "rerun.components.Points2DIndicator"; - { - const auto result = - rerun::components::Point2D::to_data_cell(points.data(), points.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + std::vector Points2D::as_component_batches() const { + std::vector comp_batches; + comp_batches.reserve(8); + + comp_batches.emplace_back(points); if (radii.has_value()) { - const auto& value = radii.value(); - const auto result = - rerun::components::Radius::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(radii.value()); } if (colors.has_value()) { - const auto& value = colors.value(); - const auto result = - rerun::components::Color::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(colors.value()); } if (labels.has_value()) { - const auto& value = labels.value(); - const auto result = - rerun::components::Text::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(labels.value()); } if (draw_order.has_value()) { - const auto& value = draw_order.value(); - const auto result = rerun::components::DrawOrder::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(draw_order.value()); } if (class_ids.has_value()) { - const auto& value = class_ids.value(); - const auto result = - rerun::components::ClassId::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(class_ids.value()); } if (keypoint_ids.has_value()) { - const auto& value = keypoint_ids.value(); - const auto result = - rerun::components::KeypointId::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(keypoint_ids.value()); } if (instance_keys.has_value()) { - const auto& value = instance_keys.value(); - const auto result = - rerun::components::InstanceKey::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(instance_keys.value()); } - { - const auto result = create_indicator_component( - "rerun.components.Points2DIndicator", + comp_batches.emplace_back( + ComponentBatch>( + nullptr, num_instances() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + ) + ); - return cells; + return comp_batches; } } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/points2d.hpp b/rerun_cpp/src/rerun/archetypes/points2d.hpp index f9ac680042cf..cd2f7553a524 100644 --- a/rerun_cpp/src/rerun/archetypes/points2d.hpp +++ b/rerun_cpp/src/rerun/archetypes/points2d.hpp @@ -4,6 +4,7 @@ #pragma once #include "../arrow.hpp" +#include "../component_batch.hpp" #include "../components/class_id.hpp" #include "../components/color.hpp" #include "../components/draw_order.hpp" @@ -57,6 +58,10 @@ namespace rerun { /// Unique identifiers for each individual point in the batch. std::optional> instance_keys; + /// Name of the indicator component, used to identify the archetype when converting to a + /// list of components. + static const char INDICATOR_COMPONENT_NAME[]; + public: Points2D() = default; @@ -166,8 +171,11 @@ namespace rerun { return points.size(); } - /// Creates a list of Rerun DataCell from this archetype. - Result> to_data_cells() const; + /// Collections all component lists into a list of component collections. *Attention:* + /// The returned vector references this instance and does not take ownership of any + /// data. Adding any new components to this archetype will invalidate the returned + /// component lists! + std::vector as_component_batches() const; }; } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/points3d.cpp b/rerun_cpp/src/rerun/archetypes/points3d.cpp index 998eae9f2428..a81397ec4ab0 100644 --- a/rerun_cpp/src/rerun/archetypes/points3d.cpp +++ b/rerun_cpp/src/rerun/archetypes/points3d.cpp @@ -3,94 +3,43 @@ #include "points3d.hpp" -#include "../components/class_id.hpp" -#include "../components/color.hpp" -#include "../components/instance_key.hpp" -#include "../components/keypoint_id.hpp" -#include "../components/point3d.hpp" -#include "../components/radius.hpp" -#include "../components/text.hpp" +#include "../indicator_component.hpp" namespace rerun { namespace archetypes { - Result> Points3D::to_data_cells() const { - std::vector cells; - cells.reserve(7); + const char Points3D::INDICATOR_COMPONENT_NAME[] = "rerun.components.Points3DIndicator"; - { - const auto result = - rerun::components::Point3D::to_data_cell(points.data(), points.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + std::vector Points3D::as_component_batches() const { + std::vector comp_batches; + comp_batches.reserve(7); + + comp_batches.emplace_back(points); if (radii.has_value()) { - const auto& value = radii.value(); - const auto result = - rerun::components::Radius::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(radii.value()); } if (colors.has_value()) { - const auto& value = colors.value(); - const auto result = - rerun::components::Color::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(colors.value()); } if (labels.has_value()) { - const auto& value = labels.value(); - const auto result = - rerun::components::Text::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(labels.value()); } if (class_ids.has_value()) { - const auto& value = class_ids.value(); - const auto result = - rerun::components::ClassId::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(class_ids.value()); } if (keypoint_ids.has_value()) { - const auto& value = keypoint_ids.value(); - const auto result = - rerun::components::KeypointId::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(keypoint_ids.value()); } if (instance_keys.has_value()) { - const auto& value = instance_keys.value(); - const auto result = - rerun::components::InstanceKey::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(instance_keys.value()); } - { - const auto result = create_indicator_component( - "rerun.components.Points3DIndicator", + comp_batches.emplace_back( + ComponentBatch>( + nullptr, num_instances() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + ) + ); - return cells; + return comp_batches; } } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/points3d.hpp b/rerun_cpp/src/rerun/archetypes/points3d.hpp index edc667ea0e4a..42d1426be8e9 100644 --- a/rerun_cpp/src/rerun/archetypes/points3d.hpp +++ b/rerun_cpp/src/rerun/archetypes/points3d.hpp @@ -4,6 +4,7 @@ #pragma once #include "../arrow.hpp" +#include "../component_batch.hpp" #include "../components/class_id.hpp" #include "../components/color.hpp" #include "../components/instance_key.hpp" @@ -69,6 +70,10 @@ namespace rerun { /// Unique identifiers for each individual point in the batch. std::optional> instance_keys; + /// Name of the indicator component, used to identify the archetype when converting to a + /// list of components. + static const char INDICATOR_COMPONENT_NAME[]; + public: Points3D() = default; @@ -171,8 +176,11 @@ namespace rerun { return points.size(); } - /// Creates a list of Rerun DataCell from this archetype. - Result> to_data_cells() const; + /// Collections all component lists into a list of component collections. *Attention:* + /// The returned vector references this instance and does not take ownership of any + /// data. Adding any new components to this archetype will invalidate the returned + /// component lists! + std::vector as_component_batches() const; }; } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/segmentation_image.cpp b/rerun_cpp/src/rerun/archetypes/segmentation_image.cpp index 84e021fbfa9b..18f0d13a7e4e 100644 --- a/rerun_cpp/src/rerun/archetypes/segmentation_image.cpp +++ b/rerun_cpp/src/rerun/archetypes/segmentation_image.cpp @@ -3,42 +3,30 @@ #include "segmentation_image.hpp" -#include "../components/draw_order.hpp" -#include "../components/tensor_data.hpp" +#include "../indicator_component.hpp" namespace rerun { namespace archetypes { - Result> SegmentationImage::to_data_cells() const { - std::vector cells; - cells.reserve(2); + const char SegmentationImage::INDICATOR_COMPONENT_NAME[] = + "rerun.components.SegmentationImageIndicator"; - { - const auto result = rerun::components::TensorData::to_data_cell(&data, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + std::vector SegmentationImage::as_component_batches() const { + std::vector comp_batches; + comp_batches.reserve(2); + + comp_batches.emplace_back(data); if (draw_order.has_value()) { - const auto& value = draw_order.value(); - const auto result = rerun::components::DrawOrder::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(draw_order.value()); } - { - const auto result = create_indicator_component( - "rerun.components.SegmentationImageIndicator", + comp_batches.emplace_back( + ComponentBatch< + components::IndicatorComponent>( + nullptr, num_instances() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + ) + ); - return cells; + return comp_batches; } } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/segmentation_image.hpp b/rerun_cpp/src/rerun/archetypes/segmentation_image.hpp index b3bed0299d8b..649860bcdc99 100644 --- a/rerun_cpp/src/rerun/archetypes/segmentation_image.hpp +++ b/rerun_cpp/src/rerun/archetypes/segmentation_image.hpp @@ -4,6 +4,7 @@ #pragma once #include "../arrow.hpp" +#include "../component_batch.hpp" #include "../components/draw_order.hpp" #include "../components/tensor_data.hpp" #include "../data_cell.hpp" @@ -31,6 +32,10 @@ namespace rerun { /// Objects with higher values are drawn on top of those with lower values. std::optional draw_order; + /// Name of the indicator component, used to identify the archetype when converting to a + /// list of components. + static const char INDICATOR_COMPONENT_NAME[]; + public: SegmentationImage() = default; @@ -48,8 +53,11 @@ namespace rerun { return 1; } - /// Creates a list of Rerun DataCell from this archetype. - Result> to_data_cells() const; + /// Collections all component lists into a list of component collections. *Attention:* + /// The returned vector references this instance and does not take ownership of any + /// data. Adding any new components to this archetype will invalidate the returned + /// component lists! + std::vector as_component_batches() const; }; } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/tensor.cpp b/rerun_cpp/src/rerun/archetypes/tensor.cpp index 1fd099de86b1..7e8ce5baf58f 100644 --- a/rerun_cpp/src/rerun/archetypes/tensor.cpp +++ b/rerun_cpp/src/rerun/archetypes/tensor.cpp @@ -3,31 +3,25 @@ #include "tensor.hpp" -#include "../components/tensor_data.hpp" +#include "../indicator_component.hpp" namespace rerun { namespace archetypes { - Result> Tensor::to_data_cells() const { - std::vector cells; - cells.reserve(1); + const char Tensor::INDICATOR_COMPONENT_NAME[] = "rerun.components.TensorIndicator"; - { - const auto result = rerun::components::TensorData::to_data_cell(&data, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = - create_indicator_component("rerun.components.TensorIndicator", num_instances()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + std::vector Tensor::as_component_batches() const { + std::vector comp_batches; + comp_batches.reserve(1); - return cells; + comp_batches.emplace_back(data); + comp_batches.emplace_back( + ComponentBatch>( + nullptr, + num_instances() + ) + ); + + return comp_batches; } } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/tensor.hpp b/rerun_cpp/src/rerun/archetypes/tensor.hpp index 3044a5e4c7dd..cba6f5da3e00 100644 --- a/rerun_cpp/src/rerun/archetypes/tensor.hpp +++ b/rerun_cpp/src/rerun/archetypes/tensor.hpp @@ -4,6 +4,7 @@ #pragma once #include "../arrow.hpp" +#include "../component_batch.hpp" #include "../components/tensor_data.hpp" #include "../data_cell.hpp" #include "../result.hpp" @@ -19,6 +20,10 @@ namespace rerun { /// The tensor data rerun::components::TensorData data; + /// Name of the indicator component, used to identify the archetype when converting to a + /// list of components. + static const char INDICATOR_COMPONENT_NAME[]; + public: Tensor() = default; @@ -29,8 +34,11 @@ namespace rerun { return 1; } - /// Creates a list of Rerun DataCell from this archetype. - Result> to_data_cells() const; + /// Collections all component lists into a list of component collections. *Attention:* + /// The returned vector references this instance and does not take ownership of any + /// data. Adding any new components to this archetype will invalidate the returned + /// component lists! + std::vector as_component_batches() const; }; } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/text_document.cpp b/rerun_cpp/src/rerun/archetypes/text_document.cpp index 0c0f7040e169..7bfba07d6fec 100644 --- a/rerun_cpp/src/rerun/archetypes/text_document.cpp +++ b/rerun_cpp/src/rerun/archetypes/text_document.cpp @@ -3,33 +3,27 @@ #include "text_document.hpp" -#include "../components/text.hpp" +#include "../indicator_component.hpp" namespace rerun { namespace archetypes { - Result> TextDocument::to_data_cells() const { - std::vector cells; - cells.reserve(1); + const char TextDocument::INDICATOR_COMPONENT_NAME[] = + "rerun.components.TextDocumentIndicator"; - { - const auto result = rerun::components::Text::to_data_cell(&body, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = create_indicator_component( - "rerun.components.TextDocumentIndicator", + std::vector TextDocument::as_component_batches() const { + std::vector comp_batches; + comp_batches.reserve(1); + + comp_batches.emplace_back(body); + comp_batches.emplace_back( + ComponentBatch< + components::IndicatorComponent>( + nullptr, num_instances() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + ) + ); - return cells; + return comp_batches; } } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/text_document.hpp b/rerun_cpp/src/rerun/archetypes/text_document.hpp index 9dfc53f10f57..c8c79607c31d 100644 --- a/rerun_cpp/src/rerun/archetypes/text_document.hpp +++ b/rerun_cpp/src/rerun/archetypes/text_document.hpp @@ -4,6 +4,7 @@ #pragma once #include "../arrow.hpp" +#include "../component_batch.hpp" #include "../components/text.hpp" #include "../data_cell.hpp" #include "../result.hpp" @@ -18,6 +19,10 @@ namespace rerun { struct TextDocument { rerun::components::Text body; + /// Name of the indicator component, used to identify the archetype when converting to a + /// list of components. + static const char INDICATOR_COMPONENT_NAME[]; + public: TextDocument() = default; @@ -28,8 +33,11 @@ namespace rerun { return 1; } - /// Creates a list of Rerun DataCell from this archetype. - Result> to_data_cells() const; + /// Collections all component lists into a list of component collections. *Attention:* + /// The returned vector references this instance and does not take ownership of any + /// data. Adding any new components to this archetype will invalidate the returned + /// component lists! + std::vector as_component_batches() const; }; } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/transform3d.cpp b/rerun_cpp/src/rerun/archetypes/transform3d.cpp index 0e07d98e0f12..0cefca18ad7c 100644 --- a/rerun_cpp/src/rerun/archetypes/transform3d.cpp +++ b/rerun_cpp/src/rerun/archetypes/transform3d.cpp @@ -3,33 +3,27 @@ #include "transform3d.hpp" -#include "../components/transform3d.hpp" +#include "../indicator_component.hpp" namespace rerun { namespace archetypes { - Result> Transform3D::to_data_cells() const { - std::vector cells; - cells.reserve(1); + const char Transform3D::INDICATOR_COMPONENT_NAME[] = + "rerun.components.Transform3DIndicator"; - { - const auto result = rerun::components::Transform3D::to_data_cell(&transform, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = create_indicator_component( - "rerun.components.Transform3DIndicator", + std::vector Transform3D::as_component_batches() const { + std::vector comp_batches; + comp_batches.reserve(1); + + comp_batches.emplace_back(transform); + comp_batches.emplace_back( + ComponentBatch< + components::IndicatorComponent>( + nullptr, num_instances() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + ) + ); - return cells; + return comp_batches; } } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/transform3d.hpp b/rerun_cpp/src/rerun/archetypes/transform3d.hpp index 726984e205c9..ef449f45cd6e 100644 --- a/rerun_cpp/src/rerun/archetypes/transform3d.hpp +++ b/rerun_cpp/src/rerun/archetypes/transform3d.hpp @@ -4,6 +4,7 @@ #pragma once #include "../arrow.hpp" +#include "../component_batch.hpp" #include "../components/transform3d.hpp" #include "../data_cell.hpp" #include "../result.hpp" @@ -55,6 +56,10 @@ namespace rerun { /// The transform rerun::components::Transform3D transform; + /// Name of the indicator component, used to identify the archetype when converting to a + /// list of components. + static const char INDICATOR_COMPONENT_NAME[]; + public: // Extensions to generated type defined in 'transform3d_ext.cpp' @@ -243,8 +248,11 @@ namespace rerun { return 1; } - /// Creates a list of Rerun DataCell from this archetype. - Result> to_data_cells() const; + /// Collections all component lists into a list of component collections. *Attention:* + /// The returned vector references this instance and does not take ownership of any + /// data. Adding any new components to this archetype will invalidate the returned + /// component lists! + std::vector as_component_batches() const; }; } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/src/rerun/component_batch.hpp b/rerun_cpp/src/rerun/component_batch.hpp new file mode 100644 index 000000000000..c6de048666d8 --- /dev/null +++ b/rerun_cpp/src/rerun/component_batch.hpp @@ -0,0 +1,94 @@ +#pragma once + +#include +#include + +#include "data_cell.hpp" +#include "result.hpp" + +namespace rerun { + /// Generic list of components that are contiguous in memory. + /// + /// Does *not* own the data, user is responsible for the lifetime independent of how it was + /// passed in. + template + class ComponentBatch { + public: + const ComponentType* data; + size_t num_instances; + + public: + /// Construct from a single component. + /// + /// *Attention*: As with all other constructors, this does *not* take ownership of the data, + /// you need to ensure that the data outlives the component list. + ComponentBatch(const ComponentType& one_and_only) : data(&one_and_only), num_instances(1) {} + + /// Construct from a raw pointer and size. + ComponentBatch(const ComponentType* _data, size_t _num_instances) + : data(_data), num_instances(_num_instances) {} + + /// Construct from an std::vector. + /// + /// *Attention*: As with all other constructors, this does *not* take ownership of the data, + /// you need to ensure that the data outlives the component list. + /// In particular, manipulating the passed vector after constructing the component list, + /// will invalidate it, similar to iterator invalidation. + ComponentBatch(const std::vector& _data) + : data(_data.data()), num_instances(_data.size()) {} + + /// Construct from an std::array. + /// + /// *Attention*: As with all other constructors, this does *not* take ownership of the data, + /// you need to ensure that the data outlives the component list. + template + ComponentBatch(const std::array& _data) + : data(_data.data()), num_instances(NumInstances) {} + + /// Construct from a C-Array. + /// + /// *Attention*: As with all other constructors, this does *not* take ownership of the data, + /// you need to ensure that the data outlives the component list. + template + ComponentBatch(const ComponentType (&_data)[NumInstances]) + : data(_data), num_instances(NumInstances) {} + + /// Creates a Rerun DataCell from this list of components. + Result to_data_cell() const { + return ComponentType::to_data_cell(data, num_instances); + } + }; + + /// A type erased version of `ComponentBatch`. + class AnonymousComponentBatch { + public: + const void* data; + size_t num_instances; + + public: + /// Construct from any parameter that can be converted to a strongly typed component list. + template + AnonymousComponentBatch(const ComponentBatchLikeType& component_list_like) + : AnonymousComponentBatch(ComponentBatch(component_list_like)) {} + + /// Construct from a strongly typed component list. + template + AnonymousComponentBatch(const ComponentBatch& component_list) + : data(component_list.data), + num_instances(component_list.num_instances), + to_data_cell_func([](const void* _data, size_t _num_instances) { + return ComponentType::to_data_cell( + reinterpret_cast(_data), + _num_instances + ); + }) {} + + /// Creates a Rerun DataCell from this list of components. + Result to_data_cell() const { + return to_data_cell_func(data, num_instances); + } + + private: + Result (*to_data_cell_func)(const void*, size_t); + }; +} // namespace rerun diff --git a/rerun_cpp/src/rerun/components/annotation_context.cpp b/rerun_cpp/src/rerun/components/annotation_context.cpp index 50219bd804ef..b77dd1046122 100644 --- a/rerun_cpp/src/rerun/components/annotation_context.cpp +++ b/rerun_cpp/src/rerun/components/annotation_context.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *AnnotationContext::NAME = "rerun.annotation_context"; + const char AnnotationContext::NAME[] = "rerun.annotation_context"; const std::shared_ptr &AnnotationContext::arrow_datatype() { static const auto datatype = arrow::list(arrow::field( diff --git a/rerun_cpp/src/rerun/components/annotation_context.hpp b/rerun_cpp/src/rerun/components/annotation_context.hpp index 360146091726..bda8270f75d9 100644 --- a/rerun_cpp/src/rerun/components/annotation_context.hpp +++ b/rerun_cpp/src/rerun/components/annotation_context.hpp @@ -31,7 +31,7 @@ namespace rerun { std::vector class_map; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: // Extensions to generated type defined in 'annotation_context_ext.cpp' diff --git a/rerun_cpp/src/rerun/components/class_id.cpp b/rerun_cpp/src/rerun/components/class_id.cpp index 1f870436c230..03be8b11c2db 100644 --- a/rerun_cpp/src/rerun/components/class_id.cpp +++ b/rerun_cpp/src/rerun/components/class_id.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *ClassId::NAME = "rerun.class_id"; + const char ClassId::NAME[] = "rerun.class_id"; const std::shared_ptr &ClassId::arrow_datatype() { static const auto datatype = rerun::datatypes::ClassId::arrow_datatype(); diff --git a/rerun_cpp/src/rerun/components/class_id.hpp b/rerun_cpp/src/rerun/components/class_id.hpp index 6cdf9576f451..110948a0827f 100644 --- a/rerun_cpp/src/rerun/components/class_id.hpp +++ b/rerun_cpp/src/rerun/components/class_id.hpp @@ -28,7 +28,7 @@ namespace rerun { rerun::datatypes::ClassId id; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: ClassId() = default; diff --git a/rerun_cpp/src/rerun/components/color.cpp b/rerun_cpp/src/rerun/components/color.cpp index b4ac1687c7b8..4627ca035cdc 100644 --- a/rerun_cpp/src/rerun/components/color.cpp +++ b/rerun_cpp/src/rerun/components/color.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *Color::NAME = "rerun.colorrgba"; + const char Color::NAME[] = "rerun.colorrgba"; const std::shared_ptr &Color::arrow_datatype() { static const auto datatype = rerun::datatypes::Color::arrow_datatype(); diff --git a/rerun_cpp/src/rerun/components/color.hpp b/rerun_cpp/src/rerun/components/color.hpp index c0d9d402b29e..a53cf4f971b6 100644 --- a/rerun_cpp/src/rerun/components/color.hpp +++ b/rerun_cpp/src/rerun/components/color.hpp @@ -29,7 +29,7 @@ namespace rerun { rerun::datatypes::Color rgba; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: // Extensions to generated type defined in 'color_ext.cpp' diff --git a/rerun_cpp/src/rerun/components/depth_meter.cpp b/rerun_cpp/src/rerun/components/depth_meter.cpp index 67e874b7da08..cc6a511e086d 100644 --- a/rerun_cpp/src/rerun/components/depth_meter.cpp +++ b/rerun_cpp/src/rerun/components/depth_meter.cpp @@ -11,7 +11,7 @@ namespace rerun { namespace components { - const char* DepthMeter::NAME = "rerun.components.DepthMeter"; + const char DepthMeter::NAME[] = "rerun.components.DepthMeter"; const std::shared_ptr& DepthMeter::arrow_datatype() { static const auto datatype = arrow::float32(); diff --git a/rerun_cpp/src/rerun/components/depth_meter.hpp b/rerun_cpp/src/rerun/components/depth_meter.hpp index 3ad724689dd3..c62059403509 100644 --- a/rerun_cpp/src/rerun/components/depth_meter.hpp +++ b/rerun_cpp/src/rerun/components/depth_meter.hpp @@ -27,7 +27,7 @@ namespace rerun { float value; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: DepthMeter() = default; diff --git a/rerun_cpp/src/rerun/components/disconnected_space.cpp b/rerun_cpp/src/rerun/components/disconnected_space.cpp index 14ac87cbb5d9..1582b9a73f26 100644 --- a/rerun_cpp/src/rerun/components/disconnected_space.cpp +++ b/rerun_cpp/src/rerun/components/disconnected_space.cpp @@ -11,7 +11,7 @@ namespace rerun { namespace components { - const char *DisconnectedSpace::NAME = "rerun.disconnected_space"; + const char DisconnectedSpace::NAME[] = "rerun.disconnected_space"; const std::shared_ptr &DisconnectedSpace::arrow_datatype() { static const auto datatype = arrow::boolean(); diff --git a/rerun_cpp/src/rerun/components/disconnected_space.hpp b/rerun_cpp/src/rerun/components/disconnected_space.hpp index f45e8b2412d8..7b4dee95ae69 100644 --- a/rerun_cpp/src/rerun/components/disconnected_space.hpp +++ b/rerun_cpp/src/rerun/components/disconnected_space.hpp @@ -27,7 +27,7 @@ namespace rerun { bool is_disconnected; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: DisconnectedSpace() = default; diff --git a/rerun_cpp/src/rerun/components/draw_order.cpp b/rerun_cpp/src/rerun/components/draw_order.cpp index f1512002ab5d..bcf1dff37ab4 100644 --- a/rerun_cpp/src/rerun/components/draw_order.cpp +++ b/rerun_cpp/src/rerun/components/draw_order.cpp @@ -11,7 +11,7 @@ namespace rerun { namespace components { - const char* DrawOrder::NAME = "rerun.draw_order"; + const char DrawOrder::NAME[] = "rerun.draw_order"; const std::shared_ptr& DrawOrder::arrow_datatype() { static const auto datatype = arrow::float32(); diff --git a/rerun_cpp/src/rerun/components/draw_order.hpp b/rerun_cpp/src/rerun/components/draw_order.hpp index ce6b8287010f..16ce24628950 100644 --- a/rerun_cpp/src/rerun/components/draw_order.hpp +++ b/rerun_cpp/src/rerun/components/draw_order.hpp @@ -33,7 +33,7 @@ namespace rerun { float value; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: DrawOrder() = default; diff --git a/rerun_cpp/src/rerun/components/instance_key.cpp b/rerun_cpp/src/rerun/components/instance_key.cpp index 7efd80d811d9..27e09951e1f0 100644 --- a/rerun_cpp/src/rerun/components/instance_key.cpp +++ b/rerun_cpp/src/rerun/components/instance_key.cpp @@ -11,7 +11,7 @@ namespace rerun { namespace components { - const char* InstanceKey::NAME = "rerun.instance_key"; + const char InstanceKey::NAME[] = "rerun.instance_key"; const std::shared_ptr& InstanceKey::arrow_datatype() { static const auto datatype = arrow::uint64(); diff --git a/rerun_cpp/src/rerun/components/instance_key.hpp b/rerun_cpp/src/rerun/components/instance_key.hpp index 317fcbf1ee48..f87df4c62c7e 100644 --- a/rerun_cpp/src/rerun/components/instance_key.hpp +++ b/rerun_cpp/src/rerun/components/instance_key.hpp @@ -27,7 +27,7 @@ namespace rerun { uint64_t value; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: InstanceKey() = default; diff --git a/rerun_cpp/src/rerun/components/keypoint_id.cpp b/rerun_cpp/src/rerun/components/keypoint_id.cpp index dfcba5ef68ec..51e8545b4d6e 100644 --- a/rerun_cpp/src/rerun/components/keypoint_id.cpp +++ b/rerun_cpp/src/rerun/components/keypoint_id.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *KeypointId::NAME = "rerun.keypoint_id"; + const char KeypointId::NAME[] = "rerun.keypoint_id"; const std::shared_ptr &KeypointId::arrow_datatype() { static const auto datatype = rerun::datatypes::KeypointId::arrow_datatype(); diff --git a/rerun_cpp/src/rerun/components/keypoint_id.hpp b/rerun_cpp/src/rerun/components/keypoint_id.hpp index f036d4abf2f8..e407be206db1 100644 --- a/rerun_cpp/src/rerun/components/keypoint_id.hpp +++ b/rerun_cpp/src/rerun/components/keypoint_id.hpp @@ -28,7 +28,7 @@ namespace rerun { rerun::datatypes::KeypointId id; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: KeypointId() = default; diff --git a/rerun_cpp/src/rerun/components/line_strip2d.cpp b/rerun_cpp/src/rerun/components/line_strip2d.cpp index b4f0d641d701..3a7fba1d2cc8 100644 --- a/rerun_cpp/src/rerun/components/line_strip2d.cpp +++ b/rerun_cpp/src/rerun/components/line_strip2d.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *LineStrip2D::NAME = "rerun.linestrip2d"; + const char LineStrip2D::NAME[] = "rerun.linestrip2d"; const std::shared_ptr &LineStrip2D::arrow_datatype() { static const auto datatype = diff --git a/rerun_cpp/src/rerun/components/line_strip2d.hpp b/rerun_cpp/src/rerun/components/line_strip2d.hpp index 4407f983cbc6..c11d7d6959b0 100644 --- a/rerun_cpp/src/rerun/components/line_strip2d.hpp +++ b/rerun_cpp/src/rerun/components/line_strip2d.hpp @@ -36,7 +36,7 @@ namespace rerun { std::vector points; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: LineStrip2D() = default; diff --git a/rerun_cpp/src/rerun/components/line_strip3d.cpp b/rerun_cpp/src/rerun/components/line_strip3d.cpp index 470d7a664486..e6cb3d9e83a2 100644 --- a/rerun_cpp/src/rerun/components/line_strip3d.cpp +++ b/rerun_cpp/src/rerun/components/line_strip3d.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *LineStrip3D::NAME = "rerun.linestrip3d"; + const char LineStrip3D::NAME[] = "rerun.linestrip3d"; const std::shared_ptr &LineStrip3D::arrow_datatype() { static const auto datatype = diff --git a/rerun_cpp/src/rerun/components/line_strip3d.hpp b/rerun_cpp/src/rerun/components/line_strip3d.hpp index 49f946e52570..cf2ce4cfa3fc 100644 --- a/rerun_cpp/src/rerun/components/line_strip3d.hpp +++ b/rerun_cpp/src/rerun/components/line_strip3d.hpp @@ -36,7 +36,7 @@ namespace rerun { std::vector points; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: LineStrip3D() = default; diff --git a/rerun_cpp/src/rerun/components/origin3d.cpp b/rerun_cpp/src/rerun/components/origin3d.cpp index 5c0f0f2a05ef..0f12b8158b5c 100644 --- a/rerun_cpp/src/rerun/components/origin3d.cpp +++ b/rerun_cpp/src/rerun/components/origin3d.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *Origin3D::NAME = "rerun.components.Origin3D"; + const char Origin3D::NAME[] = "rerun.components.Origin3D"; const std::shared_ptr &Origin3D::arrow_datatype() { static const auto datatype = rerun::datatypes::Vec3D::arrow_datatype(); diff --git a/rerun_cpp/src/rerun/components/origin3d.hpp b/rerun_cpp/src/rerun/components/origin3d.hpp index 78e5e282ced0..4623d0de0683 100644 --- a/rerun_cpp/src/rerun/components/origin3d.hpp +++ b/rerun_cpp/src/rerun/components/origin3d.hpp @@ -24,7 +24,7 @@ namespace rerun { rerun::datatypes::Vec3D origin; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: // Extensions to generated type defined in 'origin3d_ext.cpp' diff --git a/rerun_cpp/src/rerun/components/point2d.cpp b/rerun_cpp/src/rerun/components/point2d.cpp index 603006944852..7a7214d2a7de 100644 --- a/rerun_cpp/src/rerun/components/point2d.cpp +++ b/rerun_cpp/src/rerun/components/point2d.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *Point2D::NAME = "rerun.point2d"; + const char Point2D::NAME[] = "rerun.point2d"; const std::shared_ptr &Point2D::arrow_datatype() { static const auto datatype = rerun::datatypes::Vec2D::arrow_datatype(); diff --git a/rerun_cpp/src/rerun/components/point2d.hpp b/rerun_cpp/src/rerun/components/point2d.hpp index 7e579a5f6b9c..79d4feee0308 100644 --- a/rerun_cpp/src/rerun/components/point2d.hpp +++ b/rerun_cpp/src/rerun/components/point2d.hpp @@ -24,7 +24,7 @@ namespace rerun { rerun::datatypes::Vec2D xy; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: // Extensions to generated type defined in 'point2d_ext.cpp' diff --git a/rerun_cpp/src/rerun/components/point3d.cpp b/rerun_cpp/src/rerun/components/point3d.cpp index 042b3b4c2e9f..75234eade858 100644 --- a/rerun_cpp/src/rerun/components/point3d.cpp +++ b/rerun_cpp/src/rerun/components/point3d.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *Point3D::NAME = "rerun.point3d"; + const char Point3D::NAME[] = "rerun.point3d"; const std::shared_ptr &Point3D::arrow_datatype() { static const auto datatype = rerun::datatypes::Vec3D::arrow_datatype(); diff --git a/rerun_cpp/src/rerun/components/point3d.hpp b/rerun_cpp/src/rerun/components/point3d.hpp index 0e54af29eaed..d80639f0b0eb 100644 --- a/rerun_cpp/src/rerun/components/point3d.hpp +++ b/rerun_cpp/src/rerun/components/point3d.hpp @@ -24,7 +24,7 @@ namespace rerun { rerun::datatypes::Vec3D xyz; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: // Extensions to generated type defined in 'point3d_ext.cpp' diff --git a/rerun_cpp/src/rerun/components/radius.cpp b/rerun_cpp/src/rerun/components/radius.cpp index 57acdce70650..f704aa7c2b37 100644 --- a/rerun_cpp/src/rerun/components/radius.cpp +++ b/rerun_cpp/src/rerun/components/radius.cpp @@ -11,7 +11,7 @@ namespace rerun { namespace components { - const char* Radius::NAME = "rerun.radius"; + const char Radius::NAME[] = "rerun.radius"; const std::shared_ptr& Radius::arrow_datatype() { static const auto datatype = arrow::float32(); diff --git a/rerun_cpp/src/rerun/components/radius.hpp b/rerun_cpp/src/rerun/components/radius.hpp index ae974ac37b08..cb388bc6855a 100644 --- a/rerun_cpp/src/rerun/components/radius.hpp +++ b/rerun_cpp/src/rerun/components/radius.hpp @@ -27,7 +27,7 @@ namespace rerun { float value; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: Radius() = default; diff --git a/rerun_cpp/src/rerun/components/tensor_data.cpp b/rerun_cpp/src/rerun/components/tensor_data.cpp index c6967b1b770e..70dfa5e22893 100644 --- a/rerun_cpp/src/rerun/components/tensor_data.cpp +++ b/rerun_cpp/src/rerun/components/tensor_data.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *TensorData::NAME = "rerun.components.TensorData"; + const char TensorData::NAME[] = "rerun.components.TensorData"; const std::shared_ptr &TensorData::arrow_datatype() { static const auto datatype = rerun::datatypes::TensorData::arrow_datatype(); diff --git a/rerun_cpp/src/rerun/components/tensor_data.hpp b/rerun_cpp/src/rerun/components/tensor_data.hpp index d3dd8cf05a16..e62fc4b80f34 100644 --- a/rerun_cpp/src/rerun/components/tensor_data.hpp +++ b/rerun_cpp/src/rerun/components/tensor_data.hpp @@ -23,7 +23,7 @@ namespace rerun { rerun::datatypes::TensorData data; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: TensorData() = default; diff --git a/rerun_cpp/src/rerun/components/text.cpp b/rerun_cpp/src/rerun/components/text.cpp index 222e288f2f20..3ba6c08c2055 100644 --- a/rerun_cpp/src/rerun/components/text.cpp +++ b/rerun_cpp/src/rerun/components/text.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *Text::NAME = "rerun.label"; + const char Text::NAME[] = "rerun.label"; const std::shared_ptr &Text::arrow_datatype() { static const auto datatype = rerun::datatypes::Utf8::arrow_datatype(); diff --git a/rerun_cpp/src/rerun/components/text.hpp b/rerun_cpp/src/rerun/components/text.hpp index 9120d020d670..3eb401df3b16 100644 --- a/rerun_cpp/src/rerun/components/text.hpp +++ b/rerun_cpp/src/rerun/components/text.hpp @@ -25,7 +25,7 @@ namespace rerun { rerun::datatypes::Utf8 value; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: // Extensions to generated type defined in 'text_ext.cpp' diff --git a/rerun_cpp/src/rerun/components/transform3d.cpp b/rerun_cpp/src/rerun/components/transform3d.cpp index f7a5e2a19187..6b17b9b9a554 100644 --- a/rerun_cpp/src/rerun/components/transform3d.cpp +++ b/rerun_cpp/src/rerun/components/transform3d.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *Transform3D::NAME = "rerun.transform3d"; + const char Transform3D::NAME[] = "rerun.transform3d"; const std::shared_ptr &Transform3D::arrow_datatype() { static const auto datatype = rerun::datatypes::Transform3D::arrow_datatype(); diff --git a/rerun_cpp/src/rerun/components/transform3d.hpp b/rerun_cpp/src/rerun/components/transform3d.hpp index 4d993454fd4a..ec0a0f3e5af1 100644 --- a/rerun_cpp/src/rerun/components/transform3d.hpp +++ b/rerun_cpp/src/rerun/components/transform3d.hpp @@ -25,7 +25,7 @@ namespace rerun { rerun::datatypes::Transform3D repr; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: Transform3D() = default; diff --git a/rerun_cpp/src/rerun/components/vector3d.cpp b/rerun_cpp/src/rerun/components/vector3d.cpp index 912d7e042a26..aa515643cd7c 100644 --- a/rerun_cpp/src/rerun/components/vector3d.cpp +++ b/rerun_cpp/src/rerun/components/vector3d.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *Vector3D::NAME = "rerun.components.Vector3D"; + const char Vector3D::NAME[] = "rerun.components.Vector3D"; const std::shared_ptr &Vector3D::arrow_datatype() { static const auto datatype = rerun::datatypes::Vec3D::arrow_datatype(); diff --git a/rerun_cpp/src/rerun/components/vector3d.hpp b/rerun_cpp/src/rerun/components/vector3d.hpp index 4f26b131afc1..a085c1f6b0cf 100644 --- a/rerun_cpp/src/rerun/components/vector3d.hpp +++ b/rerun_cpp/src/rerun/components/vector3d.hpp @@ -24,7 +24,7 @@ namespace rerun { rerun::datatypes::Vec3D vector; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: // Extensions to generated type defined in 'vector3d_ext.cpp' diff --git a/rerun_cpp/src/rerun/indicator_component.hpp b/rerun_cpp/src/rerun/indicator_component.hpp new file mode 100644 index 000000000000..96a6ec5517f6 --- /dev/null +++ b/rerun_cpp/src/rerun/indicator_component.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "arrow.hpp" +#include "data_cell.hpp" + +namespace rerun { + namespace components { + /// Indicator component used by archetypes when converting them to component lists. + /// + /// This is done in order to track how a collection of component was logged. + template + struct IndicatorComponent { + public: + IndicatorComponent() = default; + + /// Creates a Rerun DataCell from an array of IndicatorComponent components. + static Result to_data_cell( + const IndicatorComponent*, size_t num_instances + ) { + return rerun::create_indicator_component(Name, num_instances); + } + }; + } // namespace components +} // namespace rerun diff --git a/rerun_cpp/src/rerun/recording_stream.cpp b/rerun_cpp/src/rerun/recording_stream.cpp index 6ebd2b61c53e..5884f5a36c0c 100644 --- a/rerun_cpp/src/rerun/recording_stream.cpp +++ b/rerun_cpp/src/rerun/recording_stream.cpp @@ -1,4 +1,5 @@ #include "recording_stream.hpp" +#include "components/instance_key.hpp" #include @@ -6,6 +7,8 @@ #include namespace rerun { + static const auto splat_key = components::InstanceKey(std::numeric_limits::max()); + static rr_store_kind store_kind_to_c(StoreKind store_kind) { switch (store_kind) { case StoreKind::Recording: @@ -91,6 +94,40 @@ namespace rerun { rr_recording_stream_flush_blocking(_id); } + Error RecordingStream::try_log_component_batches( + const char* entity_path, size_t num_instances, + const std::vector& component_lists + ) { + if (num_instances == 0) { + return Error::ok(); + } + + std::vector instanced; + std::vector splatted; + + for (const auto& component_list : component_lists) { + const auto result = component_list.to_data_cell(); + if (result.is_err()) { + return result.error; + } + if (num_instances > 1 && component_list.num_instances == 1) { + splatted.push_back(result.value); + } else { + instanced.push_back(result.value); + } + } + + if (!splatted.empty()) { + splatted.push_back(components::InstanceKey::to_data_cell(&splat_key, 1).value); + auto result = try_log_data_row(entity_path, 1, splatted.size(), splatted.data()); + if (result.is_err()) { + return result; + } + } + + return try_log_data_row(entity_path, num_instances, instanced.size(), instanced.data()); + } + Error RecordingStream::try_log_data_row( const char* entity_path, size_t num_instances, size_t num_data_cells, const DataCell* data_cells diff --git a/rerun_cpp/src/rerun/recording_stream.hpp b/rerun_cpp/src/rerun/recording_stream.hpp index 793d1714ecca..ba993ed03652 100644 --- a/rerun_cpp/src/rerun/recording_stream.hpp +++ b/rerun_cpp/src/rerun/recording_stream.hpp @@ -1,10 +1,9 @@ #pragma once -#include // size_t -#include // uint32_t etc +#include // uint32_t etc. #include -#include "data_cell.hpp" +#include "component_batch.hpp" #include "error.hpp" namespace rerun { @@ -38,6 +37,16 @@ namespace rerun { /// set it as a the global. /// /// Shutting down cannot ever block. + /// + /// ## Logging + /// + /// Internally, the stream will automatically micro-batch multiple log calls to optimize + /// transport. + /// See [SDK Micro Batching](https://www.rerun.io/docs/reference/sdk-micro-batching) for + /// more information. + /// + /// The data will be timestamped automatically based on the `RecordingStream`'s + /// internal clock. class RecordingStream { public: /// Creates a new recording stream to log to. @@ -116,11 +125,8 @@ namespace rerun { /// Logs an archetype. /// - /// Prefer this interface for ease of use over the more general `log_components` interface. - /// - /// Alias for `log_archetype`. - /// TODO(andreas): Would be nice if this were able to combine both log_archetype and - /// log_components! + /// Prefer this interface for ease of use over the more general `log_component_batches` + /// interface. /// /// Logs any failure via `Error::log_on_failure` template @@ -128,11 +134,7 @@ namespace rerun { log_archetype(entity_path, archetype); } - /// Logs an archetype. - /// - /// Prefer this interface for ease of use over the more general `log_components` interface. - /// - /// Logs any failure via `Error::log_on_failure` + /// @copydoc log template void log_archetype(const char* entity_path, const T& archetype) { try_log_archetype(entity_path, archetype).log_on_failure(); @@ -143,122 +145,109 @@ namespace rerun { /// @see log_archetype template Error try_log_archetype(const char* entity_path, const T& archetype) { - const auto data_cells_result = archetype.to_data_cells(); - if (data_cells_result.is_ok()) { - return try_log_data_row( - entity_path, - archetype.num_instances(), - data_cells_result.value.size(), - data_cells_result.value.data() - ); - } else { - return data_cells_result.error; - } + return try_log_component_batches( + entity_path, + archetype.num_instances(), + archetype.as_component_batches() + ); } - /// Logs a list of component arrays. + /// Logs a single component batch. /// /// This forms the "medium level API", for easy to use high level api, prefer `log` to log /// built-in archetypes. /// - /// Expects component arrays as std::vector, std::array or C arrays. + /// Logs any failure via `Error::log_on_failure` /// - /// TODO(andreas): More documentation, examples etc. + /// @param component_batch + /// Expects component batch as std::vector, std::array or C arrays. + /// + /// @see try_log_component_batch, log_component_batches, try_log_component_batches + template + void log_component_batch(const char* entity_path, const T& component_batch) { + const auto batch = AnonymousComponentBatch(component_batch); + try_log_component_batches(entity_path, batch.num_instances, batch).log_on_failure(); + } + + /// Logs a single component batch. + /// + /// This forms the "medium level API", for easy to use high level api, prefer `log` to log + /// built-in archetypes. + /// + /// @param component_batch + /// Expects component batch as std::vector, std::array or C arrays. + /// + /// @see log_component_batch, log_component_batches, try_log_component_batches + template + Error try_log_component_batch(const char* entity_path, const T& component_batch) { + const auto batch = AnonymousComponentBatch(component_batch); + return try_log_component_batches(entity_path, batch.num_instances, batch); + } + + /// Logs several component batches. + /// + /// This forms the "medium level API", for easy to use high level api, prefer `log` to log + /// built-in archetypes. /// /// Logs any failure via `Error::log_on_failure` + /// + /// @param component_batches + /// Expects component batches as std::vector, std::array or C arrays. + /// + /// @param num_instances + /// Specify the expected number of component instances present in each + /// list. Each can have either: + /// - exactly `num_instances` instances, + /// - a single instance (splat), + /// - or zero instance (clear). + /// + /// @see try_log_component_batches template - void log_components(const char* entity_path, const Ts&... component_array) { - try_log_components(entity_path, component_array...).log_on_failure(); + void log_component_batches( + const char* entity_path, size_t num_instances, const Ts&... component_batches + ) { + try_log_component_batches(entity_path, num_instances, component_batches...) + .log_on_failure(); } - /// Logs a list of component arrays, returning an error on failure. + /// Logs several component batches, returning an error on failure. + /// /// - /// @see log_components + /// @param num_instances + /// Specify the expected number of component instances present in each + /// list. Each can have either: + /// - exactly `num_instances` instances, + /// - a single instance (splat), + /// - or zero instance (clear). + /// + /// @see log_component_batches template - Error try_log_components(const char* entity_path, const Ts&... component_array) { - // TODO(andreas): Handle splats. - const size_t num_instances = size_of_first_collection(component_array...); - - std::vector data_cells; - data_cells.reserve(sizeof...(Ts)); - const auto error = push_data_cells(data_cells, component_array...); - if (error.is_err()) { - return error; - } - - return try_log_data_row( + Error try_log_component_batches( + const char* entity_path, size_t num_instances, const Ts&... component_batches + ) { + return try_log_component_batches( entity_path, num_instances, - data_cells.size(), - data_cells.data() + {AnonymousComponentBatch(component_batches)...} ); } + /// @copydoc try_log_component_batches + Error try_log_component_batches( + const char* entity_path, size_t num_instances, + const std::vector& component_lists + ); + /// Low level API that logs raw data cells to the recording stream. /// - /// I.e. logs a number of components arrays (each with a same number of instances) to a - /// single entity path. + /// @param num_instances + /// Each cell is expected to hold exactly `num_instances` instances. Error try_log_data_row( const char* entity_path, size_t num_instances, size_t num_data_cells, const DataCell* data_cells ); private: - template - static size_t size_of_first_collection(const std::vector& first, const Ts&...) { - return first.size(); - } - - template - static size_t size_of_first_collection(const std::array& first, const Ts&...) { - return first.size(); - } - - template - static size_t size_of_first_collection(const C (&)[N], const Ts&...) { - return N; - } - - template - static Error push_data_cells( - std::vector& data_cells, const std::vector& first, const Ts&... rest - ) { - const auto cell_result = C::to_data_cell(first.data(), first.size()); - if (cell_result.is_err()) { - return cell_result.error; - } - data_cells.push_back(cell_result.value); - return push_data_cells(data_cells, rest...); - } - - template - static Error push_data_cells( - std::vector& data_cells, const std::array& first, const Ts&... rest - ) { - const auto cell_result = C::to_data_cell(first.data(), N); - if (!cell_result.is_ok()) { - return cell_result.error; - } - data_cells.push_back(cell_result.value); - return push_data_cells(data_cells, rest...); - } - - template - static Error push_data_cells( - std::vector& data_cells, const C (&first)[N], const Ts&... rest - ) { - const auto cell_result = C::to_data_cell(first, N); - if (!cell_result.is_ok()) { - return cell_result.error; - } - data_cells.push_back(cell_result.value); - return push_data_cells(data_cells, rest...); - } - - static Error push_data_cells(std::vector&) { - return Error(); - } - RecordingStream(uint32_t id, StoreKind store_kind) : _id(id), _store_kind(store_kind) {} uint32_t _id; diff --git a/rerun_cpp/tests/archetypes/archetype_test.hpp b/rerun_cpp/tests/archetypes/archetype_test.hpp index d0c1ec55ec37..785f0d66ab1a 100644 --- a/rerun_cpp/tests/archetypes/archetype_test.hpp +++ b/rerun_cpp/tests/archetypes/archetype_test.hpp @@ -1,26 +1,42 @@ #pragma once +#include #include -#include +#include +#include template void test_serialization_for_manual_and_builder(const T& from_manual, const T& from_builder) { - THEN("serialization succeeds") { - auto from_builder_serialized = from_builder.to_data_cells(); - REQUIRE(from_builder_serialized.is_ok()); + THEN("convert to component lists") { + std::vector from_builder_lists = + from_builder.as_component_batches(); + std::vector from_manual_lists = + from_manual.as_component_batches(); + + REQUIRE(from_builder_lists.size() == from_manual_lists.size()); - auto from_manual_serialized = from_manual.to_data_cells(); - REQUIRE(from_manual_serialized.is_ok()); + AND_THEN("serializing each list succeeds") { + std::vector from_builder_cells; + std::vector from_manual_cells; + for (size_t i = 0; i < from_builder_lists.size(); ++i) { + auto from_builder_cell = from_builder_lists[i].to_data_cell(); + auto from_manual_cell = from_manual_lists[i].to_data_cell(); - AND_THEN("the serialized data is the same") { - auto from_builder_cells = from_builder_serialized.value; - auto from_manual_cells = from_manual_serialized.value; + REQUIRE(from_builder_cell.is_ok()); + REQUIRE(from_manual_cell.is_ok()); + + from_builder_cells.push_back(from_builder_cell.value); + from_manual_cells.push_back(from_manual_cell.value); + } - CHECK(from_builder_cells.size() == from_manual_cells.size()); - for (size_t i = 0; i < from_builder_cells.size(); ++i) { - CHECK(from_builder_cells[i].component_name == from_manual_cells[i].component_name); - CHECK(from_builder_cells[i].buffer->Equals(*from_manual_cells[i].buffer)); + AND_THEN("the serialized data is the same") { + for (size_t i = 0; i < from_builder_lists.size(); ++i) { + CHECK( + from_builder_cells[i].component_name == from_manual_cells[i].component_name + ); + CHECK(from_builder_cells[i].buffer->Equals(*from_manual_cells[i].buffer)); + } } } } diff --git a/rerun_cpp/tests/archetypes/disconnected_space.cpp b/rerun_cpp/tests/archetypes/disconnected_space.cpp index 93002cb6735f..15b973cbbf16 100644 --- a/rerun_cpp/tests/archetypes/disconnected_space.cpp +++ b/rerun_cpp/tests/archetypes/disconnected_space.cpp @@ -11,7 +11,9 @@ SCENARIO("disconnected_space archetype can be serialized" TEST_TAG) { auto from_builder = DisconnectedSpace(true); THEN("serialization succeeds") { - CHECK(from_builder.to_data_cells().is_ok()); + for (auto& list : from_builder.as_component_batches()) { + CHECK(list.to_data_cell().is_ok()); + } } } } diff --git a/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.cpp b/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.cpp index 261c35210864..a3ded49b529c 100644 --- a/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.cpp +++ b/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.cpp @@ -3,653 +3,172 @@ #include "affix_fuzzer1.hpp" -#include "../components/affix_fuzzer1.hpp" -#include "../components/affix_fuzzer10.hpp" -#include "../components/affix_fuzzer11.hpp" -#include "../components/affix_fuzzer12.hpp" -#include "../components/affix_fuzzer13.hpp" -#include "../components/affix_fuzzer14.hpp" -#include "../components/affix_fuzzer15.hpp" -#include "../components/affix_fuzzer16.hpp" -#include "../components/affix_fuzzer17.hpp" -#include "../components/affix_fuzzer18.hpp" -#include "../components/affix_fuzzer19.hpp" -#include "../components/affix_fuzzer2.hpp" -#include "../components/affix_fuzzer20.hpp" -#include "../components/affix_fuzzer3.hpp" -#include "../components/affix_fuzzer4.hpp" -#include "../components/affix_fuzzer5.hpp" -#include "../components/affix_fuzzer6.hpp" -#include "../components/affix_fuzzer7.hpp" -#include "../components/affix_fuzzer8.hpp" -#include "../components/affix_fuzzer9.hpp" +#include namespace rerun { namespace archetypes { - Result> AffixFuzzer1::to_data_cells() const { - std::vector cells; - cells.reserve(74); + const char AffixFuzzer1::INDICATOR_COMPONENT_NAME[] = + "rerun.testing.components.AffixFuzzer1Indicator"; - { - const auto result = rerun::components::AffixFuzzer1::to_data_cell(&fuzz1001, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer2::to_data_cell(&fuzz1002, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer3::to_data_cell(&fuzz1003, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer4::to_data_cell(&fuzz1004, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer5::to_data_cell(&fuzz1005, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer6::to_data_cell(&fuzz1006, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer7::to_data_cell(&fuzz1007, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer8::to_data_cell(&fuzz1008, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer9::to_data_cell(&fuzz1009, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer10::to_data_cell(&fuzz1010, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer11::to_data_cell(&fuzz1011, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer12::to_data_cell(&fuzz1012, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer13::to_data_cell(&fuzz1013, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer14::to_data_cell(&fuzz1014, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer15::to_data_cell(&fuzz1015, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer16::to_data_cell(&fuzz1016, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer17::to_data_cell(&fuzz1017, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer18::to_data_cell(&fuzz1018, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer19::to_data_cell(&fuzz1019, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer20::to_data_cell(&fuzz1020, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = - rerun::components::AffixFuzzer1::to_data_cell(fuzz1101.data(), fuzz1101.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = - rerun::components::AffixFuzzer2::to_data_cell(fuzz1102.data(), fuzz1102.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = - rerun::components::AffixFuzzer3::to_data_cell(fuzz1103.data(), fuzz1103.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = - rerun::components::AffixFuzzer4::to_data_cell(fuzz1104.data(), fuzz1104.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = - rerun::components::AffixFuzzer5::to_data_cell(fuzz1105.data(), fuzz1105.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = - rerun::components::AffixFuzzer6::to_data_cell(fuzz1106.data(), fuzz1106.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = - rerun::components::AffixFuzzer7::to_data_cell(fuzz1107.data(), fuzz1107.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = - rerun::components::AffixFuzzer8::to_data_cell(fuzz1108.data(), fuzz1108.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = - rerun::components::AffixFuzzer9::to_data_cell(fuzz1109.data(), fuzz1109.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer10::to_data_cell( - fuzz1110.data(), - fuzz1110.size() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer11::to_data_cell( - fuzz1111.data(), - fuzz1111.size() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer12::to_data_cell( - fuzz1112.data(), - fuzz1112.size() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer13::to_data_cell( - fuzz1113.data(), - fuzz1113.size() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer14::to_data_cell( - fuzz1114.data(), - fuzz1114.size() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer15::to_data_cell( - fuzz1115.data(), - fuzz1115.size() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer16::to_data_cell( - fuzz1116.data(), - fuzz1116.size() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer17::to_data_cell( - fuzz1117.data(), - fuzz1117.size() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = rerun::components::AffixFuzzer18::to_data_cell( - fuzz1118.data(), - fuzz1118.size() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } + std::vector AffixFuzzer1::as_component_batches() const { + std::vector comp_batches; + comp_batches.reserve(74); + + comp_batches.emplace_back(fuzz1001); + comp_batches.emplace_back(fuzz1002); + comp_batches.emplace_back(fuzz1003); + comp_batches.emplace_back(fuzz1004); + comp_batches.emplace_back(fuzz1005); + comp_batches.emplace_back(fuzz1006); + comp_batches.emplace_back(fuzz1007); + comp_batches.emplace_back(fuzz1008); + comp_batches.emplace_back(fuzz1009); + comp_batches.emplace_back(fuzz1010); + comp_batches.emplace_back(fuzz1011); + comp_batches.emplace_back(fuzz1012); + comp_batches.emplace_back(fuzz1013); + comp_batches.emplace_back(fuzz1014); + comp_batches.emplace_back(fuzz1015); + comp_batches.emplace_back(fuzz1016); + comp_batches.emplace_back(fuzz1017); + comp_batches.emplace_back(fuzz1018); + comp_batches.emplace_back(fuzz1019); + comp_batches.emplace_back(fuzz1020); + comp_batches.emplace_back(fuzz1101); + comp_batches.emplace_back(fuzz1102); + comp_batches.emplace_back(fuzz1103); + comp_batches.emplace_back(fuzz1104); + comp_batches.emplace_back(fuzz1105); + comp_batches.emplace_back(fuzz1106); + comp_batches.emplace_back(fuzz1107); + comp_batches.emplace_back(fuzz1108); + comp_batches.emplace_back(fuzz1109); + comp_batches.emplace_back(fuzz1110); + comp_batches.emplace_back(fuzz1111); + comp_batches.emplace_back(fuzz1112); + comp_batches.emplace_back(fuzz1113); + comp_batches.emplace_back(fuzz1114); + comp_batches.emplace_back(fuzz1115); + comp_batches.emplace_back(fuzz1116); + comp_batches.emplace_back(fuzz1117); + comp_batches.emplace_back(fuzz1118); if (fuzz2001.has_value()) { - const auto& value = fuzz2001.value(); - const auto result = rerun::components::AffixFuzzer1::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2001.value()); } if (fuzz2002.has_value()) { - const auto& value = fuzz2002.value(); - const auto result = rerun::components::AffixFuzzer2::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2002.value()); } if (fuzz2003.has_value()) { - const auto& value = fuzz2003.value(); - const auto result = rerun::components::AffixFuzzer3::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2003.value()); } if (fuzz2004.has_value()) { - const auto& value = fuzz2004.value(); - const auto result = rerun::components::AffixFuzzer4::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2004.value()); } if (fuzz2005.has_value()) { - const auto& value = fuzz2005.value(); - const auto result = rerun::components::AffixFuzzer5::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2005.value()); } if (fuzz2006.has_value()) { - const auto& value = fuzz2006.value(); - const auto result = rerun::components::AffixFuzzer6::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2006.value()); } if (fuzz2007.has_value()) { - const auto& value = fuzz2007.value(); - const auto result = rerun::components::AffixFuzzer7::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2007.value()); } if (fuzz2008.has_value()) { - const auto& value = fuzz2008.value(); - const auto result = rerun::components::AffixFuzzer8::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2008.value()); } if (fuzz2009.has_value()) { - const auto& value = fuzz2009.value(); - const auto result = rerun::components::AffixFuzzer9::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2009.value()); } if (fuzz2010.has_value()) { - const auto& value = fuzz2010.value(); - const auto result = rerun::components::AffixFuzzer10::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2010.value()); } if (fuzz2011.has_value()) { - const auto& value = fuzz2011.value(); - const auto result = rerun::components::AffixFuzzer11::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2011.value()); } if (fuzz2012.has_value()) { - const auto& value = fuzz2012.value(); - const auto result = rerun::components::AffixFuzzer12::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2012.value()); } if (fuzz2013.has_value()) { - const auto& value = fuzz2013.value(); - const auto result = rerun::components::AffixFuzzer13::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2013.value()); } if (fuzz2014.has_value()) { - const auto& value = fuzz2014.value(); - const auto result = rerun::components::AffixFuzzer14::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2014.value()); } if (fuzz2015.has_value()) { - const auto& value = fuzz2015.value(); - const auto result = rerun::components::AffixFuzzer15::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2015.value()); } if (fuzz2016.has_value()) { - const auto& value = fuzz2016.value(); - const auto result = rerun::components::AffixFuzzer16::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2016.value()); } if (fuzz2017.has_value()) { - const auto& value = fuzz2017.value(); - const auto result = rerun::components::AffixFuzzer17::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2017.value()); } if (fuzz2018.has_value()) { - const auto& value = fuzz2018.value(); - const auto result = rerun::components::AffixFuzzer18::to_data_cell(&value, 1); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2018.value()); } if (fuzz2101.has_value()) { - const auto& value = fuzz2101.value(); - const auto result = - rerun::components::AffixFuzzer1::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2101.value()); } if (fuzz2102.has_value()) { - const auto& value = fuzz2102.value(); - const auto result = - rerun::components::AffixFuzzer2::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2102.value()); } if (fuzz2103.has_value()) { - const auto& value = fuzz2103.value(); - const auto result = - rerun::components::AffixFuzzer3::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2103.value()); } if (fuzz2104.has_value()) { - const auto& value = fuzz2104.value(); - const auto result = - rerun::components::AffixFuzzer4::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2104.value()); } if (fuzz2105.has_value()) { - const auto& value = fuzz2105.value(); - const auto result = - rerun::components::AffixFuzzer5::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2105.value()); } if (fuzz2106.has_value()) { - const auto& value = fuzz2106.value(); - const auto result = - rerun::components::AffixFuzzer6::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2106.value()); } if (fuzz2107.has_value()) { - const auto& value = fuzz2107.value(); - const auto result = - rerun::components::AffixFuzzer7::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2107.value()); } if (fuzz2108.has_value()) { - const auto& value = fuzz2108.value(); - const auto result = - rerun::components::AffixFuzzer8::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2108.value()); } if (fuzz2109.has_value()) { - const auto& value = fuzz2109.value(); - const auto result = - rerun::components::AffixFuzzer9::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2109.value()); } if (fuzz2110.has_value()) { - const auto& value = fuzz2110.value(); - const auto result = - rerun::components::AffixFuzzer10::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2110.value()); } if (fuzz2111.has_value()) { - const auto& value = fuzz2111.value(); - const auto result = - rerun::components::AffixFuzzer11::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2111.value()); } if (fuzz2112.has_value()) { - const auto& value = fuzz2112.value(); - const auto result = - rerun::components::AffixFuzzer12::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2112.value()); } if (fuzz2113.has_value()) { - const auto& value = fuzz2113.value(); - const auto result = - rerun::components::AffixFuzzer13::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2113.value()); } if (fuzz2114.has_value()) { - const auto& value = fuzz2114.value(); - const auto result = - rerun::components::AffixFuzzer14::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2114.value()); } if (fuzz2115.has_value()) { - const auto& value = fuzz2115.value(); - const auto result = - rerun::components::AffixFuzzer15::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2115.value()); } if (fuzz2116.has_value()) { - const auto& value = fuzz2116.value(); - const auto result = - rerun::components::AffixFuzzer16::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2116.value()); } if (fuzz2117.has_value()) { - const auto& value = fuzz2117.value(); - const auto result = - rerun::components::AffixFuzzer17::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2117.value()); } if (fuzz2118.has_value()) { - const auto& value = fuzz2118.value(); - const auto result = - rerun::components::AffixFuzzer18::to_data_cell(value.data(), value.size()); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); - } - { - const auto result = create_indicator_component( - "rerun.components.AffixFuzzer1Indicator", - num_instances() - ); - if (result.is_err()) { - return result.error; - } - cells.emplace_back(std::move(result.value)); + comp_batches.emplace_back(fuzz2118.value()); } + comp_batches.emplace_back( + ComponentBatch< + components::IndicatorComponent>( + nullptr, + num_instances() + ) + ); - return cells; + return comp_batches; } } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.hpp b/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.hpp index c937876b0130..d9803eb933fd 100644 --- a/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.hpp +++ b/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -183,6 +184,10 @@ namespace rerun { std::optional> fuzz2118; + /// Name of the indicator component, used to identify the archetype when converting to a + /// list of components. + static const char INDICATOR_COMPONENT_NAME[]; + public: AffixFuzzer1() = default; @@ -619,8 +624,11 @@ namespace rerun { return 1; } - /// Creates a list of Rerun DataCell from this archetype. - Result> to_data_cells() const; + /// Collections all component lists into a list of component collections. *Attention:* + /// The returned vector references this instance and does not take ownership of any + /// data. Adding any new components to this archetype will invalidate the returned + /// component lists! + std::vector as_component_batches() const; }; } // namespace archetypes } // namespace rerun diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer1.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer1.cpp index fc93e942e303..2338ec748335 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer1.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer1.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *AffixFuzzer1::NAME = "rerun.testing.components.AffixFuzzer1"; + const char AffixFuzzer1::NAME[] = "rerun.testing.components.AffixFuzzer1"; const std::shared_ptr &AffixFuzzer1::arrow_datatype() { static const auto datatype = rerun::datatypes::AffixFuzzer1::arrow_datatype(); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer1.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer1.hpp index de242f3b1dba..fed34cb72e83 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer1.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer1.hpp @@ -23,7 +23,7 @@ namespace rerun { rerun::datatypes::AffixFuzzer1 single_required; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer1() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer10.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer10.cpp index cfe22d9885b8..f5d307148beb 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer10.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer10.cpp @@ -10,7 +10,7 @@ namespace rerun { namespace components { - const char* AffixFuzzer10::NAME = "rerun.testing.components.AffixFuzzer10"; + const char AffixFuzzer10::NAME[] = "rerun.testing.components.AffixFuzzer10"; const std::shared_ptr& AffixFuzzer10::arrow_datatype() { static const auto datatype = arrow::utf8(); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer10.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer10.hpp index f2083f40c2ae..0004d9cae0d4 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer10.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer10.hpp @@ -23,7 +23,7 @@ namespace rerun { std::optional single_string_optional; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer10() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer11.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer11.cpp index a1a05249710b..8c2f689065da 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer11.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer11.cpp @@ -10,7 +10,7 @@ namespace rerun { namespace components { - const char *AffixFuzzer11::NAME = "rerun.testing.components.AffixFuzzer11"; + const char AffixFuzzer11::NAME[] = "rerun.testing.components.AffixFuzzer11"; const std::shared_ptr &AffixFuzzer11::arrow_datatype() { static const auto datatype = arrow::list(arrow::field("item", arrow::float32(), false)); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer11.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer11.hpp index 1acdfa3e675a..4fdfff07a541 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer11.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer11.hpp @@ -23,7 +23,7 @@ namespace rerun { std::optional> many_floats_optional; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer11() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer12.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer12.cpp index 385d8f47b389..85ca4ca3a3d7 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer12.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer12.cpp @@ -10,7 +10,7 @@ namespace rerun { namespace components { - const char *AffixFuzzer12::NAME = "rerun.testing.components.AffixFuzzer12"; + const char AffixFuzzer12::NAME[] = "rerun.testing.components.AffixFuzzer12"; const std::shared_ptr &AffixFuzzer12::arrow_datatype() { static const auto datatype = arrow::list(arrow::field("item", arrow::utf8(), false)); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer12.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer12.hpp index ba6ea2df6e72..3f5f2489dc2a 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer12.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer12.hpp @@ -23,7 +23,7 @@ namespace rerun { std::vector many_strings_required; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer12() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer13.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer13.cpp index 57156c13120e..b8dc65fd87d6 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer13.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer13.cpp @@ -10,7 +10,7 @@ namespace rerun { namespace components { - const char *AffixFuzzer13::NAME = "rerun.testing.components.AffixFuzzer13"; + const char AffixFuzzer13::NAME[] = "rerun.testing.components.AffixFuzzer13"; const std::shared_ptr &AffixFuzzer13::arrow_datatype() { static const auto datatype = arrow::list(arrow::field("item", arrow::utf8(), false)); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer13.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer13.hpp index 3b12ccd9d1ef..7a5608be6d0e 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer13.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer13.hpp @@ -24,7 +24,7 @@ namespace rerun { std::optional> many_strings_optional; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer13() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer14.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer14.cpp index 6d24cb4ae4fe..64bf59a022e7 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer14.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer14.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *AffixFuzzer14::NAME = "rerun.testing.components.AffixFuzzer14"; + const char AffixFuzzer14::NAME[] = "rerun.testing.components.AffixFuzzer14"; const std::shared_ptr &AffixFuzzer14::arrow_datatype() { static const auto datatype = rerun::datatypes::AffixFuzzer3::arrow_datatype(); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer14.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer14.hpp index 2e6327a92da3..ab2b811f9981 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer14.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer14.hpp @@ -23,7 +23,7 @@ namespace rerun { rerun::datatypes::AffixFuzzer3 single_required_union; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer14() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer15.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer15.cpp index 167d07bebb6a..ff9be3f7ce1b 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer15.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer15.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char* AffixFuzzer15::NAME = "rerun.testing.components.AffixFuzzer15"; + const char AffixFuzzer15::NAME[] = "rerun.testing.components.AffixFuzzer15"; const std::shared_ptr& AffixFuzzer15::arrow_datatype() { static const auto datatype = rerun::datatypes::AffixFuzzer3::arrow_datatype(); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer15.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer15.hpp index 2907455e93f6..2dee19a45d98 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer15.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer15.hpp @@ -24,7 +24,7 @@ namespace rerun { std::optional single_optional_union; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer15() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer16.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer16.cpp index b0e6baf294ec..2fa5b243d7ed 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer16.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer16.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *AffixFuzzer16::NAME = "rerun.testing.components.AffixFuzzer16"; + const char AffixFuzzer16::NAME[] = "rerun.testing.components.AffixFuzzer16"; const std::shared_ptr &AffixFuzzer16::arrow_datatype() { static const auto datatype = arrow::list( diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer16.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer16.hpp index fd9db4eb8563..c26fee58e0b7 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer16.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer16.hpp @@ -24,7 +24,7 @@ namespace rerun { std::vector many_required_unions; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer16() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer17.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer17.cpp index 3a729b151a62..f50dee01ee10 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer17.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer17.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *AffixFuzzer17::NAME = "rerun.testing.components.AffixFuzzer17"; + const char AffixFuzzer17::NAME[] = "rerun.testing.components.AffixFuzzer17"; const std::shared_ptr &AffixFuzzer17::arrow_datatype() { static const auto datatype = arrow::list( diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer17.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer17.hpp index 491b4d8204fd..5b2025d426dc 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer17.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer17.hpp @@ -25,7 +25,7 @@ namespace rerun { std::optional> many_optional_unions; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer17() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer18.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer18.cpp index e1a3193ef533..45f2c53e2d85 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer18.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer18.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *AffixFuzzer18::NAME = "rerun.testing.components.AffixFuzzer18"; + const char AffixFuzzer18::NAME[] = "rerun.testing.components.AffixFuzzer18"; const std::shared_ptr &AffixFuzzer18::arrow_datatype() { static const auto datatype = arrow::list( diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer18.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer18.hpp index 134d5384f814..7ef230d5a952 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer18.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer18.hpp @@ -25,7 +25,7 @@ namespace rerun { std::optional> many_optional_unions; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer18() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer19.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer19.cpp index 92f6b13a4a2e..7a5145116bb2 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer19.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer19.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *AffixFuzzer19::NAME = "rerun.testing.components.AffixFuzzer19"; + const char AffixFuzzer19::NAME[] = "rerun.testing.components.AffixFuzzer19"; const std::shared_ptr &AffixFuzzer19::arrow_datatype() { static const auto datatype = rerun::datatypes::AffixFuzzer5::arrow_datatype(); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer19.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer19.hpp index af44d944c866..1d38d909c9a6 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer19.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer19.hpp @@ -25,7 +25,7 @@ namespace rerun { rerun::datatypes::AffixFuzzer5 just_a_table_nothing_shady; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer19() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer2.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer2.cpp index bd5a5f4dc985..6a9ca5a75898 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer2.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer2.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *AffixFuzzer2::NAME = "rerun.testing.components.AffixFuzzer2"; + const char AffixFuzzer2::NAME[] = "rerun.testing.components.AffixFuzzer2"; const std::shared_ptr &AffixFuzzer2::arrow_datatype() { static const auto datatype = rerun::datatypes::AffixFuzzer1::arrow_datatype(); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer2.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer2.hpp index d5f3046639dd..051db6ecefa2 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer2.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer2.hpp @@ -23,7 +23,7 @@ namespace rerun { rerun::datatypes::AffixFuzzer1 single_required; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer2() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer20.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer20.cpp index ef59114a4f4f..eac13fe1e968 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer20.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer20.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *AffixFuzzer20::NAME = "rerun.testing.components.AffixFuzzer20"; + const char AffixFuzzer20::NAME[] = "rerun.testing.components.AffixFuzzer20"; const std::shared_ptr &AffixFuzzer20::arrow_datatype() { static const auto datatype = rerun::datatypes::AffixFuzzer20::arrow_datatype(); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer20.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer20.hpp index 9ec20362953d..115444709068 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer20.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer20.hpp @@ -23,7 +23,7 @@ namespace rerun { rerun::datatypes::AffixFuzzer20 nested_transparent; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer20() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer3.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer3.cpp index 2c18982b087b..ccd566b057ae 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer3.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer3.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *AffixFuzzer3::NAME = "rerun.testing.components.AffixFuzzer3"; + const char AffixFuzzer3::NAME[] = "rerun.testing.components.AffixFuzzer3"; const std::shared_ptr &AffixFuzzer3::arrow_datatype() { static const auto datatype = rerun::datatypes::AffixFuzzer1::arrow_datatype(); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer3.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer3.hpp index 6d1aa4a3722a..8beac649e530 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer3.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer3.hpp @@ -23,7 +23,7 @@ namespace rerun { rerun::datatypes::AffixFuzzer1 single_required; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer3() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer4.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer4.cpp index f76430f65d21..2337cbe88a7c 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer4.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer4.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char* AffixFuzzer4::NAME = "rerun.testing.components.AffixFuzzer4"; + const char AffixFuzzer4::NAME[] = "rerun.testing.components.AffixFuzzer4"; const std::shared_ptr& AffixFuzzer4::arrow_datatype() { static const auto datatype = rerun::datatypes::AffixFuzzer1::arrow_datatype(); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer4.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer4.hpp index 96db78a82142..34cc550fbeb7 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer4.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer4.hpp @@ -24,7 +24,7 @@ namespace rerun { std::optional single_optional; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer4() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer5.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer5.cpp index cfe0ebcfbca6..bbc6bd04f8d9 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer5.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer5.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char* AffixFuzzer5::NAME = "rerun.testing.components.AffixFuzzer5"; + const char AffixFuzzer5::NAME[] = "rerun.testing.components.AffixFuzzer5"; const std::shared_ptr& AffixFuzzer5::arrow_datatype() { static const auto datatype = rerun::datatypes::AffixFuzzer1::arrow_datatype(); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer5.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer5.hpp index 5cba6f663fc5..d33d7b193cd9 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer5.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer5.hpp @@ -24,7 +24,7 @@ namespace rerun { std::optional single_optional; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer5() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer6.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer6.cpp index 79fec308e35e..344a1e881410 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer6.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer6.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char* AffixFuzzer6::NAME = "rerun.testing.components.AffixFuzzer6"; + const char AffixFuzzer6::NAME[] = "rerun.testing.components.AffixFuzzer6"; const std::shared_ptr& AffixFuzzer6::arrow_datatype() { static const auto datatype = rerun::datatypes::AffixFuzzer1::arrow_datatype(); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer6.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer6.hpp index aa9b4f1386bc..b0507f5ff003 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer6.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer6.hpp @@ -24,7 +24,7 @@ namespace rerun { std::optional single_optional; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer6() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer7.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer7.cpp index 0ec2b4b25e87..806adafca8c0 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer7.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer7.cpp @@ -12,7 +12,7 @@ namespace rerun { namespace components { - const char *AffixFuzzer7::NAME = "rerun.testing.components.AffixFuzzer7"; + const char AffixFuzzer7::NAME[] = "rerun.testing.components.AffixFuzzer7"; const std::shared_ptr &AffixFuzzer7::arrow_datatype() { static const auto datatype = arrow::list( diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer7.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer7.hpp index c4bc6305ef05..2f1c82f6205e 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer7.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer7.hpp @@ -25,7 +25,7 @@ namespace rerun { std::optional> many_optional; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer7() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer8.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer8.cpp index ea4dfc50170f..9a108b863e2c 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer8.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer8.cpp @@ -10,7 +10,7 @@ namespace rerun { namespace components { - const char* AffixFuzzer8::NAME = "rerun.testing.components.AffixFuzzer8"; + const char AffixFuzzer8::NAME[] = "rerun.testing.components.AffixFuzzer8"; const std::shared_ptr& AffixFuzzer8::arrow_datatype() { static const auto datatype = arrow::float32(); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer8.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer8.hpp index 5a83728f9231..f046725f1c23 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer8.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer8.hpp @@ -26,7 +26,7 @@ namespace rerun { std::optional single_float_optional; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer8() = default; diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer9.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer9.cpp index 1262e6b83fb9..8f8928e7f3dc 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer9.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer9.cpp @@ -10,7 +10,7 @@ namespace rerun { namespace components { - const char* AffixFuzzer9::NAME = "rerun.testing.components.AffixFuzzer9"; + const char AffixFuzzer9::NAME[] = "rerun.testing.components.AffixFuzzer9"; const std::shared_ptr& AffixFuzzer9::arrow_datatype() { static const auto datatype = arrow::utf8(); diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer9.hpp b/rerun_cpp/tests/generated/components/affix_fuzzer9.hpp index 66b0212bdd0e..5f0f53dc3892 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer9.hpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer9.hpp @@ -22,7 +22,7 @@ namespace rerun { std::string single_string_required; /// Name of the component, used for serialization. - static const char* NAME; + static const char NAME[]; public: AffixFuzzer9() = default; diff --git a/rerun_cpp/tests/recording_stream.cpp b/rerun_cpp/tests/recording_stream.cpp index 6cf175473f79..d955effc8907 100644 --- a/rerun_cpp/tests/recording_stream.cpp +++ b/rerun_cpp/tests/recording_stream.cpp @@ -36,14 +36,12 @@ const char* BadComponent::NAME = "bad!"; rr::Error BadComponent::error = rr::Error(rr::ErrorCode::Unknown, "BadComponent"); struct BadArchetype { - rr::Error error = rr::Error(rr::ErrorCode::Unknown, "BadArchetype"); - size_t num_instances() const { return 1; } - rr::Result> to_data_cells() const { - return error; + std::vector as_component_batches() const { + return {BadComponent()}; } }; @@ -138,16 +136,25 @@ SCENARIO("RecordingStream can be used for logging archetypes and components", TE WHEN("creating a new stream") { rr::RecordingStream stream("test", kind); + THEN("single components can be logged") { + stream.log_component_batches( + "single-components", + 2, + rrc::Point2D{1.0, 2.0}, + rrc::Color(0x00FF00FF) + ); + } + THEN("components as c-array can be logged") { rrc::Point2D c_style_array[2] = { rr::datatypes::Vec2D{1.0, 2.0}, rr::datatypes::Vec2D{4.0, 5.0}, }; - stream.log_components("as-carray", c_style_array); + stream.log_component_batch("as-carray", c_style_array); } THEN("components as std::array can be logged") { - stream.log_components( + stream.log_component_batch( "as-array", std::array{ rr::datatypes::Vec2D{1.0, 2.0}, @@ -156,8 +163,9 @@ SCENARIO("RecordingStream can be used for logging archetypes and components", TE ); } THEN("components as std::vector can be logged") { - stream.log_components( + stream.log_component_batches( "as-vector", + 2, std::vector{ rr::datatypes::Vec2D{1.0, 2.0}, rr::datatypes::Vec2D{4.0, 5.0}, @@ -170,8 +178,9 @@ SCENARIO("RecordingStream can be used for logging archetypes and components", TE rrc::Text("friend"), rrc::Text("yo"), }; - stream.log_components( + stream.log_component_batches( "as-mix", + 3, std::vector{ rrc::Point2D(rr::datatypes::Vec2D{0.0, 0.0}), rrc::Point2D(rr::datatypes::Vec2D{1.0, 3.0}), @@ -186,13 +195,24 @@ SCENARIO("RecordingStream can be used for logging archetypes and components", TE ); } + THEN("components with splatting some of them can be logged") { + stream.log_component_batches( + "log_component_batches-splat", + 2, + std::vector{ + rrc::Point2D(rr::datatypes::Vec2D{0.0, 0.0}), + rrc::Point2D(rr::datatypes::Vec2D{1.0, 3.0}), + }, + rrc::Color(0xFF0000FF) + ); + } + THEN("an archetype can be logged") { stream.log_archetype( - "archetype", - rr::archetypes::Points2D({ - rr::datatypes::Vec2D{1.0, 2.0}, - rr::datatypes::Vec2D{4.0, 5.0}, - }) + "log_archetype-splat", + rr::archetypes::Points2D( + {rr::datatypes::Vec2D{1.0, 2.0}, rr::datatypes::Vec2D{4.0, 5.0}} + ).with_colors(rrc::Color(0xFF0000FF)) ); } @@ -246,7 +266,7 @@ SCENARIO("RecordingStream can log to file", TEST_TAG) { WHEN("logging a component to the second stream") { check_logged_error([&] { - stream1->log_components( + stream1->log_component_batch( "as-array", std::array{ rr::datatypes::Vec2D{1.0, 2.0}, @@ -305,7 +325,7 @@ void test_logging_to_connection(const char* address, rr::RecordingStream& stream WHEN("logging a component and then flushing") { check_logged_error([&] { - stream.log_components( + stream.log_component_batch( "as-array", std::array{ rr::datatypes::Vec2D{1.0, 2.0}, @@ -375,18 +395,22 @@ SCENARIO("Recording stream handles invalid logging gracefully", TEST_TAG) { THEN("try_log_data_row returns the correct error") { CHECK(stream.try_log_data_row(path, 0, 0, nullptr).code == error); } - THEN("try_log_components returns the correct error") { + THEN("try_log_component_batch returns the correct error") { CHECK( - stream.try_log_components(path, std::array{v}).code == error + stream.try_log_component_batch(path, std::array{v}).code == + error ); } THEN("try_log_archetypes returns the correct error") { CHECK(stream.try_log_archetype(path, rr::archetypes::Points2D(v)).code == error); } - THEN("log_components logs the correct error") { + THEN("log_component_batch logs the correct error") { check_logged_error( [&] { - stream.log_components(std::get<0>(variant), std::array{v}); + stream.log_component_batch( + std::get<0>(variant), + std::array{v} + ); }, error ); @@ -459,59 +483,60 @@ SCENARIO("Recording stream handles serialization failure during logging graceful BadComponent::error.code = GENERATE(rr::ErrorCode::Unknown, rr::ErrorCode::ArrowStatusCode_TypeError); - THEN("calling log_components with an array logs the serialization error") { + THEN("calling log_component_batch with an array logs the serialization error") { check_logged_error( [&] { - stream.log_components(path, std::array{component, component}); + stream.log_component_batch(path, std::array{component, component}); }, component.error.code ); } - THEN("calling log_components with a vector logs the serialization error") { + THEN("calling log_component_batch with a vector logs the serialization error") { check_logged_error( [&] { - stream.log_components(path, std::vector{component, component}); + stream.log_component_batch(path, std::vector{component, component}); }, component.error.code ); } - THEN("calling log_components with a c array logs the serialization error") { + THEN("calling log_component_batch with a c array logs the serialization error") { const BadComponent components[] = {component, component}; check_logged_error( - [&] { stream.log_components(path, components); }, + [&] { stream.log_component_batch(path, components); }, component.error.code ); } - THEN("calling try_log_components with an array forwards the serialization error") { + THEN("calling try_log_component_batch with an array forwards the serialization error") { CHECK( - stream.try_log_components(path, std::array{component, component}) == + stream.try_log_component_batch(path, std::array{component, component}) == component.error ); } - THEN("calling try_log_components with a vector forwards the serialization error") { + THEN("calling try_log_component_batch with a vector forwards the serialization error") { CHECK( - stream.try_log_components(path, std::vector{component, component}) == + stream.try_log_component_batch(path, std::vector{component, component}) == component.error ); } - THEN("calling try_log_components with a c array forwards the serialization error") { + THEN("calling try_log_component_batch with a c array forwards the serialization error" + ) { const BadComponent components[] = {component, component}; - CHECK(stream.try_log_components(path, components) == component.error); + CHECK(stream.try_log_component_batch(path, components) == component.error); } } AND_GIVEN("an archetype that fails serialization") { auto archetype = BadArchetype(); - archetype.error.code = + BadComponent::error.code = GENERATE(rr::ErrorCode::Unknown, rr::ErrorCode::ArrowStatusCode_TypeError); THEN("calling log_archetype logs the serialization error") { check_logged_error( [&] { stream.log_archetype(path, archetype); }, - archetype.error.code + BadComponent::error.code ); } THEN("calling log_archetype forwards the serialization error") { - CHECK(stream.try_log_archetype(path, archetype) == archetype.error); + CHECK(stream.try_log_archetype(path, archetype) == BadComponent::error); } } }