Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
peersimgrid release 1.0
[simgrid.git] / contrib / psg / src / example / bittorrent / IntMsg.java
1 /*
2  * Copyright (c) 2007-2008 Fabrizio Frioli, Michele Pedrolli
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  * Please send your questions/suggestions to:
20  * {fabrizio.frioli, michele.pedrolli} at studenti dot unitn dot it
21  *
22  */
23
24 package example.bittorrent;
25
26 import peersim.core.*;
27 import psgsim.Sizable;
28
29 /**
30  * This class is a {@link SimpleMsg} and acts as a container for a message that
31  * uses only an integer value.
32  */
33 public class IntMsg extends SimpleMsg implements Sizable {
34
35         /**
36          * The data value (an integer) contained in the message.
37          */
38         private int integer;
39         private double size;
40
41         /**
42          * The basic constructor of the message.
43          *
44          * @param type
45          *            the type of the message
46          * @param sender
47          *            The sender node
48          * @param value
49          *            The data value of the message
50          */
51         public IntMsg(int type, Node sender, int value, double size) {
52                 super.type = type;
53                 super.sender = sender;
54                 this.integer = value;
55                 this.size = size;
56         }
57
58         /**
59          * Gets the value contained in the message.
60          *
61          * @return the integer value contained in the message
62          */
63         public int getInt() {
64                 return this.integer;
65         }
66
67         @Override
68         public double getSize() {
69                 // TODO Auto-generated method stub
70                 return size;
71         }
72 }