package net.heartshield.filter;

import org.apache.commons.math3.complex.Complex;

/**
 * Realtime batch-processing filter block interface.
 * Complex input, real output.
 *
 * @author David Madl (git@abanbytes.eu)
 * @date 2017-03-29
 */
public abstract class CRFilterBlock implements CFilterBlock {
    protected IRFilterBlock mConsumer;

    public void connect(IRFilterBlock consumer) {
        mConsumer = consumer;
    }

    /** batch-add an array and push results through consumers */
    @Override
    public void put(Complex[] x) {
        mConsumer.put(this.batch(x));
    }

    /** batch-process an array and return array of output values */
    protected abstract double[] batch(Complex[] x);
}
