Declarativa Declarativa
 

 

Entrada

Produtos

Serviços

Inquiridor
Aplicações internet à medida
Auditoria informática
Subcontratação para I&D

Plataforma de conteúdos

Tecnologia

Web Information Systems
Web Application Maker
InterProlog

A empresa

Apresentação institucional

com.declarativa.interprolog
Class SubprocessEngine

java.lang.Object
  extended bycom.declarativa.interprolog.AbstractPrologEngine
      extended bycom.declarativa.interprolog.SubprocessEngine
All Implemented Interfaces:
PrologEngine
Direct Known Subclasses:
GNUSubprocessEngine, SWISubprocessEngine, XSBSubprocessEngine, YAPSubprocessEngine

public abstract class SubprocessEngine
extends AbstractPrologEngine

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.AbstractPrologEngine
firstJavaMessageName, interrupting, nl, prologBinDirectoryOrCommand
 
Fields inherited from interface com.declarativa.interprolog.PrologEngine
MAX_INT_VALUE, MIN_INT_VALUE, version
 
Constructor Summary
SubprocessEngine()
           
SubprocessEngine(boolean debug)
           
SubprocessEngine(String startPrologCommand)
           
SubprocessEngine(String prologCommand, boolean debug)
           
SubprocessEngine(String prologCommand, boolean debug, boolean loadFromJar)
          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 client)
          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
 boolean realCommand(String s)
          This implementation may get stuck if the command includes variables, because the Prolog top level interpreter may offer to compute more solutions; use variables prefixed with '_'
 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 setDebug(boolean debug)
          Show (or hide) debug messages, both Java and Prolog side, cf. ipIsDebugging/0.
 void shutdown()
          Shuts down the background Prolog process as well as the dependent Java threads.
 
Methods inherited from class com.declarativa.interprolog.AbstractPrologEngine
abortTasks, assignableType, command, consultAbsolute, consultFromPackage, consultRelative, deterministicGoal, deterministicGoal, deterministicGoal, deterministicGoal, doCallback, endAllTasks, findConstructor, findMethod, firstJavaMessage, getImplementationPeer, getJarDirectory, getJarDirectory, getLoadFromJar, getPrologBaseDirectory, getPrologNumericVersion, getPrologVersion, getRealJavaObject, getRealJavaObject, getRealJavaObject, handleCallback, interrupt, interruptTasks, isDebug, isIdle, isMacOS, isShutingDown, isWindowsOS, load_dynRelative, makeInvisible, printBindings, progressMessage, prologBinToBaseDirectory, registerJavaObject, setThreadedCallbacks, shortClassName, teachMoreObjects, teachMoreObjects, teachMoreObjects, teachOneObject, unescapedFilePath, unregisterJavaObject, unregisterJavaObject, unregisterJavaObjects, waitUntilAvailable, waitUntilIdle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubprocessEngine

public SubprocessEngine(String prologCommand,
                        boolean debug,
                        boolean loadFromJar)
Construct a SubprocessEngine, launching a Prolog process in background.

Parameters:
prologCommand - 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(), AbstractPrologEngine.teachMoreObjects(ObjectExamplePair[]), setDebug(boolean)

SubprocessEngine

public SubprocessEngine(String prologCommand,
                        boolean debug)

SubprocessEngine

public SubprocessEngine(String startPrologCommand)

SubprocessEngine

public SubprocessEngine(boolean debug)

SubprocessEngine

public SubprocessEngine()
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 client)
Add a OutputListener to get output from Prolog's standard output. This is a lower level interface than addPrologOutputListener(PrologOutputListener).

Parameters:
client - An object interested in Prolog's standard output
See Also:
OutputListener

addPrologStderrListener

public void addPrologStderrListener(OutputListener l)

removePrologStdoutListener

public void removePrologStdoutListener(OutputListener l)

removePrologStderrListener

public void removePrologStderrListener(OutputListener l)

setDebug

public void setDebug(boolean debug)
Description copied from class: AbstractPrologEngine
Show (or hide) debug messages, both Java and Prolog side, cf. ipIsDebugging/0. Beware that this may try to assert/retract a flag (ipIsDebugging/0) on the Prolog side, be sure to invoke this method sooner rather than later as it may get "stuck" if there are problems communicating with the Prolog engine

Specified by:
setDebug in interface PrologEngine
Overrides:
setDebug in class AbstractPrologEngine

isAvailable

public boolean isAvailable()
Prolog is thought to be idle

Specified by:
isAvailable in interface PrologEngine
Overrides:
isAvailable in class AbstractPrologEngine

shutdown

public void shutdown()
Shuts down the background Prolog process as well as the dependent Java threads.

Specified by:
shutdown in interface PrologEngine
Overrides:
shutdown in class AbstractPrologEngine

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)

realCommand

public boolean realCommand(String s)
This implementation may get stuck if the command includes variables, because the Prolog top level interpreter may offer to compute more solutions; use variables prefixed with '_'

Specified by:
realCommand in class AbstractPrologEngine
See Also:
AbstractPrologEngine.command(String)

deterministicGoal

public Object[] deterministicGoal(String G,
                                  String OVar,
                                  Object[] objectsP,
                                  String RVars)
Description copied from class: AbstractPrologEngine
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.

Specified by:
deterministicGoal in interface PrologEngine
Overrides:
deterministicGoal in class AbstractPrologEngine
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:
AbstractPrologEngine.deterministicGoal(String), AbstractPrologEngine.deterministicGoal(String,String), AbstractPrologEngine.deterministicGoal(String,String,Object[])



 Declarativa - Serviços de Informática, Lda.
  www.declarativa.com, info@declarativa.com  fax: +351-22-030-1511  tel: +351-22-030-1580
UPTEC - Parque de Ciência e Tecnologia da Universidade do Porto (GoogleMap)
Rua Actor Ferreira da Silva 100 4200-298 Porto Portugal