Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
peersimgrid release 1.0
[simgrid.git] / contrib / psg / src / peersim / vector / SingleValueHolder.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.vector;
20
21 import peersim.core.*;
22
23 /**
24  * The task of this protocol is to store a single double value and make it
25  * available through the {@link SingleValue} interface.
26  *
27  * @author Alberto Montresor
28  * @version $Revision: 1.6 $
29  */
30 public class SingleValueHolder 
31 implements SingleValue, Protocol
32 {
33
34 //--------------------------------------------------------------------------
35 //Fields
36 //--------------------------------------------------------------------------
37         
38 /** Value held by this protocol */
39 protected double value;
40         
41
42 //--------------------------------------------------------------------------
43 //Initialization
44 //--------------------------------------------------------------------------
45
46 /**
47  * Does nothing.
48  */
49 public SingleValueHolder(String prefix)
50 {
51 }
52
53 //--------------------------------------------------------------------------
54
55 /**
56  * Clones the value holder.
57  */
58 public Object clone()
59 {
60         SingleValueHolder svh=null;
61         try { svh=(SingleValueHolder)super.clone(); }
62         catch( CloneNotSupportedException e ) {} // never happens
63         return svh;
64 }
65
66 //--------------------------------------------------------------------------
67 //methods
68 //--------------------------------------------------------------------------
69
70 /**
71  * @inheritDoc
72  */
73 public double getValue()
74 {
75         return value;
76 }
77
78 //--------------------------------------------------------------------------
79
80 /**
81  * @inheritDoc
82  */
83 public void setValue(double value)
84 {
85         this.value = value;
86 }
87
88 //--------------------------------------------------------------------------
89
90 /**
91  * Returns the value as a string.
92  */
93 public String toString() { return ""+value; }
94
95 }