Files
ParkingRobot/.task8-sweep/ParkrobTrajplanner/PathSmoothing/Visualization/SmoothingReportExportResult.cs
T

50 lines
1.9 KiB
C#
Raw Normal View History

2026-08-09 22:13:18 +08:00
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace MultiWheelC.TrajectoryPlanning.PathSmoothing.Visualization;
/// <summary>报告导出结果的稳定状态。</summary>
public enum SmoothingReportExportStatus
{
Success,
InvalidInput,
FontUnavailable,
Failed,
}
/// <summary>六张 SVG、六张 PNG 与一个 CSV 的发布结果;失败时不返回部分输出路径。</summary>
public sealed class SmoothingReportExportResult
{
internal SmoothingReportExportResult(SmoothingReportExportStatus status, string reason, IReadOnlyList<string> svgPaths, IReadOnlyList<string> pngPaths, string csvPath)
{
Status = status;
Reason = reason ?? string.Empty;
SvgPaths = Copy(svgPaths);
PngPaths = Copy(pngPaths);
CsvPath = csvPath ?? string.Empty;
}
public SmoothingReportExportStatus Status { get; }
public string Reason { get; }
public IReadOnlyList<string> SvgPaths { get; }
public IReadOnlyList<string> PngPaths { get; }
public string CsvPath { get; }
internal static SmoothingReportExportResult Success(IReadOnlyList<string> svgPaths, IReadOnlyList<string> pngPaths, string csvPath)
{
return new SmoothingReportExportResult(SmoothingReportExportStatus.Success, string.Empty, svgPaths, pngPaths, csvPath);
}
internal static SmoothingReportExportResult Failure(SmoothingReportExportStatus status, string reason)
{
return new SmoothingReportExportResult(status, reason, new string[0], new string[0], string.Empty);
}
private static IReadOnlyList<string> Copy(IReadOnlyList<string> source)
{
var copy = new List<string>(source == null ? 0 : source.Count);
if (source != null) for (int index = 0; index < source.Count; index++) copy.Add(source[index] ?? string.Empty);
return new ReadOnlyCollection<string>(copy);
}
}