public class IntSignalPort extends Object implements IntSignalSource
An instance of this class, when used directly, acts as a dynamic proxy
that delegates all method invocations to a pluggable input signal source.
The currently plugged input is looked up via getInput()
at every
delegation event, such that re-plugging via setInput(IntSignalSource)
has immediate effect.
If an instance of this class is compiled, usually as a subcomponent of a
complex signal network, then the compiled code shares the pluggable state of
the original orig
, and will dynamically delegate to the input signal
source returned by orig.getInput()
. Thus even complex network
modules with multiple inputs and outputs can be compiled to monolithic code,
but configured dynamically, by
IntSignalSource
and its companion classes,The pluggable input signal source can be set to null
, which will
cause the getAsInt()
method of this object to fail at runtime
with NullPointerException
.
Constructor and Description |
---|
IntSignalPort()
Creates a new instance with no specified initial input.
|
IntSignalPort(IntSignalSource input)
Creates a new instance with the specified initial input.
|
Modifier and Type | Method and Description |
---|---|
Consumer<CompilationContext> |
compileDataFlow()
Returns a code generator for outputting the value of this entity.
|
int |
getAsInt()
Returns the current value of this signal source.
|
IntSignalSource |
getInput()
Returns the current input signal source.
|
void |
setInput(IntSignalSource input)
Sets the current input signal source.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
abs, add, choose, choose, choose, choose, clock, compileMainSignalSource, constant, delayed, delayed, delayedFeedback, delayedFeedback, divide, equal, getConstantAsInt, getValueClass, greaterOrEqual, greaterThan, guard, hasConstantAsInt, invariant, lessOrEqual, lessThan, map, max, min, modulo, multiply, negate, negative, nonEqual, nonnegative, nonpositive, nonzero, positive, power, probe, publishStoredValueVariable, relateWith, sampleAndHold, stored, subtract, zero, zipWith
compileDataFlowTo, hasDataFlowIO
public IntSignalPort()
public IntSignalPort(IntSignalSource input)
input
- the input signal sourcepublic IntSignalSource getInput()
public void setInput(IntSignalSource input)
public int getAsInt()
The value may be either computed on demand, or retrieved from storage.
Implementations of this method should have no side effect.
This implementation always delegates to getInput().getAsInt()
.
getAsInt
in interface IntSignalSource
getAsInt
in interface IntSupplier
public Consumer<CompilationContext> compileDataFlow()
IntSignalSource
This implementation generates code to invoke this.getAsInt()
.
compileDataFlow
in interface CompilableDataFlow
compileDataFlow
in interface IntSignalSource