java.lang.Object
org.praxislive.code.CodeDelegate
- Direct Known Subclasses:
CodeContainerDelegate,CodeRootDelegate,DefaultCodeDelegate
CodeDelegate is the base class for all user rewritable code.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionask(ControlAddress destination, Object... args) Call a Control.ask(ControlAddress destination, List<Value> args) Call a Control.final <T,R> Async <R> async(T input, Async.Task<T, R> task) Run a task asynchronously and outside of the component context.<T> Optional<T> Search for an instance of the given type.Return a Lookup for finding instances of features.final booleanisLoggable(LogLevel level) Check whether the messages at the given log level are being sent.final voidSend a log message with associated Exception type.final voidSend a log message with associated Exception type.final voidSend a log message with associated Exception.final voidSend a log message.final longmillis()The current time in milliseconds since the root was started.final ComponentAddressself()Get this component's address.final ControlAddressGet the address of a control on this component.final voidtell(ControlAddress destination, double value) Send a message to a Control.final voidtell(ControlAddress destination, String value) Send a message to a Control.final voidtell(ControlAddress destination, Value value) Send a message to a Control.final voidtellIn(double seconds, ControlAddress destination, double value) Send a message to a Control in the given number of seconds or fractions of second from now.final voidtellIn(double seconds, ControlAddress destination, String value) Send a message to a Control in the given number of seconds or fractions of second from now.final voidtellIn(double seconds, ControlAddress destination, Value value) Send a message to a Control in the given number of seconds or fractions of second from now.final longtime()The current clocktime in nanoseconds.final <T> Async<T> Timeout the provided async after the given time period if it has not already been completed.final voidSend a value to a port on another component.final voidSend a value to a port on another component.final voidSend a value to a port on another component.
-
Constructor Details
-
CodeDelegate
public CodeDelegate()
-
-
Method Details
-
log
Send a log message.- Parameters:
level-msg-
-
log
Send a log message with associated Exception type.- Parameters:
level-ex-
-
log
Send a log message with associated Exception.- Parameters:
level-ex-msg-
-
log
Send a log message with associated Exception type.- Parameters:
level-type-msg-
-
isLoggable
Check whether the messages at the given log level are being sent.- Parameters:
level-- Returns:
-
transmit
Send a value to a port on another component. The other component must have the same parent.- Parameters:
componentID- ID of the other componentportID- ID of the port on the other componentvalue-
-
transmit
Send a value to a port on another component. The other component must have the same parent.- Parameters:
componentID- ID of the other componentportID- ID of the port on the other componentvalue-
-
transmit
Send a value to a port on another component. The other component must have the same parent.- Parameters:
componentID- ID of the other componentportID- ID of the port on the other componentvalue-
-
tell
Send a message to a Control.- Parameters:
destination- address of controlvalue- message value
-
tell
Send a message to a Control.- Parameters:
destination- address of controlvalue- message value
-
tell
Send a message to a Control.- Parameters:
destination- address of controlvalue- message value
-
tellIn
Send a message to a Control in the given number of seconds or fractions of second from now.- Parameters:
seconds- from nowdestination- address of controlvalue- message value
-
tellIn
Send a message to a Control in the given number of seconds or fractions of second from now.- Parameters:
seconds- from nowdestination- address of controlvalue- message value
-
tellIn
Send a message to a Control in the given number of seconds or fractions of second from now.- Parameters:
seconds- from nowdestination- address of controlvalue- message value
-
ask
Call a Control. The returnedAsyncresult will be completed by the responseCallif successful, or the resulting error. UseCall.argsto extract the result.- Parameters:
destination- address of controlargs- call arguments- Returns:
- async response
-
ask
Call a Control. The returnedAsyncresult will be completed by the responseCallif successful, or the resulting error. UseCall.argsto extract the result.- Parameters:
destination- address of controlargs- call arguments- Returns:
- async response
-
async
Run a task asynchronously and outside of the component context. All data required to complete the task should be passed in as input data. The task should not access any other data from the component during execution. If multiple inputs are required, considerList.of(java.lang.Object...).The returned
Asyncwill be completed by the task result, or the resulting error.- Type Parameters:
T- type of inputR- type of result- Parameters:
input- input datatask- async task- Returns:
- async result
-
timeout
Timeout the provided async after the given time period if it has not already been completed.- Type Parameters:
T- async type- Parameters:
seconds- timeout timeasync- async to timeout- Returns:
- async reference for convenience
-
self
Get this component's address.- Returns:
- address of self
-
self
Get the address of a control on this component.- Parameters:
control- id of control- Returns:
- address of control
-
getLookup
Return a Lookup for finding instances of features.- Returns:
- Lookup context
-
find
Search for an instance of the given type.- Type Parameters:
T-- Parameters:
type- class to search for- Returns:
- Optional wrapping the result if found, or empty if not
-
time
public final long time()The current clocktime in nanoseconds. May only be used relatively to itself, and may be negative.- Returns:
-
millis
public final long millis()The current time in milliseconds since the root was started.- Returns:
-