namespace CutList.Core.Nesting.Pipeline
{
///
/// Executes a sequence of packing steps to produce a final result.
/// Provides a composable, testable approach to bin packing algorithms.
///
public class PackingPipeline
{
private readonly List _steps = new();
///
/// Adds a step to the pipeline.
///
/// The step to add.
/// This pipeline for fluent chaining.
public PackingPipeline AddStep(IPackingStep step)
{
_steps.Add(step ?? throw new ArgumentNullException(nameof(step)));
return this;
}
///
/// Executes all steps in sequence and returns the result.
///
/// The packing request to process.
/// The packing result.
public PackResult Execute(PackingRequest request)
{
var context = new PackingContext(request);
foreach (var step in _steps)
{
step.Execute(context);
}
return context.ToResult();
}
}
}