public class LongSignalPort extends Object implements LongSignalSource
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(LongSignalSource)
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
LongSignalSource
and its companion classes,The pluggable input signal source can be set to null
, which will
cause the getAsLong()
method of this object to fail at runtime
with NullPointerException
.
Constructor and Description |
---|
LongSignalPort()
Creates a new instance with no specified initial input.
|
LongSignalPort(LongSignalSource 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.
|
long |
getAsLong()
Returns the current value of this signal source.
|
LongSignalSource |
getInput()
Returns the current input signal source.
|
void |
setInput(LongSignalSource 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, getConstantAsLong, getValueClass, greaterOrEqual, greaterThan, guard, hasConstantAsLong, 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 LongSignalPort()
public LongSignalPort(LongSignalSource input)
input
- the input signal sourcepublic LongSignalSource getInput()
public void setInput(LongSignalSource input)
public long getAsLong()
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().getAsLong()
.
getAsLong
in interface LongSignalSource
getAsLong
in interface LongSupplier
public Consumer<CompilationContext> compileDataFlow()
LongSignalSource
This implementation generates code to invoke this.getAsLong()
.
compileDataFlow
in interface CompilableDataFlow
compileDataFlow
in interface LongSignalSource