#include "tensorstore/index_space/index_domain_builder.h"
template <DimensionIndex Rank = dynamic_rank>
class tensorstore::IndexDomainBuilder;

Builder class for creating an IndexDomain.

The rank may be specified either at compile time, as a template parameter, or at runtime, as a constructor parameter.

This behaves exactly like IndexTransformBuilder with an output rank of 0, except that Finalize returns an IndexDomain rather than an IndexTransform.

Examples

IndexDomain<2> t = IndexDomainBuilder<2>()
    .origin({1, 2})
    .shape({3, 4})
    .labels({"x", "y"})
    .Finalize()
    .value();

IndexDomain<> t = IndexDomainBuilder()
    .origin({1, 2, 3})
    .exclusive_max({4, 5, 6})
    .Finalize()
    .value();

Constructors

IndexDomainBuilder(std::nullptr_t);

Constructs an invalid IndexDomainBuilder.

IndexDomainBuilder(DimensionIndex rank);
IndexDomainBuilder(
    
std::integral_constant<DimensionIndex, R> rank = {});

Constructs a valid IndexDomainBuilder with the specified rank.

Methods

bool valid() const;

Returns true if this is a valid, initialized builder.

StaticOrDynamicRank<Rank> rank() const;

Returns the rank. :pre: valid() == true

span<Index, Rank> origin();

Returns the mutable origin vector, and marks the origin as having been set.

IndexDomainBuilder& origin(const Indices& indices);
IndexDomainBuilder& origin(const Index (&indices)[N]);

Sets the origin vector to the specified value.

span<Index, Rank> shape();

Returns the mutable shape vector, and marks the upper bound as having been set.

IndexDomainBuilder& shape(const Indices& indices);
IndexDomainBuilder& shape(const Index (&indices)[N]);

Sets the shape vector to the specified value. Specify a value of kInfSize to indicate an unbounded (infinite) upper bound.

span<Index, Rank> exclusive_max();

Returns the mutable exclusive_max vector, and marks the upper bound as having been set.

IndexDomainBuilder& exclusive_max(const Indices& indices);
IndexDomainBuilder& exclusive_max(const Index (&indices)[N]);

Specifies the exclusive upper bounds of the input domain. Specify a value of kInfIndex + 1 to indicate an unbounded (infinite) upper bound.

span<Index, Rank> inclusive_max();

Returns the mutable inclusive_max vector, and marks the upper bound as having been set.

IndexDomainBuilder& inclusive_max(const Indices& indices);
IndexDomainBuilder& inclusive_max(const Index (&indices)[N]);

Specifies the inclusive upper bounds. Specify a value of kInfIndex to indicate an unbounded (infinite) upper bound.

IndexDomainBuilder& bounds(const BoxLike& box);

Specifies the lower and upper bounds.

MutableBoxView<Rank> bounds();

Returns the mutable bounds box, and marks the lower and upper bounds as having been set.

IndexDomainBuilder& domain(IndexDomainView<Rank> domain);

Copies an existing domain. Individual parts of the domain may then be overridden by calling other methods.

span<std::string, Rank> labels();

Returns the mutable labels vector.

IndexDomainBuilder& labels(const Labels& labels);
IndexDomainBuilder& labels(const std::string_view (&labels)[N]);

Sets the labels vector to the specified value.

DimensionSet& implicit_lower_bounds();

Returns the mutable implicit_lower_bounds bit vector, and marks it as having been set.

IndexDomainBuilder& implicit_lower_bounds(DimensionSet x);
IndexDomainBuilder& implicit_lower_bounds(const bool (&x)[N]);

Sets the implicit_lower_bounds bit-vector to the specified value.

DimensionSet& implicit_upper_bounds();

Returns the mutable implicit_upper_bounds bit vector, and marks it as having been set.

IndexDomainBuilder& implicit_upper_bounds(DimensionSet x);
IndexDomainBuilder& implicit_upper_bounds(const bool (&x)[N]);

Sets the implicit_upper_bounds bit-vector to the specified value.

Result<IndexDomain<Rank>> Finalize();

Validates and returns the specified index domain.