Class LongSignalPort
- All Implemented Interfaces:
AbstractSignalSource
,CompilableDataFlow
,LongSignalSource
,LongSupplier
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
- creating an interpreted version of
the module with inputs realized as ports, i.e. instances of
LongSignalSource
and its companion classes, - compiling the module,
- retaining references to the ports,
- plugging the actual inputs into the ports,
- using the output signal sources of the compiled version in place of the interpreted one.
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 Summary
ConstructorDescriptionCreates a new instance with no specified initial input.LongSignalPort
(LongSignalSource input) Creates a new instance with the specified initial input. -
Method Summary
Modifier and TypeMethodDescriptionReturns a code generator for outputting the value of this entity.long
Returns the current value of this signal source.getInput()
Returns the current input signal source.void
setInput
(LongSignalSource input) Sets the current input signal source.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface eu.bandm.sig.adlib2.compile.CompilableDataFlow
compileDataFlowTo, hasDataFlowIO
Methods inherited from interface eu.bandm.sig.adlib2.LongSignalSource
abs, add, asInt, compileMainSignalSource, DEBUG, delayed, delayed, 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
-
Constructor Details
-
LongSignalPort
public LongSignalPort()Creates a new instance with no specified initial input. -
LongSignalPort
Creates a new instance with the specified initial input.- Parameters:
input
- the input signal source
-
-
Method Details
-
getInput
Returns the current input signal source. -
setInput
Sets the current input signal source. -
getAsLong
public long getAsLong()Returns the current value of this signal source.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()
.- Specified by:
getAsLong
in interfaceLongSignalSource
- Specified by:
getAsLong
in interfaceLongSupplier
- Returns:
- the current value of this signal source
-
compileDataFlow
Description copied from interface:LongSignalSource
Returns a code generator for outputting the value of this entity.This implementation generates code to invoke
this.getAsLong()
.- Specified by:
compileDataFlow
in interfaceCompilableDataFlow
- Specified by:
compileDataFlow
in interfaceLongSignalSource
-