anthill.antsim.impl
Class PeernetImpl

java.lang.Object
  |
  +--anthill.antsim.impl.PeernetImpl
All Implemented Interfaces:
Clearable, Peernet

public class PeernetImpl
extends java.lang.Object
implements Peernet

This is a basic implementation of the Peernet interface. A PeernetImpl is characterized by a certain size (i.e., the number of nests composing it) and a degree (i.e., the number of links connecting it to other nests).

This Peernet implementation uses the Factory class to dynamically instantiate objects implementing Nest; the Factory instance must be opportunely instructed with an XML definition for Nest.


Field Summary
protected  int degree
          The degree of the nests, i.e. the number of links to other nests
protected  Factory factory
          Reference to the peernet factory which created this object
protected  Nest[] nests
          Nest network
protected  int nestVersion
          Nest version
protected  int size
          The size of the network, i.e. the number of nests included in it
 
Constructor Summary
PeernetImpl(Factory factory, int size, int degree)
          Initialize a new Peernet factory
 
Method Summary
 void clear()
          Restores the object to its initial state.
 Nest[] getNests()
          Return the nodes composing the simulated p2p network
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

protected Factory factory
Reference to the peernet factory which created this object

size

protected int size
The size of the network, i.e. the number of nests included in it

degree

protected int degree
The degree of the nests, i.e. the number of links to other nests

nests

protected Nest[] nests
Nest network

nestVersion

protected int nestVersion
Nest version
Constructor Detail

PeernetImpl

public PeernetImpl(Factory factory,
                   int size,
                   int degree)
Initialize a new Peernet factory
Parameters:
factory - the factory to be utilized
Method Detail

getNests

public Nest[] getNests()
Return the nodes composing the simulated p2p network
Specified by:
getNests in interface Peernet

clear

public void clear()
Restores the object to its initial state. New nests are instantiated when this method is called for the first time; if the initialization arguments for the Nest interface have been changed, the old nests are discarded and the new nests are created. In all other cases, the old nodes are cleared.
Specified by:
clear in interface Clearable