< Summary

Line coverage
100%
Covered lines: 73
Uncovered lines: 0
Coverable lines: 73
Total lines: 192
Line coverage: 100%
Branch coverage
100%
Covered branches: 12
Total branches: 12
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
File 1: .ctor(...)100%11100%
File 2: .ctor(...)100%22100%
File 2: get_GenerationCapacity()100%11100%
File 2: get_RetainedBytes()100%22100%
File 2: get_Status()100%11100%
File 2: get_RunStamp()100%22100%
File 2: Begin(...)100%66100%
File 2: MarkStale()100%11100%

File(s)

/home/runner/work/GridForge/GridForge/src/GridForge/Grids/Topology/GridCoveredAddressCursor.BoundGeneration.cs

#LineLine coverage
 1//=======================================================================
 2// GridCoveredAddressCursor.BoundGeneration.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using GridForge.Spatial;
 9
 10namespace GridForge.Grids.Topology;
 11
 12public sealed partial class GridCoveredAddressCursor
 13{
 14    internal readonly struct BoundGeneration
 15    {
 16        internal BoundGeneration(
 17            GridCoveredAddressGeneration generation,
 18            VoxelIndex minimum,
 19            VoxelIndex maximum,
 20            bool hasRange)
 21        {
 5022            Generation = generation;
 5023            Minimum = minimum;
 5024            Maximum = maximum;
 5025            HasRange = hasRange;
 5026        }
 27
 28        internal GridCoveredAddressGeneration Generation { get; }
 29        internal VoxelIndex Minimum { get; }
 30        internal VoxelIndex Maximum { get; }
 31        internal bool HasRange { get; }
 32    }
 33}

/home/runner/work/GridForge/GridForge/src/GridForge/Grids/Topology/GridCoveredAddressCursor.cs

#LineLine coverage
 1//=======================================================================
 2// GridCoveredAddressCursor.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using System;
 9using FixedMathSharp;
 10using GridForge.Configuration;
 11using GridForge.Spatial;
 12
 13namespace GridForge.Grids.Topology;
 14
 15
 16
 17/// <summary>Stores caller-owned bounded progress for a value-only covered-address query.</summary>
 18/// <remarks>
 19/// Construct with the maximum eligible generation count, begin through <see cref="GridWorld"/>, then
 20/// supply the next canonical generation-input slice to each advance call until it is consumed. Once all
 21/// declared generations are bound, pass an empty input span. The cursor retains no live grid or voxel.
 22/// </remarks>
 23public sealed partial class GridCoveredAddressCursor
 24{
 25    private const long LogicalStateBytes = 512L;
 26    private const long ArrayHeaderBytes = 24L;
 27    private const long BoundGenerationBytes = 160L;
 28
 29
 30
 31    internal readonly BoundGeneration[] Generations;
 32    internal long WorldSpawnToken;
 33    internal uint WorldVersion;
 34    internal ulong WorldChangeSequence;
 35    internal Vector3d QueryMinimum;
 36    internal Vector3d QueryMaximum;
 37    internal GridConfigurationKey FilterConfigurationKey;
 38    internal GridCoveredAddressGeneration LastBoundGeneration;
 39    internal GridCoveredAddress PendingOutput;
 40    internal VoxelIndex CurrentAddress;
 41    internal int ExpectedGenerationCount;
 42    internal int BoundGenerationCount;
 43    internal int RangeGenerationCount;
 44    internal int GenerationOrdinal;
 45    internal bool HasConfigurationFilter;
 46    internal bool HasLastBoundGeneration;
 47    internal bool HasPendingOutput;
 48    internal bool HasCurrentAddress;
 49    internal GridCoveredAddressCursorStatus CurrentStatus;
 50
 51    /// <summary>Initializes reusable storage for at most <paramref name="generationCapacity"/> eligible grids.</summary
 2452    public GridCoveredAddressCursor(int generationCapacity)
 53    {
 2454        ChronicleGuard.ThrowIfNegative(generationCapacity, nameof(generationCapacity));
 2455        Generations = generationCapacity == 0
 2456            ? Array.Empty<BoundGeneration>()
 2457            : new BoundGeneration[generationCapacity];
 2458    }
 59
 60    /// <summary>The maximum eligible generation count accepted by this cursor.</summary>
 161    public int GenerationCapacity => Generations.Length;
 62
 63    /// <summary>The deterministic logical bytes retained by this cursor and its owned generation storage.</summary>
 64    /// <remarks>Shared empty-array storage is not charged.</remarks>
 465    public long RetainedBytes => checked(
 466        LogicalStateBytes
 467        + (Generations.Length == 0
 468            ? 0L
 469            : ArrayHeaderBytes + ((long)Generations.Length * BoundGenerationBytes)));
 70
 71    /// <summary>The current query state.</summary>
 372    public GridCoveredAddressCursorStatus Status => CurrentStatus;
 73
 74    /// <summary>The cumulative number of generation validation and spatial lookup probes.</summary>
 75    public ulong LookupProbeOrdinal { get; internal set; }
 76
 77    /// <summary>The cumulative number of topology-address probes.</summary>
 78    public ulong AddressProbeOrdinal { get; internal set; }
 79
 80    /// <summary>The cumulative number of covered addresses emitted.</summary>
 81    public ulong OutputOrdinal { get; internal set; }
 82
 83    /// <summary>The exact committed world revision bound by this cursor.</summary>
 84    public GridCoveredAddressRunStamp RunStamp =>
 1985        CurrentStatus == GridCoveredAddressCursorStatus.Stale
 1986            ? default
 1987            : new GridCoveredAddressRunStamp(
 1988                WorldSpawnToken,
 1989                WorldVersion,
 1990                WorldChangeSequence);
 91
 92    internal bool Begin(
 93        long worldSpawnToken,
 94        uint worldVersion,
 95        ulong worldChangeSequence,
 96        Vector3d queryMinimum,
 97        Vector3d queryMaximum,
 98        int expectedGenerationCount,
 99        bool hasConfigurationFilter,
 100        GridConfigurationKey filterConfigurationKey)
 101    {
 28102        if (expectedGenerationCount < 0 || expectedGenerationCount > Generations.Length)
 103        {
 2104            MarkStale();
 2105            return false;
 106        }
 107
 26108        WorldSpawnToken = worldSpawnToken;
 26109        WorldVersion = worldVersion;
 26110        WorldChangeSequence = worldChangeSequence;
 26111        QueryMinimum = queryMinimum;
 26112        QueryMaximum = queryMaximum;
 26113        ExpectedGenerationCount = expectedGenerationCount;
 26114        BoundGenerationCount = 0;
 26115        RangeGenerationCount = 0;
 26116        GenerationOrdinal = 0;
 26117        HasConfigurationFilter = hasConfigurationFilter;
 26118        FilterConfigurationKey = filterConfigurationKey;
 26119        LastBoundGeneration = default;
 26120        PendingOutput = default;
 26121        CurrentAddress = default;
 26122        HasPendingOutput = false;
 26123        HasCurrentAddress = false;
 26124        HasLastBoundGeneration = false;
 26125        LookupProbeOrdinal = 0;
 26126        AddressProbeOrdinal = 0;
 26127        OutputOrdinal = 0;
 26128        CurrentStatus = expectedGenerationCount == 0
 26129            ? GridCoveredAddressCursorStatus.Complete
 26130            : GridCoveredAddressCursorStatus.More;
 26131        return true;
 132    }
 133
 134    internal GridCoveredAddressCursorStatus MarkStale()
 135    {
 9136        WorldSpawnToken = 0;
 9137        WorldVersion = 0;
 9138        WorldChangeSequence = 0;
 9139        QueryMinimum = default;
 9140        QueryMaximum = default;
 9141        FilterConfigurationKey = default;
 9142        LastBoundGeneration = default;
 9143        PendingOutput = default;
 9144        CurrentAddress = default;
 9145        ExpectedGenerationCount = 0;
 9146        BoundGenerationCount = 0;
 9147        RangeGenerationCount = 0;
 9148        GenerationOrdinal = 0;
 9149        HasConfigurationFilter = false;
 9150        HasLastBoundGeneration = false;
 9151        HasPendingOutput = false;
 9152        HasCurrentAddress = false;
 9153        LookupProbeOrdinal = 0;
 9154        AddressProbeOrdinal = 0;
 9155        OutputOrdinal = 0;
 9156        CurrentStatus = GridCoveredAddressCursorStatus.Stale;
 9157        return CurrentStatus;
 158    }
 159}