CallbackMatlabProxy

public class CallbackMatlabProxy

Wraps around a MatlabProxy making the method calls which interact with MATLAB operate with callbacks instead of return values. For each method in MatlabProxy that interacts with MATLAB, the same method exists but has one additional parameter that is either MatlabCallback or MatlabDataCallback. Method invocations do not throw MatlabInvocationExceptions, but if the proxy throws a MatlabInvocationException it will be provided to the callback. All interactions with the proxy will be done in a single threaded manner. The underlying proxy methods will be completed in the order their corresponding methods in this class were called. Because method invocations on the proxy occur on a separate thread from the one calling the methods in this class, it can be used from within MATLAB on the Event Dispatch Thread (EDT). This class is unconditionally thread-safe. There are no guarantees about the relative ordering of method completion when methods are invoked both on an instance of this class and on the proxy provided to it.

Author:Joshua Kaplan

Constructors

CallbackMatlabProxy

public CallbackMatlabProxy(MatlabProxy proxy)

Constructs an instance of this class, delegating all method invocations to the proxy.

Parameters:
  • proxy

Methods

disconnect

public void disconnect(MatlabDataCallback<Boolean> callback)

Delegates to the proxy, calling the callback when the proxy’s corresponding method has completed.

Parameters:
  • callback

eval

public void eval(MatlabCallback callback, String command)

Delegates to the proxy, calling the callback when the proxy’s corresponding method has completed.

Parameters:
  • callback
  • command

exit

public void exit(MatlabCallback callback)

Delegates to the proxy, calling the callback when the proxy’s corresponding method has completed.

Parameters:
  • callback

feval

public void feval(MatlabCallback callback, String functionName, Object... args)

Delegates to the proxy, calling the callback when the proxy’s corresponding method has completed.

Parameters:
  • callback
  • functionName
  • args

getVariable

public void getVariable(MatlabDataCallback<Object> callback, String variableName)

Delegates to the proxy, calling the callback when the proxy’s corresponding method has completed.

Parameters:
  • callback
  • variableName

invokeAndWait

public <U> void invokeAndWait(MatlabThreadCallable<U> callable, MatlabDataCallback<U> callback)

Delegates to the proxy, calling the callback when the method has been executed. The name of this method has been retained for consistency with MatlabProxy, but note that while the code in the callable will be invoked on the MATLAB thread and it will wait until completion so as to return a result, this method - like all others in this class, will not wait for completion. Instead, the result will be provided to the callback.

Parameters:
  • callable
  • callback

isConnected

public void isConnected(MatlabDataCallback<Boolean> callback)

Delegates to the proxy, calling the callback when the proxy’s corresponding method has completed.

returningEval

public void returningEval(MatlabDataCallback<Object[]> callback, String command, int nargout)

Delegates to the proxy, calling the callback when the proxy’s corresponding method has completed.

Parameters:
  • callback
  • command
  • nargout

returningFeval

public void returningFeval(MatlabDataCallback<Object[]> callback, String functionName, int nargout, Object... args)

Delegates to the proxy, calling the callback when the proxy’s corresponding method has completed.

Parameters:
  • callback
  • functionName
  • nargout
  • args

setVariable

public void setVariable(MatlabCallback callback, String variableName, Object value)

Delegates to the proxy, calling the callback when the proxy’s corresponding method has completed.

Parameters:
  • callback
  • variableName
  • value

toString

public String toString()

Returns a brief description. The exact details of this representation are unspecified and are subject to change.