soundvision/UnityProject/Assets/Scripts/PdConnection/PdArrayContainer.cs

40 lines
1 KiB
C#
Raw Normal View History

2019-09-29 19:53:47 +00:00
namespace cylvester
{
2019-10-05 16:09:24 +00:00
public interface IPdArrayContainer
2019-09-29 19:53:47 +00:00
{
IPdArray this[int index] { get; }
}
public interface IUpdater
{
2019-09-29 19:53:47 +00:00
void Update();
}
2019-10-05 16:09:24 +00:00
public class PdArrayContainer : IPdArrayContainer, IUpdater
2019-09-29 19:53:47 +00:00
{
private readonly IPdArray[] arrays_;
private readonly IUpdater[] updaters_;
2019-09-29 19:53:47 +00:00
2019-10-05 16:09:24 +00:00
public PdArrayContainer(string prefix)
2019-09-29 19:53:47 +00:00
{
arrays_ = new IPdArray[PdConstant.NumMaxInputChannels];
updaters_ = new IUpdater[PdConstant.NumMaxInputChannels];
for (var i = 0; i < PdConstant.NumMaxInputChannels; ++i)
{
2019-10-05 16:09:24 +00:00
arrays_[i] = new PdArray(prefix + i, PdConstant.BlockSize);
updaters_[i] = (IUpdater) arrays_[i];
}
2019-09-29 19:53:47 +00:00
}
public void Update()
{
foreach (var updater in updaters_)
2019-09-29 19:53:47 +00:00
{
updater.Update();
2019-09-29 19:53:47 +00:00
}
}
public IPdArray this[int index] => arrays_[index];
}
}