|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.declarativa.interprolog.PrologEngine
The heart of InterProlog; a PrologEngine represents a Prolog abstract machine instance. This is an abstract class; you should use it just to declare variables, but must instantiate only a subclass.
Field Summary | |
String |
firstJavaMessageName
Name of first message sent to Java |
boolean |
interrupting
Prolog is handling an interrupt |
static int |
MAX_INT_VALUE
Maximum integer value. |
static int |
MIN_INT_VALUE
Minimum integer value. |
static String |
nl
Convenience for newline |
String |
startPrologCommand
File path to Prolog machine |
static String |
version
InterProlog version |
Constructor Summary | |
PrologEngine(String startPrologCommand,
boolean debug)
Create a Prolog executor, possibly spawning it in a different process or loading it into memory, depending on the implementation by our subclass. |
Method Summary | |
void |
abortTasks()
Do not invoke this |
static boolean |
assignableType(Class left,
Class right)
It is OK to assign an expression typed right to a variable typed left. |
boolean |
command(String s)
Execute a Prolog "command" |
void |
consultFromPackage(String filename,
Object requester)
Extracts a Prolog file from the jar file or directory where the requester's class came from, and asks the background Prolog process to consult it. |
void |
consultRelative(String filename,
Object requester)
Consults a Prolog file from the directory where the requester's class would come from if it did not come from a jar file. |
boolean |
deterministicGoal(String G)
A parameterless goal with no result other than success/failure. |
Object[] |
deterministicGoal(String G,
String RVars)
Useful when you're constructing objects from Prolog, but don't need to pass any from Java. |
boolean |
deterministicGoal(String G,
String OVar,
Object[] objectsP)
Useful when you want to pass objects to Prolog but don't need objects returned. |
Object[] |
deterministicGoal(String G,
String OVar,
Object[] objectsP,
String RVars)
Synchronously calls a Prolog goal. |
ResultFromJava |
doCallback(Object x)
Execute a Prolog->Java call |
static Constructor |
findConstructor(Class targetClass,
Class[] formalArguments)
Similar to findMethod(), but for constructors rather than regular methods |
static Method |
findMethod(Class targetClass,
String name,
Class[] formalArguments)
An utility building on the functionality of getMethod(), to provide the javaMessage predicate with method argument polimorphism. |
void |
firstJavaMessage()
Dummy method, whose name is used to start the callback thread |
File |
getJarDirectory()
Returns the directory containing the jar with the engine class |
static File |
getJarDirectory(Class aClass)
Returns the directory containing the jar with the given class |
Object |
getRealJavaObject(int ID)
Same as getRealJavaObject(InvisibleObject), but accepts an integer ID as argument instead |
Object |
getRealJavaObject(InvisibleObject o)
Get the object referred by the integer in a InvisibleObject wrapper. |
Object |
getRealJavaObject(Object o)
Just returns the object, untouched (but "dereferenced" if called from Prolog). |
Object |
handleCallback(Object x)
Handling of javaMessages and deterministicGoals. |
void |
interrupt()
Interrupt Prolog and make it return to its top level. |
void |
interruptTasks()
Do not invoke this |
boolean |
isAvailable()
Present implementation is always available, so this always returns true |
boolean |
isDebug()
Debug messages are being written |
boolean |
isIdle()
The engine is doing nothing |
void |
load_dynRelative(String filename,
Object requester)
|
Object |
makeInvisible(Object x)
Register an object with this Engine, so it later can be referred from Prolog without serializing it, and returns an InvisibleObject encapsulating the reference. |
static void |
printBindings(Object[] b)
Convenience for debugging |
void |
progressMessage(String s)
Debugging aid |
int |
registerJavaObject(Object x)
Register an object with this Engine, so it later can be referred from Prolog without serializing it. |
void |
setDebug(boolean d)
|
static String |
shortClassName(Class c)
|
abstract void |
shutdown()
Release Prolog engine resources, making it unusable |
boolean |
teachMoreObjects(Object[] examples)
Same as #teachMoreObjects(ObjectExamplePair[]), but example pairs are constructed with (2) repeated examples for each object |
boolean |
teachMoreObjects(ObjectExamplePair[] examples)
Send an array of object example pairs to Prolog and generate ipObjectSpec facts. |
boolean |
teachOneObject(Object example)
Same as #teachMoreObjects(ObjectExamplePair[]), but the single example pair is constructed repeating the object |
void |
waitUntilAvailable()
|
void |
waitUntilIdle()
Sleeps the current Java thread until this engine is available. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String version
public String startPrologCommand
public static final String nl
public boolean interrupting
public final String firstJavaMessageName
public static final int MAX_INT_VALUE
public static final int MIN_INT_VALUE
Constructor Detail |
public PrologEngine(String startPrologCommand, boolean debug)
startPrologCommand
- File path to Prolog machine, see subclass docs for precise semanticsdebug
- if true, print progress messages to aid debuggingMethod Detail |
public abstract void shutdown()
public File getJarDirectory()
public static File getJarDirectory(Class aClass)
public void consultFromPackage(String filename, Object requester)
filename
- The Prolog file name, including suffix; if absent ".P" is appendedrequester
- Defines where the Prolog file residesconsultRelative(String, Object)
,
load_dynRelative(String, Object)
public void consultRelative(String filename, Object requester)
filename
- The Prolog file name, including suffix; if absent ".P" is appendedrequester
- Defines where the Prolog file residespublic void load_dynRelative(String filename, Object requester)
public void interrupt()
public boolean command(String s)
public void progressMessage(String s)
public boolean isDebug()
public void setDebug(boolean d)
public static void printBindings(Object[] b)
public boolean teachOneObject(Object example)
teachMoreObjects(ObjectExamplePair[])
public boolean teachMoreObjects(Object[] examples)
teachMoreObjects(ObjectExamplePair[])
public boolean teachMoreObjects(ObjectExamplePair[] examples)
examples
- The examplesObjectExamplePair
public Object[] deterministicGoal(String G, String OVar, Object[] objectsP, String RVars)
G
- Prolog goal termOVar
- Prolog variable that will be bound to objectsP arrayobjectsP
- Array of Java objects to pass to Prolog goalRVars
- 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
deterministicGoal(String)
,
deterministicGoal(String,String)
,
deterministicGoal(String,String,Object[])
public boolean deterministicGoal(String G)
public Object[] deterministicGoal(String G, String RVars)
public boolean deterministicGoal(String G, String OVar, Object[] objectsP)
public boolean isIdle()
public void abortTasks()
public void interruptTasks()
public boolean isAvailable()
public void waitUntilAvailable()
public void waitUntilIdle()
public Object handleCallback(Object x)
x
- Argument of the callback predicatepublic final void firstJavaMessage()
public ResultFromJava doCallback(Object x)
public static Method findMethod(Class targetClass, String name, Class[] formalArguments) throws NoSuchMethodException
NoSuchMethodException
public static Constructor findConstructor(Class targetClass, Class[] formalArguments) throws NoSuchMethodException
NoSuchMethodException
public static boolean assignableType(Class left, Class right)
public static String shortClassName(Class c)
public int registerJavaObject(Object x)
x
- Object to be registeredInvisibleObject
public Object makeInvisible(Object x)
x
- Object to be registeredInvisibleObject
public Object getRealJavaObject(InvisibleObject o)
o
- An InvisibleObjectInvisibleObject
public Object getRealJavaObject(int ID)
public Object getRealJavaObject(Object o)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |