AGENT INTERFACE TO THE DESIGN

1.  Attribute Tables

All ADF structures have attributes, which are stored in an extended form of a Hashtable known as an AttributeTable. Since these methods are common to all the structures, they will be covered first:

AttributeTable Methods:

public int add(String key,???? value)

add is a polymorphic function which can accept an int, float, Integer, Float, String, Boolean or Vector as its "value" argument. It will return -1 if you try to add an attribute that already exists.

public int put(String key,???? value)
The same as add, but needed to mask the hashtables normal put method. Use either in your code.

public int update(String key,???? value)
Accepts same "value" arguments as add or put. Changes the value of existing attributes. Will return -3 if the specified key does not exist.

public int force(String key,???? value)
Accepts same "value" arguments as add or put. Will write the new key and value pair out regardless of whether the key already exists or not.

public int getint(String key)
public float getfloat(String key)
Return an int or float value, respectively, associated with the given key, rather than the java Float or Integer objects. Returns -2 if the specified key is not associated with an Integer or Float value. This is a problem because it precludes storing -2 as an attribute value, so we'll have to fix it.

Constructors and methods for examining the Attribute table are exactly the same as the methods for the java Hashtable structure, namely:

  clear() 
     Clears this hashtable so that it contains no keys. 
 clone() 
     Creates a shallow copy of this hashtable. 
  contains(Object) 
     Tests if some key maps into the specified value in this hashtable. 
  containsKey(Object) 
     Tests if the specified object is a key in this hashtable. 
  elements() 
     Returns an enumeration of the values in this hashtable. 
 get(Object) 
     Returns the value to which the specified key is mapped in this hashtable. 
  isEmpty() 
     Tests if this hashtable maps no keys to values. 
  keys() 
     Returns an enumeration of the keys in this hashtable. 
  rehash() 
     Rehashes the contents of the hashtable into a hashtable with a larger capacity. 
  remove(Object) 
     Removes the key (and its corresponding value) from this hashtable. 
  size() 
     Returns the number of keys in this hashtable. 
  toString() 
     Returns a rather long string representation of this hashtable. 

2.  READVECTOR METHODS

Another construct common to many pieces of the ADU is the ReadVector. This is essentially a read-only version of the java vector, to make data about the design available for inspection by any agent. The available methods include all the methods on "Vector" that don't change the state of the vector:

  public boolean contains(Object elem) 
   public void copyInto(Object anArray[]) 
   public Object elementAt(int index) 
   public Enumeration elements() 
   public Object firstElement() 
   public int indexOf(Object elem) 
   public int indexOf(Object elem, int index) 
   public boolean isEmpty() 
   public Object lastElement() 
   public int lastIndexOf(Object elem) 
   public int lastIndexOf(Object elem, int index) 
   public int size() 
   public String toString()
Plus a few useful additions that assume everything stored in a readvector is an object with an AttributeTable attached:
public base findByName(String name) 
Returns the node, port, or adu which has a "name" attribute set to the value in the argument.

public base findByAttr(String key, Object value)
Returns the node, port, or adu which has an attribute with the specified key and corresponding value. If there is more than one, it will return the first one. Doesn't work on vector-valued attributes at the moment.

public boolean equal(Object value, Object bar)
Works on Strings, Floats, and Integers, and returns true if the values are the same. Used by the findBy methods. Replaces the java Object equals call which only returns true if you pass it 2 references to the same object!

I think I'm going to add a findAttr which returns a vector of all the base objects which contain a particular attribute, regardless of value.

----------------------

3.  ADU METHODS

A Design Unit(ADU) contains a graph of nodes and ports. As such, it has a publicly available AttributeTable, plus ReadVectors of all the nodes it contains, all external input ports, all external output ports, and a list of bindings(links) which contain pairs of ports internal to the design which are connected). Methods for examining all of this data are given above.

public AttributeTable attrib;
public ReadVector nodes;
public ReadVector links;
public ReadVector extIn;
public ReadVector extOut;

In addition, the following methods are available which change the graph:

public node addNode(String name)
Creates a new node with the specified name.

public int delNode(node n)
Unbinds all of a nodes ports and removes it.

public int copyNode(node n, String name)
Creates a copy of the old name and gives it the specified name.

public int bind(String srcname,String snodename,String portname,String nodename)
public int bind(port src,port dst)

public int unbind(String srcname,String snodename,String portname,String nodename)
public int unbind(port src,port dst)
The bind and unbind methods create or destroy links between two ports. -------------------------

4.  NODE METHODS

A node has publicly available an AttributeTable and ReadVectors of inputs and outputs.

 public AttributeTable attrib;
 public ReadVector inputs;
 public ReadVector outputs;
In addition, the following methods are available to change the state of the node:

public port addInput(String name)
public port addOutput(String name)
Create input or output ports with the specified name.

public int delInput(port in)
public int delInput(String portname)
public int delOutput(port out)
public int delOutput(String portname)
Delete input or output ports via an object handle or their name attribute.

public port getPortByName(String name)
Does what it says.

public int bind(port src,port dest)
public int bind(port src,String portname,String nodename)
public int bind(String srcname,String portname,String nodename)
public int bind(String srcname,port dest)
public int unbind(port src,port dest)
public int unbind(port src,String portname,String nodename)
public int unbind(String srcname,String portname,String nodename)
public int unbind(String srcname,port dest)
public int unbind(port src)
The bind and unbind methods create (or destroy) a link between two ports. Bind and unbind can accept any combination of port handles or names. They set the destination pointers in each port, and add to the list of links at the adu level. If the destination port is given as "null", the port is assumed to be ëxternal" and is added to the list of external inputs or outputs at the adu level. If no destination is given, all bindings to that particular port are removed.

------------------------

5.  PORT METHODS

A node has publicly available an AttributeTable a Vector of destinations. There are very few methods since all of the port bindings are done at the node or adu level.

public port getdst()
Returns the handle to the first destination.
public String getdstname()
Returns the name of the first destination.


File translated from TEX by TTH, version 0.9.