// 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_background.fbs".

#include "map_background.hpp"

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

namespace rerun::blueprint::archetypes {
    MapBackground MapBackground::clear_fields() {
        auto archetype = MapBackground();
        archetype.provider =
            ComponentBatch::empty<rerun::blueprint::components::MapProvider>(Descriptor_provider)
                .value_or_throw();
        return archetype;
    }

    Collection<ComponentColumn> MapBackground::columns(const Collection<uint32_t>& lengths_) {
        std::vector<ComponentColumn> columns;
        columns.reserve(1);
        if (provider.has_value()) {
            columns.push_back(provider.value().partitioned(lengths_).value_or_throw());
        }
        return columns;
    }

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

namespace rerun {

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

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

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