- java.lang.Object
-
- org.praxislive.code.CodeDelegate
-
- Direct Known Subclasses:
CodeContainerDelegate,DefaultCodeDelegate
public abstract class CodeDelegate extends Object
CodeDelegate is the base class for all user rewritable code.
-
-
Constructor Summary
Constructors Constructor Description CodeDelegate()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Optional<T>find(Class<T> type)Search for an instance of the given type.LookupgetLookup()Return a Lookup for finding instances of features.booleanisLoggable(LogLevel level)Check whether the messages at the given log level are being sent.voidlog(LogLevel level, Class<? extends Exception> type, String msg)Send a log message with associated Exception type.voidlog(LogLevel level, Exception ex)Send a log message with associated Exception type.voidlog(LogLevel level, Exception ex, String msg)Send a log message with associated Exception.voidlog(LogLevel level, String msg)Send a log message.longmillis()The current time in milliseconds since the root was started.ComponentAddressself()Get this component's address.ControlAddressself(String control)Get the address of a control on this component.voidtell(ControlAddress destination, double value)Send a message to a Control.voidtell(ControlAddress destination, String value)Send a message to a Control.voidtell(ControlAddress destination, Value value)Send a message to a Control.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.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.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.longtime()The current clocktime in nanoseconds.voidtransmit(String componentID, String portID, double value)Send a value to a port on another component.voidtransmit(String componentID, String portID, String value)Send a value to a port on another component.voidtransmit(String componentID, String portID, Value value)Send a value to a port on another component.
-
-
-
Method Detail
-
log
public final void log(LogLevel level, String msg)
Send a log message.- Parameters:
level-msg-
-
log
public final void log(LogLevel level, Exception ex)
Send a log message with associated Exception type.- Parameters:
level-ex-
-
log
public final void log(LogLevel level, Exception ex, String msg)
Send a log message with associated Exception.- Parameters:
level-ex-msg-
-
log
public final void log(LogLevel level, Class<? extends Exception> type, String msg)
Send a log message with associated Exception type.- Parameters:
level-type-msg-
-
isLoggable
public final boolean isLoggable(LogLevel level)
Check whether the messages at the given log level are being sent.- Parameters:
level-- Returns:
-
transmit
public final void transmit(String componentID, String portID, String value)
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
public final void transmit(String componentID, String portID, Value value)
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
public final void transmit(String componentID, String portID, double value)
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
public final void tell(ControlAddress destination, String value)
Send a message to a Control.- Parameters:
destination- address of controlvalue- message value
-
tell
public final void tell(ControlAddress destination, double value)
Send a message to a Control.- Parameters:
destination- address of controlvalue- message value
-
tell
public final void tell(ControlAddress destination, Value value)
Send a message to a Control.- Parameters:
destination- address of controlvalue- message value
-
tellIn
public final void tellIn(double seconds, ControlAddress destination, String value)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
public final void tellIn(double seconds, ControlAddress destination, double value)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
public final void tellIn(double seconds, ControlAddress destination, Value value)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
-
self
public final ComponentAddress self()
Get this component's address.- Returns:
- address of self
-
self
public final ControlAddress self(String control)
Get the address of a control on this component.- Parameters:
control- id of control- Returns:
- address of control
-
getLookup
public Lookup getLookup()
Return a Lookup for finding instances of features.- Returns:
- Lookup context
-
find
public <T> Optional<T> find(Class<T> type)
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:
-
-