Eidola home

org.eidola.kernel
Class Function

java.lang.Object
  |
  +--org.eidola.kernel.event.EventBroadcaster
        |
        +--org.eidola.kernel.Container
              |
              +--org.eidola.kernel.Element
                    |
                    +--org.eidola.kernel.NamedElement
                          |
                          +--org.eidola.kernel.Function

public class Function
extends NamedElement

Holds a body of code which takes input and output parameters.

A function's parameters are Variables, which means that they are named, and they come in a list instead of a set, which means that they have an order. This is to allow a UI to show parameter passing by order (C/Java-style) or by name, or both at once if that seems most entertaining.

To the code in the function's body, both the input and output parameters behave as local variables. It's just that the inputs happen to come initialized with useful information, and the outputs go on to whoever's calling the function.

What exactly the "body of code" will looks like is yet to be determined. It may well look like your wildest dreams, or your worst nightmares, or both. It may be possible to make the "Code" class very abstract, and have different subclasses with different syntactic flavors (i.e., one more procedural, another more functional, another using some ultra-funky dataflow thingers...). Or maybe it will be raw 6502 machine code. Who can tell?

Structure:

Signature:

See note on synchronization and concurrent read safety in Container.

Version:
[Development version]
Author:
Paul Cantrell

Inner Class Summary
 class Function.Compilation
           
 
Inner classes inherited from class org.eidola.kernel.NamedElement
NamedElement.Compilation
 
Inner classes inherited from class org.eidola.kernel.Element
Element.Compilation
 
Inner classes inherited from class org.eidola.kernel.Container
Container.Compilation
 
Field Summary
static ContainerPart BODY
          Part of a function.
static ContainerPart INPUTS
          Part of a function.
static ContainerPart OUTPUTS
          Part of a function.
 
Fields inherited from class org.eidola.kernel.NamedElement
NAME
 
Fields inherited from class org.eidola.kernel.Element
OWNER
 
Fields inherited from class org.eidola.kernel.Container
CONTENTS, debugCompile
 
Fields inherited from class org.eidola.kernel.event.EventBroadcaster
debugEvents
 
Constructor Summary
Function()
          Creates a new empty abstract function that takes nothing, does nothing with it, and gives you nothing back, yet still will probably run a bit slowly....
 
Method Summary
 void addInput(Variable input)
          Adds an input parameter at the end of the parameter list.
 void addOutput(Variable output)
          Adds an output parameter at the end of the parameter list.
 void addParameter(Variable parameter, boolean in)
          Adds a parameter at the end of the parameter list.
 void dump(int i)
          Does a debug dump of this container to System.out.
 org.eidola.kernel.Function.Code getBody()
          Returns the body of code which describes the action this function takes, or null if the function is purely abstract.
 List getInputs()
          Returns the list of input parameters.
 List getOutputs()
          Returns the list of output parameters.
 void handleContentEvent(ContainerEvent event)
          Handles an event passed on from content.
protected  Container.Compilation makeNewCompilation()
          Creates a new Function.Compilation of an appropriate type for this container.
 void removeInput(Variable input)
          Removes an input parameter.
 void removeOutput(Variable output)
          Removes an output parameter.
 void removeParameter(Variable parameter, boolean in)
          Removes a parameter.
 void setInputs(List inputs)
          Sets the input parameters.
 void setOutputs(List outputs)
          Sets the output parameters.
 void setParameters(List newParameters, boolean in)
          Sets the input or output parameters.
 
Methods inherited from class org.eidola.kernel.NamedElement
broadcastEvent, getName, getSignatureVersion, setName
 
Methods inherited from class org.eidola.kernel.Element
getFullName, getIndirectOwners, getNamespace, getOwner, handleOwnerEvent, setOwner, toString
 
Methods inherited from class org.eidola.kernel.Container
compile, finalize, getCompilation, getCompileVersion, getStructureVersion, handleSelfEvent
 
Methods inherited from class org.eidola.kernel.event.EventBroadcaster
addListener, removeListener, updateBroadcasters
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INPUTS

public static final ContainerPart INPUTS
Part of a function.
See Also:
StructureChanged

OUTPUTS

public static final ContainerPart OUTPUTS
Part of a function.
See Also:
StructureChanged

BODY

public static final ContainerPart BODY
Part of a function.
See Also:
StructureChanged
Constructor Detail

Function

public Function()
Creates a new empty abstract function that takes nothing, does nothing with it, and gives you nothing back, yet still will probably run a bit slowly....
Method Detail

getInputs

public List getInputs()
Returns the list of input parameters.
Returns:
A list of Variables.

getOutputs

public List getOutputs()
Returns the list of output parameters.
Returns:
A list of Variables.

addInput

public void addInput(Variable input)
              throws IllegalElementType
Adds an input parameter at the end of the parameter list.

addOutput

public void addOutput(Variable output)
               throws IllegalElementType
Adds an output parameter at the end of the parameter list.

addParameter

public void addParameter(Variable parameter,
                         boolean in)
                  throws IllegalElementType
Adds a parameter at the end of the parameter list.
Parameters:
parameter - The parameter to add
in - True = input parameter; false = output parameter

removeInput

public void removeInput(Variable input)
Removes an input parameter.

removeOutput

public void removeOutput(Variable output)
Removes an output parameter.

removeParameter

public void removeParameter(Variable parameter,
                            boolean in)
Removes a parameter.
Parameters:
parameter - The parameter to remove
in - True = input parameter; false = output parameter

setInputs

public void setInputs(List inputs)
               throws IllegalElementType
Sets the input parameters.
Parameters:
inputs - A list of Variables. This method creates an internal copy, so it is safe to pass a list and subsequently modify it.

setOutputs

public void setOutputs(List outputs)
                throws IllegalElementType
Sets the output parameters.
Parameters:
inputs - A list of Variables. This method creates an internal copy, so it is safe to pass a list and subsequently modify it.

setParameters

public void setParameters(List newParameters,
                          boolean in)
                   throws IllegalElementType
Sets the input or output parameters.
Parameters:
inputs - A list of Variables. This method creates an internal copy, so it is safe to pass a list and subsequently modify it.
in - True = input parameters; false = output parameters

getBody

public org.eidola.kernel.Function.Code getBody()
Returns the body of code which describes the action this function takes, or null if the function is purely abstract.

handleContentEvent

public void handleContentEvent(ContainerEvent event)
Handles an event passed on from content. This handler passes SignatureChanged events from parameters, and calls Container.handleContentEvent(ContainerEvent).
Overrides:
handleContentEvent in class Container

makeNewCompilation

protected Container.Compilation makeNewCompilation()
Description copied from class: Container
Creates a new Container.Compilation of an appropriate type for this container. This method only exists because Java does not use runtime types to resolve inner class names; in other words, there are no virtual inner classes. Under normal circumstances, you will not need to call this method directly; use Container.compile() instead. It is a good idea to synchronize on the container when calling this method.
Overrides:
makeNewCompilation in class Container

dump

public void dump(int i)
Description copied from class: Container
Does a debug dump of this container to System.out.
Overrides:
dump in class Container

Eidola home