peersim.config
Class FastConfig

java.lang.Object
  extended by peersim.config.FastConfig

public class FastConfig
extends java.lang.Object

Reads configuration regarding relations between protocols. Technically, this class is not necessary because protocols could access the configuration directly. However, it provides much faster access to "linkable" and "transport" information, enhancing runtime speed. This class is a static singleton and is initialized only when first accessed. During initialization it reads and caches the configuration info it handles.


Parameter Summary
linkable
          Parameter name in configuration that attaches a linkable protocol to a protocol.
transport
          Parameter name in configuration that attaches a transport layer protocol to a protocol.
 
Field Summary
protected static int[][] links
          This array stores the protocol ids of the Linkable protocols that are linked to the protocol given by the array index.
protected static int[] transports
          This array stores the protocol id of the Transport protocol that is linked to the protocol given by the array index.
 
Method Summary
static int getLinkable(int pid)
          Invokes getLinkable(pid, 0).
static int getLinkable(int pid, int linkIndex)
          Returns the protocol id of the linkIndex-th linkable used by the protocol identified by pid.
static int getTransport(int pid)
          Returns the id of the transport protocol used by the protocol identified by pid.
static boolean hasLinkable(int pid)
          Returns true if the given protocol has at least one linkable protocol associated with it, otherwise false.
static boolean hasTransport(int pid)
          Returns true if the given protocol has a transport protocol associated with it, otherwise false.
static int numLinkables(int pid)
          Returns the number of linkable protocols associated with a given protocol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Parameter Detail

linkable

Parameter name in configuration that attaches a linkable protocol to a protocol. The property can contain multiple protocol names, in one line, separated by non-word characters (e.g. whitespace or ",").


transport

Parameter name in configuration that attaches a transport layer protocol to a protocol.

Field Detail

links

protected static final int[][] links
This array stores the protocol ids of the Linkable protocols that are linked to the protocol given by the array index.


transports

protected static final int[] transports
This array stores the protocol id of the Transport protocol that is linked to the protocol given by the array index.

Method Detail

hasLinkable

public static boolean hasLinkable(int pid)
Returns true if the given protocol has at least one linkable protocol associated with it, otherwise false.


numLinkables

public static int numLinkables(int pid)
Returns the number of linkable protocols associated with a given protocol.


getLinkable

public static int getLinkable(int pid,
                              int linkIndex)
Returns the protocol id of the linkIndex-th linkable used by the protocol identified by pid. Throws an IllegalParameterException if there is no linkable associated with the given protocol: we assume here that this happens when the configuration is incorrect.


getLinkable

public static int getLinkable(int pid)
Invokes getLinkable(pid, 0).


hasTransport

public static boolean hasTransport(int pid)
Returns true if the given protocol has a transport protocol associated with it, otherwise false.


getTransport

public static int getTransport(int pid)
Returns the id of the transport protocol used by the protocol identified by pid. Throws an IllegalParameterException if there is no transport associated with the given protocol: we assume here that his happens when the configuration is incorrect.