// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
// Based on "crates/store/re_types/definitions/rerun/archetypes/recording_info.fbs".

#include "recording_info.hpp"

#include "../collection_adapter_builtins.hpp"

namespace rerun::archetypes {
    RecordingInfo RecordingInfo::clear_fields() {
        auto archetype = RecordingInfo();
        archetype.start_time =
            ComponentBatch::empty<rerun::components::Timestamp>(Descriptor_start_time)
                .value_or_throw();
        archetype.name =
            ComponentBatch::empty<rerun::components::Name>(Descriptor_name).value_or_throw();
        return archetype;
    }

    Collection<ComponentColumn> RecordingInfo::columns(const Collection<uint32_t>& lengths_) {
        std::vector<ComponentColumn> columns;
        columns.reserve(2);
        if (start_time.has_value()) {
            columns.push_back(start_time.value().partitioned(lengths_).value_or_throw());
        }
        if (name.has_value()) {
            columns.push_back(name.value().partitioned(lengths_).value_or_throw());
        }
        return columns;
    }

    Collection<ComponentColumn> RecordingInfo::columns() {
        if (start_time.has_value()) {
            return columns(std::vector<uint32_t>(start_time.value().length(), 1));
        }
        if (name.has_value()) {
            return columns(std::vector<uint32_t>(name.value().length(), 1));
        }
        return Collection<ComponentColumn>();
    }
} // namespace rerun::archetypes

namespace rerun {

    Result<Collection<ComponentBatch>> AsComponents<archetypes::RecordingInfo>::as_batches(
        const archetypes::RecordingInfo& archetype
    ) {
        using namespace archetypes;
        std::vector<ComponentBatch> cells;
        cells.reserve(2);

        if (archetype.start_time.has_value()) {
            cells.push_back(archetype.start_time.value());
        }
        if (archetype.name.has_value()) {
            cells.push_back(archetype.name.value());
        }

        return rerun::take_ownership(std::move(cells));
    }
} // namespace rerun
