using System.Collections.Generic;
using System.Threading;
using MfGames.Gallium;
namespace MfGames.Nitride.Pipelines;
/// <summary>
/// A basic pipeline that is configured through properties and methods.
/// </summary>
public abstract class PipelineBase : IPipeline
{
private readonly List<IPipeline> dependencies;
protected PipelineBase()
this.dependencies = new List<IPipeline>();
}
/// Adds one or more pipeline dependencies into the current one. All of
/// the dependencies are guaranteed to run before this pipeline's RunAsync
/// is called.
/// <param name="pipelines">The pipelines to add as a dependency.</param>
/// <returns>The same object for chaining operations.</returns>
public PipelineBase AddDependency(params IPipeline[] pipelines)
foreach (IPipeline pipeline in pipelines)
this.dependencies.Add(pipeline);
return this;
/// <inheritdoc />
public IEnumerable<IPipeline> GetDependencies()
return this.dependencies;
public abstract IAsyncEnumerable<Entity> RunAsync(
IEnumerable<Entity> entities,
CancellationToken cancellationToken = default);
public override string ToString()
return this.GetType().Name;