Note: This is an HTML facsimile of the actual Java code. To see the code itself in its most current version, you can look at BasicRunService.java in the directory \Hyperwire\Classes\kinetix\hyperc1\runtime\.

package kinetix.hyperc1.runtime;

/********************************************************************************\
**                                                                              **
**  (C) Copyright 1997 by Autodesk, Inc.                                        **
**                                                                              **
**  This program is copyrighted by Autodesk, Inc. and is licensed to you under  **
**  the following conditions.  You may not distribute or publish the source     **
**  code of this program in any form.  You may incorporate this code in object  **
**  form in derivative works provided such derivative works are (i.) are de-    **
**  signed and intended to work solely with Autodesk, Inc. products, and (ii.)  **
**  contain Autodesk's copyright notice "(C) Copyright 1997 by Autodesk, Inc."  **
**                                                                              **
**  AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.  AUTODESK SPE-  **
**  CIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR  **
**  A PARTICULAR USE.  AUTODESK, INC.  DOES NOT WARRANT THAT THE OPERATION OF   **
**  THE PROGRAM WILL BE UNINTERRUPTED OR ERROR FREE.                            **
**                                                                              **
\********************************************************************************/

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.util.Vector;

/** Basic system service interface common to all plug-ins 
 * This provides general utility methods and queries for 
 * properties maintained internally by the system for all
 * plug-ins (such as userdata)
 */
public interface BasicRunService
{
	/** siGetApplet **
	* Returns a reference to the applet
	*/
	public HwApplet siGetApplet();

	/** siGetPlugIns **
	* Returns a the collection of plug-ins in this applet
	*/
	public Vector siGetPlugIns();

	/** siGetChildPlugIns **
	* Returns a the collection of plug-ins which are immediate children of this
	* plug-in.
	*/
	public Vector siGetChildPlugIns();

	/** siGetNumChildPlugIns **
	* Returns a the number of plug-ins which are immediate children of this
	* plug-in.
	*/
	public int siGetNumChildPlugIns();

	/** siGetDescendentPlugIns **
	* Returns a the collection of plug-ins which are descendents of this
	* plug-in.  Does not include this plug-in itself.
	*/
	public Vector siGetDescendentPlugIns();

	/** siGetSiblingPlugInNamed **
	* Finds a named plug-in instance in the same container as this plug-in instance (i.e., a sibling).
	* Return null is no plug-in of the given name was found.
	*/
	public BasicRunPlugIn siGetSiblingPlugInNamed(String name);

	/** siGetCurrentFocus **
	* Returns a reference to the plug-in which currently has
	* input focus, or null if focus is not assigned
	*/
	public BasicRunPlugIn siGetCurrentFocus();

	/** siGetEmbeddedData **
	* Returns the user data associated with plug-in at runtime
	*/
	public HwObject siGetEmbeddedData();

	/** siGetModuleName **
	* Returns the name of the module.
	*/
	public String siGetModuleName();

	/** siGetOwner **
	* Returns the plug-in which owns the caller or null
	*/
	public BasicRunPlugIn siGetOwner();

	/** siGetAbsParentRect **
	* Returns the bounding rectangle for the plug-in's parent relative
	* only to the surrounding applet, not to any intermediary
	* visual containers.  Returns the degenerate rectangle
	* Rectangle(0, 0, 0, 0) if this message is sent to the root
	* container.
	*/
	public Rectangle siGetAbsParentRect();

	/** siPerformInput **
	* Triggers the wire messages associated with the input port aName
	* using arguments args
	*/
	public HwObject siPerformInput(String aName)
		throws HwException;
	public HwObject siPerformInput(String aName, HwObject[] args)
		throws HwException;
 	public HwObject siPerformInput(String aName, HwObject arg1)
		throws HwException;
 	public HwObject siPerformInput(String aName, HwObject arg1, HwObject arg2)
 		throws HwException;
 	public HwObject siPerformInput(String aName, HwObject arg1, HwObject arg2, HwObject arg3)
 		throws HwException;

	/** siPerformOutput **
	* Triggers the wire messages associated with the output port aName
	* using arguments args
	*/
	public HwObject siPerformOutput(String aName, HwObject[] args)
		throws HwException;
	public HwObject siPerformOutput(String aName)
 		throws HwException;
 	public HwObject siPerformOutput(String aName, HwObject arg1)
		throws HwException;
 	public HwObject siPerformOutput(String aName, HwObject arg1, HwObject arg2)
 		throws HwException;
 	public HwObject siPerformOutput(String aName, HwObject arg1, HwObject arg2, HwObject arg3)
 		throws HwException;

	/** siLogException **
	* Writes an exception to the error output. This should only be called
	* when an exception is not thrown again. Generally this is when the
	* caller is actually at the base of the calling stack which generated
	* the exception, or a system callback
	*/
	public void siLogException(Exception e);

	/** siProcessException **
	* Converts a general exception into a Hw basic exception and
	* appends a description of the context in which the exception
	* occurred via the argument errMsg. Callers of siProcessException
	* should generally rethrow the HwException which is returned
	* unless the caller is the at the base of the calling stack which
	* generated the exception. If errMsg is null, no description is appended
	* to the exception
	*/
	public HwException siProcessException(Exception e, String errMsg);

	/** siProcessRangeException **
	* Appends a description of the context in which the range exception
	* occurred via the argument errMsg. If errMsg is null, no description 
	* is appended to the exception. The error is either immediately logged if
	* the applet wants to continue from the point where the exception occurred
	* or it is rethrown if the applet wishes to treat out of range conditions
	* as true exceptions 
	*/
	public HwException siProcessRangeException(RangeException e, String errMsg)
		throws RangeException;

	/** siGetOutput **
	* Returns the MessageTableEntry for the output port aName.
	* The message table entry can then be evaluated by sending the
	* evaluateWith(HwObject[] args) message to it.  The typical
	* reason for using this technique vs. just calling siPerformOutput(...)
	* is one of performance.  It is possible to cache the MessageTableEntry
	* such that subsequent evaluations are very fast.  This might be useful
	* (for example) in inner-loop type code where the port is evaluated
	* many thousands of times per second.  For example:
	*
	*		private MessageTableEntry mMyFooCacheIV;
	*		private boolean mFooPortHasWires;
	*
	*		public void piEventAppletInit(Applet theApplet) throws HwException
	*			{
	*			mMyFooCacheIV = aRunService.siGetOutput("Foo");
	*			mFooPortHasWires = (mMyFooCacheIV != null) && mMyFooCacheIV.hasWires();
	*					.
	*					.
	*					.
	*			}
	*
	*		private void someFunctionInMyPlugIn()
	*			{
	*			if (mFooPortHasWires)
	*				{
	*				for (int i = 0; i < GIZILLION; i++)
	*					mMyFooCacheIV.evaluate();
	*				}
	*			}
	*
	*/
	public MessageTableEntry siGetOutput(String aName);

	/** siPlugInWantsTicks **
	* Controls whether or not the plug-in receives the 
	* piEventRefreshDaemonTick(...) messages.  This method
	* is typically called by the plug-in in the piEventAppletInit()
	* method.  It should not be called in inner-loop code as it
	* is *not* lightweight.  Return value indicates whether or
	* not the call resulted in a state change.
	*/
	public boolean siPlugInWantsTicks(boolean wantTick);

	/** siPlugInWantsKeyEvents **
	* Controls whether or not the plug-in receives the 
	* piEventKeyDown(...) and piEventKeyUp(...) messages.  This method
	* is typically called by the plug-in in the piEventAppletInit()
	* method.  It should not be called in inner-loop code as it
	* is *not* lightweight.  Return value indicates whether or
	* not the call resulted in a state change.
	*/
	public boolean siPlugInWantsKeyEvents(boolean wantsKeys);

	/** siPropertiesChanged **
	* Informs the system that a copy of a property which was initially
	* authored has changed at run-time. This is used to determine whether
	* the run-time properties may have to be reinitialized at some
	* later point in time to their initially authored values
	*/
	public void siPropertiesChanged();

	/** siReset **
	* Explicitly requests the system to reinitialize all properties to 
	* their initially authored values
	*/
	public void siReset()
		throws HwException;

	/** siSetCurrentFocus **
	* Informs the system that input focus has been assigned to a
	* plug-in
	*/
	public void siSetCurrentFocus(BasicRunPlugIn aPlugIn);

    /** setRadioNodule **
    * Informs the system that this plug-in wants control of the radio state **
    */
	public void siSetRadioNodule();


	/** siGetRefreshDaemon **
	* Returns the RefreshDaemon instance for this applet.
	*/
	public RefreshDaemon siGetRefreshDaemon();

	/** siSetCapture **
	* Captures the mouse.  Similar to the Windows SetCapture function.  Sets mouse
	* capture to a given plug-in.  Passing null as the plug-in is equivalent to
	* calling siReleaseCapture.  The return value is the plug-in which previously
	* has mouse capture, or null if none.  A module which has the mouse captured
	* will receive piMouseDown, piMouseUp, piMouseMove and piMouseDrag events
	* directly, bypassing the normal broadcast mechanism.  See also: siReleaseCapture
	* and siGetCapture.
	*/
	public BasicRunPlugIn siSetCapture(BasicRunPlugIn aPlugIn);

	/** siReleaseCapture **
	* Releases mouse capture.  Similar to the Windows ReleaseCapture function.  
	* Releases the current mouse capture (if any).  After the call, no plug-in
	* has mouse capture.  The return value is the plug-in which previously
	* has mouse capture, or null if none.  A module which has the mouse captured
	* will receive piMouseDown, piMouseUp, piMouseMove and piMouseDrag events
	* directly, bypassing the normal broadcast mechanism.  See also: siSetCapture
	* and siGetCapture.
	*/
	public BasicRunPlugIn siReleaseCapture();

	/** siGetCapture **
	* Queries mouse capture.  Similar to the Windows GetCapture function.  
	* Returns the plug-in which currently has the mouse captured (if any).
	* A module which has the mouse captured
	* will receive piMouseDown, piMouseUp, piMouseMove and piMouseDrag events
	* directly, bypassing the normal broadcast mechanism.  See also: siSetCapture
	* and siReleaseCapture.
	*/
	public BasicRunPlugIn siGetCapture();
}