| | | 1 | | //======================================================================= |
| | | 2 | | // NavigationMapCommitOperation.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 | | |
| | | 8 | | namespace Trailblazer.Pathing; |
| | | 9 | | |
| | | 10 | | /// <summary>Describes one deterministic prepared-map install or replacement operation.</summary> |
| | | 11 | | public readonly struct NavigationMapCommitOperation |
| | | 12 | | { |
| | | 13 | | /// <summary>Initializes an immutable prepared-map operation and its pending receipt.</summary> |
| | | 14 | | public NavigationMapCommitOperation( |
| | | 15 | | PreparedNavigationMap preparedMap, |
| | | 16 | | OverlayReplacementPolicy overlayReplacementPolicy, |
| | | 17 | | long operationSequence, |
| | | 18 | | int effectiveFrame) |
| | | 19 | | { |
| | 1311 | 20 | | SwiftThrowHelper.ThrowIfNull(preparedMap, nameof(preparedMap)); |
| | 1311 | 21 | | SwiftThrowHelper.ThrowIfArgument( |
| | 1311 | 22 | | overlayReplacementPolicy is < OverlayReplacementPolicy.PreserveAndRevalidate or > OverlayReplacementPolicy.C |
| | 1311 | 23 | | nameof(overlayReplacementPolicy)); |
| | 1309 | 24 | | SwiftThrowHelper.ThrowIfArgument( |
| | 1309 | 25 | | preparedMap.CheckpointStamp.HasValue && overlayReplacementPolicy != OverlayReplacementPolicy.Clear, |
| | 1309 | 26 | | nameof(overlayReplacementPolicy), |
| | 1309 | 27 | | "A checkpoint-stamped map can only commit with the Clear replacement policy."); |
| | 1309 | 28 | | NavigationOperationValidation.ValidateSchedule(operationSequence, effectiveFrame); |
| | | 29 | | |
| | 1309 | 30 | | PreparedMap = preparedMap; |
| | 1309 | 31 | | OverlayReplacementPolicy = overlayReplacementPolicy; |
| | 1309 | 32 | | OperationSequence = operationSequence; |
| | 1309 | 33 | | EffectiveFrame = effectiveFrame; |
| | 1309 | 34 | | Receipt = new NavigationOperationReceipt(operationSequence, effectiveFrame); |
| | 1309 | 35 | | } |
| | | 36 | | |
| | | 37 | | /// <summary>Gets the prepared inert map.</summary> |
| | | 38 | | public PreparedNavigationMap PreparedMap { get; } |
| | | 39 | | |
| | | 40 | | /// <summary>Gets the overlay replacement policy.</summary> |
| | | 41 | | public OverlayReplacementPolicy OverlayReplacementPolicy { get; } |
| | | 42 | | |
| | | 43 | | /// <summary>Gets the unique host-supplied operation sequence.</summary> |
| | | 44 | | public long OperationSequence { get; } |
| | | 45 | | |
| | | 46 | | /// <summary>Gets the earliest eligible fixed-step publication frame.</summary> |
| | | 47 | | public int EffectiveFrame { get; } |
| | | 48 | | |
| | | 49 | | /// <summary>Gets the operation's deterministic pending or terminal receipt.</summary> |
| | | 50 | | public NavigationOperationReceipt Receipt { get; } |
| | | 51 | | } |