muskel
Class Mdfi

java.lang.Object
  extended by muskel.Mdfi
All Implemented Interfaces:
java.io.Serializable

public class Mdfi
extends java.lang.Object
implements java.io.Serializable

This is the class of MDF instructions: each MDFi has a taskId instrId opCode tokenInVector tokenOutVector readyArgNo inTokenCount outTokenCount

See Also:
Serialized Form

Field Summary
 boolean debug
           
static int NoGraphId
           
static int NoInstrId
           
static int NoOpCode
           
static int NoTokId
           
 
Constructor Summary
Mdfi()
          creates an empty MDF instruction
Mdfi(int iid, int gid, int op, int inc, int outc, Dest[] did)
          Deprecated. Creates a MDFi taking care of storing the code in the codestorage This is used only in case of user defined ParCompute code. Same parmaters of the previous, complete constructor, but the GID, which is left undefined. Plus the manager, which is needed to access the global CodeStorage
Mdfi(int iid, int gid, int op, int inc, int outc, int[] ppos, int[] diid, int[] dgid)
          Deprecated. creates the instruction
Mdfi(Manager manager, int iid, Compute op, int inc, int outc, Dest[] did)
          Creates a MDFi taking care of storing the code in the codestorage This is used only in case of user defined ParCompute code.
 
Method Summary
 DestToken[] compute(CodeStorage cs)
          Computes the MDF instruction, taking the opcode from the CodeStorage
 boolean isFireable()
          test for fireable instruction
 Mdfi mdfClone()
          This is used to clone an instruciton.
 void reloc(int offset)
          this is used to relocate instructions within a graph
 void setDest(int ppos, Dest dest)
          used to reloc output of the instruction
 void setDestGraphIds(int gid)
          sets the graph id in the destination tokens
 void setGraphId(int gid)
          assigns a graph id to the instruction, possbibly created with a Mdfi.NoGraphId value.
 void storeToken(int pos, java.lang.Object value)
          used to store an input token
 java.lang.String toString()
          overrides the Object toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public final boolean debug
See Also:
Constant Field Values

NoInstrId

public static final int NoInstrId
See Also:
Constant Field Values

NoGraphId

public static final int NoGraphId
See Also:
Constant Field Values

NoTokId

public static final int NoTokId
See Also:
Constant Field Values

NoOpCode

public static final int NoOpCode
See Also:
Constant Field Values
Constructor Detail

Mdfi

public Mdfi(int iid,
            int gid,
            int op,
            int inc,
            int outc,
            int[] ppos,
            int[] diid,
            int[] dgid)
Deprecated. creates the instruction

Parameters:
iid - is the instruction id
gid - is the graph id
tid - is the task id
op - is the opcode
inc - is the number of input tokens
outc - is the number of output tokens
ppos - is the vector of the (ordered) token order ids
diid - is the vector of (ordered) instruction destination ids
dgid - is the vector of (ordered) graph destination ids

Mdfi

public Mdfi(Manager manager,
            int iid,
            Compute op,
            int inc,
            int outc,
            Dest[] did)
Creates a MDFi taking care of storing the code in the codestorage This is used only in case of user defined ParCompute code. Same parmaters of the previous, complete constructor, but the GID, which is left undefined. Plus the manager, which is needed to access the global CodeStorage

Parameters:
manager - the manager used to compute the instruction
iid - the instruction id
op - the code to be computed by the instruction. Should be a Compute (sub)class object
inc - the input token number
outc - the output token number
did - the vector of the destinations for output tokens. The i-th output token is directed to the i-th Dest

Mdfi

public Mdfi(int iid,
            int gid,
            int op,
            int inc,
            int outc,
            Dest[] did)
Deprecated. Creates a MDFi taking care of storing the code in the codestorage This is used only in case of user defined ParCompute code. Same parmaters of the previous, complete constructor, but the GID, which is left undefined. Plus the manager, which is needed to access the global CodeStorage

Parameters:
manager - the manager used to compute the instruction
iid - the instruction id
op - the index in the codestorage of the code to be computed by the instruction.
inc - the input token number
outc - the output token number
did - the vector of the destinations for output tokens. The i-th output token is directed to the i-th Dest

Mdfi

public Mdfi()
creates an empty MDF instruction

Method Detail

mdfClone

public Mdfi mdfClone()
This is used to clone an instruciton. Called by mdClone in MdfGraph, when a new instance of the graph is to be stored with the input token from the input stream as the graph input token.
Does not clone the opcode, as this is data flow.

Returns:
a copy of the current instruction

toString

public java.lang.String toString()
overrides the Object toString

Overrides:
toString in class java.lang.Object
Returns:
the pretty printed instruction

storeToken

public void storeToken(int pos,
                       java.lang.Object value)
used to store an input token

Parameters:
pos - the position in the input token vector
value - the value of the token

compute

public DestToken[] compute(CodeStorage cs)
                    throws NonFireableInstructionException,
                           OpCodeNotPresentException
Computes the MDF instruction, taking the opcode from the CodeStorage

Parameters:
cs - the codestorage to be used to retrieve instruction code
Returns:
the vector of the result tokens (DestTokens, actually)
Throws:
NonFireableInstructionException
OpCodeNotPresentException

isFireable

public boolean isFireable()
test for fireable instruction

Returns:
returns true if all the input tokens are present and the instruction can be computed

setGraphId

public void setGraphId(int gid)
assigns a graph id to the instruction, possbibly created with a Mdfi.NoGraphId value.

Parameters:
gid - the graph id to be assigned

setDestGraphIds

public void setDestGraphIds(int gid)
sets the graph id in the destination tokens

Parameters:
gid - the graph id to be used

reloc

public void reloc(int offset)
this is used to relocate instructions within a graph

Parameters:
offset - the offset used to reloc the instruction

setDest

public void setDest(int ppos,
                    Dest dest)
used to reloc output of the instruction

Parameters:
ppos - the index of the destination to be changed
dest - the new destination