46 lines
1.6 KiB
C#
46 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
|
|
namespace MultiWheelC.TrajectoryPlanning.PathSmoothing.Output.Comparison;
|
|
|
|
/// <summary>Immutable raw-path and Local G2 comparison result.</summary>
|
|
public sealed class PathSmoothingComparisonResult
|
|
{
|
|
internal PathSmoothingComparisonResult(
|
|
PathSmoothingComparisonEntry rawPathBaseline,
|
|
IReadOnlyList<PathSmoothingComparisonEntry> entries,
|
|
SmoothingMethod? recommendedMethod,
|
|
bool isCancelled,
|
|
string diagnostic)
|
|
{
|
|
RawPathBaseline = rawPathBaseline ?? throw new ArgumentNullException(nameof(rawPathBaseline));
|
|
Entries = CopyReadOnly(entries);
|
|
RecommendedMethod = recommendedMethod;
|
|
IsCancelled = isCancelled;
|
|
Diagnostic = diagnostic ?? string.Empty;
|
|
}
|
|
|
|
public PathSmoothingComparisonEntry RawPathBaseline { get; }
|
|
|
|
public IReadOnlyList<PathSmoothingComparisonEntry> Entries { get; }
|
|
|
|
/// <summary>Local G2 when its published result is deterministic; otherwise null.</summary>
|
|
public SmoothingMethod? RecommendedMethod { get; }
|
|
|
|
public bool IsCancelled { get; }
|
|
|
|
public string Diagnostic { get; }
|
|
|
|
private static IReadOnlyList<PathSmoothingComparisonEntry> CopyReadOnly(
|
|
IReadOnlyList<PathSmoothingComparisonEntry> source)
|
|
{
|
|
var copy = new List<PathSmoothingComparisonEntry>(source == null ? 0 : source.Count);
|
|
if (source != null)
|
|
{
|
|
for (int index = 0; index < source.Count; index++) copy.Add(source[index]);
|
|
}
|
|
return new ReadOnlyCollection<PathSmoothingComparisonEntry>(copy);
|
|
}
|
|
}
|