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

#pragma once

#include "../../blueprint/datatypes/filter_by_range.hpp"
#include "../../component_descriptor.hpp"
#include "../../result.hpp"

#include <cstdint>
#include <memory>

namespace rerun::blueprint::components {
    /// **Component**: Configuration for a filter-by-range feature of the dataframe view.
    struct FilterByRange {
        rerun::blueprint::datatypes::FilterByRange range;

      public:
        FilterByRange() = default;

        FilterByRange(rerun::blueprint::datatypes::FilterByRange range_) : range(range_) {}

        FilterByRange& operator=(rerun::blueprint::datatypes::FilterByRange range_) {
            range = range_;
            return *this;
        }

        /// Cast to the underlying FilterByRange datatype
        operator rerun::blueprint::datatypes::FilterByRange() const {
            return range;
        }
    };
} // namespace rerun::blueprint::components

namespace rerun {
    static_assert(
        sizeof(rerun::blueprint::datatypes::FilterByRange) ==
        sizeof(blueprint::components::FilterByRange)
    );

    /// \private
    template <>
    struct Loggable<blueprint::components::FilterByRange> {
        static constexpr ComponentDescriptor Descriptor =
            "rerun.blueprint.components.FilterByRange";

        /// Returns the arrow data type this type corresponds to.
        static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
            return Loggable<rerun::blueprint::datatypes::FilterByRange>::arrow_datatype();
        }

        /// Serializes an array of `rerun::blueprint:: components::FilterByRange` into an arrow array.
        static Result<std::shared_ptr<arrow::Array>> to_arrow(
            const blueprint::components::FilterByRange* instances, size_t num_instances
        ) {
            if (num_instances == 0) {
                return Loggable<rerun::blueprint::datatypes::FilterByRange>::to_arrow(nullptr, 0);
            } else if (instances == nullptr) {
                return rerun::Error(
                    ErrorCode::UnexpectedNullArgument,
                    "Passed array instances is null when num_elements> 0."
                );
            } else {
                return Loggable<rerun::blueprint::datatypes::FilterByRange>::to_arrow(
                    &instances->range,
                    num_instances
                );
            }
        }
    };
} // namespace rerun
