Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.declarativa.interprolog
Class SubprocessEngine

    java.lang.Object
      |
      +--com.declarativa.interprolog.PrologEngine
            |
            +--com.declarativa.interprolog.SubprocessEngine

public class SubprocessEngine
extends PrologEngine

A PrologEngine implemented over TCP/IP sockets. A SubprocessEngine object represents and gives access to a running Prolog process in background. Multiple instances correspond to multiple Prolog processes, outside the Java Virtual Machine.

Field Summary

Fields inherited from class com.declarativa.interprolog.PrologEngine
`firstJavaMessageName, interrupting, MAX_INT_VALUE, MIN_INT_VALUE, nl, startPrologCommand, version`

Constructor Summary
`SubprocessEngine(String startPrologCommand)`
`SubprocessEngine(String startPrologCommand, boolean debug)` Construct a SubprocessEngine, launching a Prolog process in background.

Method Summary
`void` | `addPrologOutputListener(PrologOutputListener client)` Add a PrologOutputListener to this engine.
`void` | `addPrologStderrListener(OutputListener l)`
`void` | `addPrologStdoutListener(OutputListener l)` Add a OutputListener to get output from Prolog's standard output.
`Object[]` | `deterministicGoal(String G, String OVar, Object[] objectsP, String RVars)` Synchronously calls a Prolog goal.
`boolean` | `isAvailable()` Prolog is thought to be idle
`void` | `removePrologOutputListener(PrologOutputListener client)`
`void` | `removePrologStderrListener(OutputListener l)`
`void` | `removePrologStdoutListener(OutputListener l)`
`void` | `sendAndFlush(String s)` Sends a String to Prolog's input.
`void` | `sendAndFlushLn(String s)`
`void` | `shutdown()` Shuts down the background Prolog process as well as the dependent Java threads.

Methods inherited from class com.declarativa.interprolog.PrologEngine
`abortTasks, assignableType, command, consultFromPackage, consultRelative, deterministicGoal, deterministicGoal, deterministicGoal, doCallback, findConstructor, findMethod, firstJavaMessage, getJarDirectory, getJarDirectory, getRealJavaObject, getRealJavaObject, getRealJavaObject, handleCallback, interrupt, interruptTasks, isDebug, isIdle, load_dynRelative, makeInvisible, printBindings, progressMessage, registerJavaObject, setDebug, shortClassName, teachMoreObjects, teachMoreObjects, teachOneObject, waitUntilAvailable, waitUntilIdle`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SubprocessEngine

    public SubprocessEngine(String startPrologCommand,
                            boolean debug)

  Construct a SubprocessEngine, launching a Prolog process in background.

Parameters:
  `startPrologCommand` - The command to launch Prolog, as if given from a console shell. Must not be null.
  `debug` - If true this engine will send debugging messages to System.out
See Also:
  `shutdown()`, `PrologEngine.teachMoreObjects(ObjectExamplePair[])`, `PrologEngine.setDebug(boolean)`

### SubprocessEngine

    public SubprocessEngine(String startPrologCommand)

Method Detail

### addPrologOutputListener

    public void addPrologOutputListener(PrologOutputListener client)

  Add a PrologOutputListener to this engine. All stdout and stderr output will be routed to the client.

  Parameters:
    `client` - An object interested in receiving messages depicting Prolog's progress
  See Also:
    `PrologOutputListener`

### removePrologOutputListener

    public void removePrologOutputListener(PrologOutputListener client)

### addPrologStdoutListener

    public void addPrologStdoutListener(OutputListener l)

  Add a OutputListener to get output from Prolog's standard output. This is a lower level interface than addPrologOutputListener(PrologOutputListener).

  See Also:
    `OutputListener`

### addPrologStderrListener

    public void addPrologStderrListener(OutputListener l)

### removePrologStdoutListener

    public void removePrologStdoutListener(OutputListener l)

### removePrologStderrListener

    public void removePrologStderrListener(OutputListener l)

### isAvailable

    public boolean isAvailable()

  Prolog is thought to be idle

  Overrides:
    `isAvailable` in class `PrologEngine`

### shutdown

    public void shutdown()

  Shuts down the background Prolog process as well as the dependent Java threads.

  Specified by:
    `shutdown` in class `PrologEngine`

### sendAndFlush

    public void sendAndFlush(String s)

  Sends a String to Prolog's input. Its meaning will naturally depend on the current state of Prolog: it can be a top goal, or input to an ongoing computation

### sendAndFlushLn

    public void sendAndFlushLn(String s)

### deterministicGoal

    public Object[] deterministicGoal(String G,
                                      String OVar,
                                      Object[] objectsP,
                                      String RVars)

  Description copied from class: `PrologEngine`
  Synchronously calls a Prolog goal. Only the first solution is considered. G should contain a syntactically correct Prolog term, without the trailing dot (.). Throws an IPAbortedException if a Prolog abort happens, and an IPInterruptedException if the interrupt() method was invoked.

  Overrides:
    `deterministicGoal` in class `PrologEngine`
  Parameters:
    `G` - Prolog goal term
    `OVar` - Prolog variable that will be bound to objectsP array
    `objectsP` - Array of Java objects to pass to Prolog goal
    `RVars` - Prolog list with object specifications, typically containing variables occurring in g. If null a single binding will be returned, containing a TermModel object representing the goal term solution
  Returns:
    a new array containing an object for each term in the rVars list, or null if goal fails
  See Also:
    `PrologEngine.deterministicGoal(String)`, `PrologEngine.deterministicGoal(String,String)`, `PrologEngine.deterministicGoal(String,String,Object[])`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD