X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ff6cb26262ba25fefdf1265628265a75d790ebd6..200986a368bbbbb5df459d43cbc7f5ef3d7678db:/contrib/psg/src/peersim/core/GeneralNode.java
diff --git a/contrib/psg/src/peersim/core/GeneralNode.java b/contrib/psg/src/peersim/core/GeneralNode.java
new file mode 100644
index 0000000000..2f2c02eb3c
--- /dev/null
+++ b/contrib/psg/src/peersim/core/GeneralNode.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2003-2005 The BISON Project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+package peersim.core;
+
+import peersim.config.*;
+
+/**
+* This is the default {@link Node} class that is used to compose the
+* {@link Network}.
+*/
+public class GeneralNode implements Node {
+
+
+// ================= fields ========================================
+// =================================================================
+
+/** used to generate unique IDs */
+private static long counterID = -1;
+
+/**
+* The protocols on this node.
+*/
+protected Protocol[] protocol = null;
+
+/**
+* The current index of this node in the node
+* list of the {@link Network}. It can change any time.
+* This is necessary to allow
+* the implementation of efficient graph algorithms.
+*/
+private int index;
+
+/**
+* The fail state of the node.
+*/
+protected int failstate = Fallible.OK;
+
+/**
+* The ID of the node. It should be final, however it can't be final because
+* clone must be able to set it.
+*/
+private long ID;
+
+// ================ constructor and initialization =================
+// =================================================================
+
+/** Used to construct the prototype node. This class currently does not
+* have specific configuration parameters and so the parameter
+* prefix
is not used. It reads the protocol components
+* (components that have type {@value peersim.core.Node#PAR_PROT}) from
+* the configuration.
+*/
+public GeneralNode(String prefix) {
+
+ String[] names = Configuration.getNames(PAR_PROT);
+ CommonState.setNode(this);
+ ID=nextID();
+ protocol = new Protocol[names.length];
+ for (int i=0; i < names.length; i++) {
+ CommonState.setPid(i);
+ Protocol p = (Protocol)
+ Configuration.getInstance(names[i]);
+ protocol[i] = p;
+ }
+}
+
+
+// -----------------------------------------------------------------
+
+public Object clone() {
+
+ GeneralNode result = null;
+ try { result=(GeneralNode)super.clone(); }
+ catch( CloneNotSupportedException e ) {} // never happens
+ result.protocol = new Protocol[protocol.length];
+ CommonState.setNode(result);
+ result.ID=nextID();
+ for(int i=0; i(int)getID(). */
+public int hashCode() { return (int)getID(); }
+
+}
+
+