// 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/blueprint/archetypes/map_zoom.fbs".

#include "map_zoom.hpp"

#include "../../collection_adapter_builtins.hpp"

namespace rerun::blueprint::archetypes {
    MapZoom MapZoom::clear_fields() {
        auto archetype = MapZoom();
        archetype.zoom =
            ComponentBatch::empty<rerun::blueprint::components::ZoomLevel>(Descriptor_zoom)
                .value_or_throw();
        return archetype;
    }

    Collection<ComponentColumn> MapZoom::columns(const Collection<uint32_t>& lengths_) {
        std::vector<ComponentColumn> columns;
        columns.reserve(2);
        if (zoom.has_value()) {
            columns.push_back(zoom.value().partitioned(lengths_).value_or_throw());
        }
        columns.push_back(
            ComponentColumn::from_indicators<MapZoom>(static_cast<uint32_t>(lengths_.size()))
                .value_or_throw()
        );
        return columns;
    }

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

namespace rerun {

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

        if (archetype.zoom.has_value()) {
            cells.push_back(archetype.zoom.value());
        }
        {
            auto result = ComponentBatch::from_indicator<MapZoom>();
            RR_RETURN_NOT_OK(result.error);
            cells.emplace_back(std::move(result.value));
        }

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