The Physiologist's Friend Simulation API

ch.unizh.ini.friend.simulation
Class AbstractAcceptsInput

java.lang.Object
  extended by ch.unizh.ini.friend.simulation.AbstractAcceptsInput
All Implemented Interfaces:
AcceptsInput, Serializable
Direct Known Subclasses:
AbstractCell, AbstractMonitor, AbstractSynapse

public abstract class AbstractAcceptsInput
extends Object
implements AcceptsInput

Provides the infrastructure for a simulation component with many inputs.

Version:
$Revision: 1.22 $
Author:
Christof Marti
See Also:
Serialized Form

Field Summary
 Collection inputs
          The input components for this one.
 
Constructor Summary
AbstractAcceptsInput()
          Creates a new instance with currently no inputs.
AbstractAcceptsInput(Collection inputs)
          Creates a new instance with the given collection of inputs.
AbstractAcceptsInput(int n)
          Creates a new instance with currently no inputs and with the given initial capacity.
AbstractAcceptsInput(Object input)
          Creates a new instance with the given input.
 
Method Summary
protected  float averageInputs()
          Returns averaged inputs.
static Object cloneObject(Object o)
          Returns a deep-clone of the given object.
static void connectOneToAll(Object source, Collection sink)
          Registers the given Object as an additional input of each of the AcceptInputs from the given collection.
static void connectOneToOne(Collection source, Collection sink)
          Registers the i-th Object from the first as an additional input of the i-th AcceptInput from the second given collection.
static Collection getCollectionInstance(AcceptsInput o, int n)
          Returns a collection of the given number of clones of the given object.
 ServesOutput getInput()
          Returns the first (if any) input.
 Collection getInputs()
          Returns a collection of all inputs to this simulation component.
protected  float integrateInputs()
          Returns summed inputs.
 void setInput(ServesOutput input)
          Sets the first (and only) input.
 void setInputs(Collection inputs)
          Sets the collection of all inputs to this simulation component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputs

public Collection inputs
The input components for this one.

Constructor Detail

AbstractAcceptsInput

public AbstractAcceptsInput()
Creates a new instance with currently no inputs.


AbstractAcceptsInput

public AbstractAcceptsInput(int n)
Creates a new instance with currently no inputs and with the given initial capacity.

Parameters:
n - Number of initial capacity for inputs.

AbstractAcceptsInput

public AbstractAcceptsInput(Collection inputs)
Creates a new instance with the given collection of inputs.

Parameters:
inputs - The collection of inputs.

AbstractAcceptsInput

public AbstractAcceptsInput(Object input)
Creates a new instance with the given input.

Parameters:
input - The input.
Method Detail

cloneObject

public static Object cloneObject(Object o)
                          throws IOException,
                                 ClassNotFoundException
Returns a deep-clone of the given object. The object and all objects it references directly or indirectly have to implement the Serializable interface for this hack to work. This method has been copied from the Java FAQ at http://www.afu.com/ and is subject to the following conditions:

Copyright

Copyright (c), 1997,1998,1999,2000,2001 Peter van der Linden. Permission to copy all or part of this work is granted for individual use, and for copies within a scholastic or academic setting. Copies may not be made or distributed for resale. The no warranty, and copyright notice must be retained verbatim and be displayed conspicuously. You need written authorization before you can include this FAQ in a book and/or a CDROM archive, and/or make a translation, and/or publish/mirror on a website (scholastic and academic use excepted). If anyone needs other permissions that aren't covered by the above, please contact the author.

No Warranty

This work is provided on an "as is" basis. The copyright holder makes no warranty whatsoever, either express or implied, regarding the work, including warranties with respect to merchantability or fitness for any purpose. Furthermore the author has been known to wear socks that don't match his pants, and to commit other egregious lapses of good fashion sense.

Parameters:
o - The first node of the object graph to be cloned.
Returns:
The corresponding node of the cloned object graph.
Throws:
IOException
ClassNotFoundException

getCollectionInstance

public static Collection getCollectionInstance(AcceptsInput o,
                                               int n)
Returns a collection of the given number of clones of the given object.

Parameters:
o - The object to be cloned.
n - The number of clones.
Returns:
The collection of clones.

connectOneToOne

public static void connectOneToOne(Collection source,
                                   Collection sink)
Registers the i-th Object from the first as an additional input of the i-th AcceptInput from the second given collection.

Parameters:
source - The data-'source' collection.
sink - The data-'sink' collection.

connectOneToAll

public static void connectOneToAll(Object source,
                                   Collection sink)
Registers the given Object as an additional input of each of the AcceptInputs from the given collection.

Parameters:
source - The data-'source' object.
sink - The data-'sink' collection.

integrateInputs

protected float integrateInputs()
Returns summed inputs.

Returns:
The summed inputs.

averageInputs

protected float averageInputs()
Returns averaged inputs.

Returns:
The averaged inputs.

getInputs

public Collection getInputs()
Returns a collection of all inputs to this simulation component.

Specified by:
getInputs in interface AcceptsInput
Returns:
The inputs.

setInputs

public void setInputs(Collection inputs)
Sets the collection of all inputs to this simulation component.

Specified by:
setInputs in interface AcceptsInput
Parameters:
inputs - The inputs.

getInput

public ServesOutput getInput()
Returns the first (if any) input.

Specified by:
getInput in interface AcceptsInput
Returns:
The input.

setInput

public void setInput(ServesOutput input)
Sets the first (and only) input.

Specified by:
setInput in interface AcceptsInput
Parameters:
input - The input.

http://www.ini.unizh.ch/~tobi/friend