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
.
- Version:
- $Revision$
- Author:
- Alberto Montresor
Field Summary |
static java.lang.String |
PEERNET_DEGREE
String name of the parameter used to determine the degree of the nodes included
in this peernet. |
static java.lang.String |
PEERNET_SIZE
String name of the parameter used to determine the number of nodes included
in this peernet. |
Method Summary |
void |
clear()
Restores the object to its initial state.
|
Nest[] |
getNests()
Return the nodes composing the simulated p2p network |
int |
size()
Returns the size of the simulated p2p network (number of nests) |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PEERNET_SIZE
public static final java.lang.String PEERNET_SIZE
- String name of the parameter used to determine the number of nodes included
in this peernet.
PEERNET_DEGREE
public static final java.lang.String PEERNET_DEGREE
- String name of the parameter used to determine the degree of the nodes included
in this peernet.
PeernetImpl
public PeernetImpl(Factory factory)
- Initialize a new Peernet factory
- Parameters:
factory
- the factory to be utilized
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
getNests
public Nest[] getNests()
- Return the nodes composing the simulated p2p network
- Specified by:
getNests
in interface Peernet
size
public int size()
- Returns the size of the simulated p2p network (number of nests)
- Specified by:
size
in interface Peernet
- Returns:
- size of the p2p network.