This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-nitride-cil/src/MfGames.Nitride/Pipelines/PipelineBase.cs

53 lines
1.3 KiB
C#

using System.Collections.Generic;
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>();
}
/// <summary>
/// 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.
/// </summary>
/// <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;
}
/// <inheritdoc />
public abstract IAsyncEnumerable<Entity> RunAsync(
IEnumerable<Entity> entities);
/// <inheritdoc />
public override string ToString()
{
return this.GetType()
.Name;
}
}