public class BooleanSignalPort extends Object implements BooleanSignalSource
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(BooleanSignalSource)
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
BooleanSignalSource
and its companion classes,The pluggable input signal source can be set to null
, which will
cause the getAsBoolean()
method of this object to fail at runtime
with NullPointerException
.
Constructor and Description |
---|
BooleanSignalPort()
Creates a new instance with no specified initial input.
|
BooleanSignalPort(BooleanSignalSource 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.
|
boolean |
getAsBoolean()
Returns the current value of this signal source.
|
BooleanSignalSource |
getInput()
Returns the current input signal source.
|
void |
setInput(BooleanSignalSource input)
Sets the current input signal source.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
and, becoming, ceasing, choose, choose, choose, choose, choose, choose, choose, choose, choose, choose, choose, clock, compileMainSignalSource, constant, delayed, delayed, delayedFeedback, delayedFeedback, getConstantAsBoolean, getValueClass, guard, hasConstantAsBoolean, invariant, map, not, or, power, probe, publishStoredValueVariable, relateWith, sampleAndHold, stored, xor, zipWith
compileDataFlowTo, hasDataFlowIO
public BooleanSignalPort()
public BooleanSignalPort(BooleanSignalSource input)
input
- the input signal sourcepublic BooleanSignalSource getInput()
public void setInput(BooleanSignalSource input)
public boolean getAsBoolean()
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().getAsBoolean()
.
getAsBoolean
in interface BooleanSignalSource
getAsBoolean
in interface BooleanSupplier
public Consumer<CompilationContext> compileDataFlow()
BooleanSignalSource
This implementation generates code to invoke this.getAsBoolean()
.
compileDataFlow
in interface BooleanSignalSource
compileDataFlow
in interface CompilableDataFlow