Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Energy, onHostDestruction: ensured ptr existence
[simgrid.git] / contrib / psg / src / peersim / core / Node.java
1 /*
2  * Copyright (c) 2003-2005 The BISON Project
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16  *
17  */
18
19 package peersim.core;
20
21 /**
22  * Class that represents one node with a network address. An {@link Network} is
23  * made of a set of nodes. The functionality of this class is thin: it must be
24  * able to represent failure states and store a list of protocols. It is the
25  * protocols that do the interesting job.
26  */
27 public interface Node extends Fallible, Cloneable
28 {
29
30 /**
31  * Prefix of the parameters that defines protocols.
32  * @config
33  */
34 public static final String PAR_PROT = "protocol";
35
36 /**
37  * Returns the <code>i</code>-th protocol in this node. If <code>i</code> 
38  * is not a valid protocol id
39  * (negative or larger than or equal to the number of protocols), then it throws
40  * IndexOutOfBoundsException.
41  */
42 public Protocol getProtocol(int i);
43
44 /**
45  * Returns the number of protocols included in this node.
46  */
47 public int protocolSize();
48
49 /**
50  * Sets the index of this node in the internal representation of the node list.
51  * Applications should not use this method. It is defined as public simply
52  * because it is not possible to define it otherwise.
53  * Using this method will result in
54  * undefined behavior. It is provided for the core system.
55  */
56 public void setIndex(int index);
57
58 /**
59  * Returns the index of this node. It is such that
60  * <code>Network.get(n.getIndex())</code> returns n. This index can
61  * change during a simulation, it is not a fixed id. If you need that, use
62  * {@link #getID}.
63  * @see Network#get
64  */
65 public int getIndex();
66
67 /**
68 * Returns the unique ID of the node. It is guaranteed that the ID is unique
69 * during the entire simulation, that is, there will be no different Node
70 * objects with the same ID in the system during one invocation of the JVM.
71 * Preferably nodes
72 * should implement <code>hashCode()</code> based on this ID. 
73 */
74 public long getID();
75
76 /**
77  * Clones the node. It is defined as part of the interface
78  * to change the access right to public and to get rid of the
79  * <code>throws</code> clause. 
80  */
81 public Object clone();
82
83 }