
org.jaudiolibs.pipes.graph.AbstractLinkable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pipes-graph Show documentation
Show all versions of pipes-graph Show documentation
Support for building and running graphs of Pipes UGens, based on
the audio API inside PraxisCORE.
The newest version!
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2019 Neil C Smith.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License version 3
* along with this work; if not, see http://www.gnu.org/licenses/
*
*/
package org.jaudiolibs.pipes.graph;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.DoubleConsumer;
import java.util.function.IntConsumer;
abstract class AbstractLinkable implements Consumer, Linkable {
private final Linkable source;
private Consumer sink;
AbstractLinkable(Linkable source) {
this.source = Objects.requireNonNull(source);
}
@Override
public void accept(IN value) {
process(value, sink);
}
@Override
public void link(Consumer consumer) {
this.sink = Objects.requireNonNull(consumer);
source.link(this);
}
abstract void process(IN value, Consumer sink);
abstract static class ToDouble implements Consumer, Linkable.Double {
private final Linkable source;
private DoubleConsumer sink;
ToDouble(Linkable source) {
this.source = Objects.requireNonNull(source);
}
@Override
public void accept(IN value) {
process(value, sink);
}
@Override
public void link(DoubleConsumer consumer) {
this.sink = Objects.requireNonNull(consumer);
source.link(this);
}
abstract void process(IN value, DoubleConsumer sink);
}
abstract static class ToInt implements Consumer, Linkable.Int {
private final Linkable source;
private IntConsumer sink;
ToInt(Linkable source) {
this.source = Objects.requireNonNull(source);
}
@Override
public void accept(IN value) {
process(value, sink);
}
@Override
public void link(IntConsumer consumer) {
this.sink = Objects.requireNonNull(consumer);
source.link(this);
}
abstract void process(IN value, IntConsumer sink);
}
abstract static class Double implements DoubleConsumer, Linkable.Double {
private final Linkable.Double source;
private DoubleConsumer sink;
Double(Linkable.Double source) {
this.source = Objects.requireNonNull(source);
}
@Override
public void accept(double value) {
process(value, sink);
}
@Override
public void link(DoubleConsumer consumer) {
this.sink = Objects.requireNonNull(consumer);
source.link(this);
}
abstract void process(double value, DoubleConsumer sink);
}
abstract static class DoubleToObj implements DoubleConsumer, Linkable {
private final Linkable.Double source;
private Consumer sink;
DoubleToObj(Linkable.Double source) {
this.source = Objects.requireNonNull(source);
}
@Override
public void accept(double value) {
process(value, sink);
}
@Override
public void link(Consumer consumer) {
this.sink = Objects.requireNonNull(consumer);
source.link(this);
}
abstract void process(double value, Consumer sink);
}
abstract static class Int implements IntConsumer, Linkable.Int {
private final Linkable.Int source;
private IntConsumer sink;
Int(Linkable.Int source) {
this.source = Objects.requireNonNull(source);
}
@Override
public void accept(int value) {
process(value, sink);
}
@Override
public void link(IntConsumer consumer) {
this.sink = Objects.requireNonNull(consumer);
source.link(this);
}
abstract void process(int value, IntConsumer sink);
}
abstract static class IntToObj implements IntConsumer, Linkable {
private final Linkable.Int source;
private Consumer sink;
IntToObj(Linkable.Int source) {
this.source = Objects.requireNonNull(source);
}
@Override
public void accept(int value) {
process(value, sink);
}
@Override
public void link(Consumer consumer) {
this.sink = Objects.requireNonNull(consumer);
source.link(this);
}
abstract void process(int value, Consumer sink);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy