The Meta-Environment API

toolbus.adapter
Class AbstractTool

java.lang.Object
  extended by toolbus.adapter.AbstractTool
All Implemented Interfaces:
IOperations
Direct Known Subclasses:
AbstractJavaTool

public abstract class AbstractTool
extends java.lang.Object
implements IOperations

This class facilitates the functions a tool needs to be able to functions.

Author:
Arnold Lankamp

Field Summary
static java.lang.String DIRECTTOOL
           
private static int PACKBUFFERSIZE
           
static java.lang.String REMOTETOOL
           
private static aterm.AFun SYMBOL_SAF
           
protected static aterm.pure.PureFactory termFactory
           
protected  ToolBridge toolBridge
          This variable MUST be set before tool interaction can take place.
 
Fields inherited from interface toolbus.IOperations
ACKDO, ACKEVENT, CONNECT, DEBUGPERFORMANCESTATS, DISCONNECT, DO, END, EVAL, EVENT, PERFORMANCESTATS, REQUEST, RESPONSE, TERMINATE, UNDEFINED, VALUE
 
Constructor Summary
AbstractTool()
          Default constructor.
 
Method Summary
abstract  void connect(java.lang.String[] args)
          Connects to the ToolBus.
 void disconnect(aterm.ATerm aTerm)
          Sends a disconnect request to the ToolBus.
static aterm.pure.PureFactory getFactory()
          Returns a reference to the aterm factory.
 ToolBridge getToolBridge()
          Returns a reference to the tool bridge that we're using.
static aterm.ATerm pack(aterm.ATerm termData)
          Packs the given term.
abstract  void receiveAckEvent(aterm.ATerm aTerm)
          Receives an acknowledgement message.
abstract  void receiveTerminate(aterm.ATerm aTerm)
          Receives a termination message.
 void sendEvent(aterm.ATerm aTerm)
          Posts an event to the ToolBus.
 aterm.ATermAppl sendRequest(aterm.ATerm aTerm)
          Posts a request to the ToolBus.
 void setToolBridge(ToolBridge toolBridge)
          Sets the reference ot the tool bridge we're using.
 void terminate()
          Terminated this Tool.
static aterm.ATerm unpack(aterm.ATerm packedTerm)
          Unpacks the given term.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

termFactory

protected static final aterm.pure.PureFactory termFactory

DIRECTTOOL

public static final java.lang.String DIRECTTOOL
See Also:
Constant Field Values

REMOTETOOL

public static final java.lang.String REMOTETOOL
See Also:
Constant Field Values

PACKBUFFERSIZE

private static final int PACKBUFFERSIZE
See Also:
Constant Field Values

SYMBOL_SAF

private static final aterm.AFun SYMBOL_SAF

toolBridge

protected ToolBridge toolBridge
This variable MUST be set before tool interaction can take place.

Constructor Detail

AbstractTool

public AbstractTool()
Default constructor.

Method Detail

connect

public abstract void connect(java.lang.String[] args)
                      throws java.lang.Exception
Connects to the ToolBus.

Parameters:
args - The arguments that contain the required information for running a tool (name + id and additionally the host + port of the ToolBus, depending on how this tool is connected to the ToolBus).
Throws:
java.lang.Exception - Thrown when something goes wrong during the parsing of the arguments or the establishing of the connection.

setToolBridge

public void setToolBridge(ToolBridge toolBridge)
Sets the reference ot the tool bridge we're using.

Parameters:
toolBridge - The reference ot the tool bridge we're using.

getToolBridge

public ToolBridge getToolBridge()
Returns a reference to the tool bridge that we're using.

Returns:
A reference to the tool bridge that we're using.

getFactory

public static aterm.pure.PureFactory getFactory()
Returns a reference to the aterm factory.

Returns:
A reference to the aterm factory.

sendEvent

public void sendEvent(aterm.ATerm aTerm)
Posts an event to the ToolBus.

Parameters:
aTerm - The term that contains the data about the event.

sendRequest

public aterm.ATermAppl sendRequest(aterm.ATerm aTerm)
Posts a request to the ToolBus.

Parameters:
aTerm - The term that contains the data about the request.
Returns:
The response.

disconnect

public void disconnect(aterm.ATerm aTerm)
Sends a disconnect request to the ToolBus.

Parameters:
aTerm - The term that contains information about the event.

terminate

public void terminate()
Terminated this Tool.


receiveAckEvent

public abstract void receiveAckEvent(aterm.ATerm aTerm)
Receives an acknowledgement message.

Parameters:
aTerm - The term containing information about the acknowledgement.

receiveTerminate

public abstract void receiveTerminate(aterm.ATerm aTerm)
Receives a termination message.

Parameters:
aTerm - The term containing information about the termination.

pack

public static aterm.ATerm pack(aterm.ATerm termData)
Packs the given term.

Parameters:
termData - The term that needs to be packed.
Returns:
The packed version of the given term.

unpack

public static aterm.ATerm unpack(aterm.ATerm packedTerm)
Unpacks the given term.

Parameters:
packedTerm - The term that needs to be unpacked.
Returns:
The unpacked version of the given term.

The Meta-Environment API