// (c) MIT 2003.  All rights reserved.

package rec.agent;

import java.rmi.*;
import java.io.*;
import java.util.*;
import metaglue.*;
import rec.util.*;
import rec.sys.*;

/**
 * This is the Agent which holds a Sketching program (rec program)
 */
public interface Sketch extends Agent {

  /**
   * This gremlin gets activated on the surface.  It can do
   * whatever it needs to do.
   */
  public int takeGremlin( Gremlin g ) throws RemoteException;

  /**
   * Using this, one can remotely add modules to monitor, change,
   * fiddle, etc.  These modules have to be serializable, and are
   * not the remote type of module.
   */
  public Id installModule( Module m ) throws RemoteException;

  /**
   * This is used to build modules on the Surface which are not
   * remote modules.  The module maker's make method is called
   * with null for parent by the surface.
   */
  public Id installModule( ModuleMaker mm ) throws RemoteException;

  /**
   * This installs a module with wires going out, back to the
   * invoking agent, so it can communicate with it.  The object
   * gets created on Sketch using dynamic construction via mm
   * 
   * @return         A stub to the object installed.
   * @param  mm      This is a module maker, it constructs the 
   *                 module and returns it.  Sketch uses it to 
   *                 construct the module.
   * @param  parent  This is handed to the object in its constructor
   *                 so it can talk to its parent.  This should be
   *                 a stub to a remote object.
   */
  public RemoteModule installModule( ModuleMaker mm,
			     ModuleListener parent ) throws RemoteException;

  public RemoteModule installModule( ModuleMaker mm,
				     AgentID parent ) throws RemoteException;

  public void removeModule( Id module_id ) throws RemoteException;

  /**
   * This allows a remote object to ask questions of modules
   * watching the Surface.  query hands the query off to module with
   * given id. 
   * 
   * I think this is unneeded, due to the installModule, above.
   */
  //  public Object query( Id module, Object o ) throws RemoteException;



  /**
   * Load an .ini file and install it.
   */
  public void loadBase( String base_name ) throws RemoteException;

  /**
   * Add an utterance to the sketch system.
   **/
  public void addUtterance( WUtterance utterance ) throws RemoteException;
  
}
