Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Correction of some bugs and performance enhancement.
[jaceP2P.git] / src / jaceP2P / Message.java
1 package jaceP2P;
2
3 public class Message implements java.io.Serializable, Cloneable {
4
5         private static final long serialVersionUID = 1L;
6
7         // attributs
8         private int tag = -1;
9         private TaskId Src = null;
10         private TaskId Dest = null;
11         private Object obj;
12         private int timeStep;
13         private int src_iteration;
14         private int src_tag = -1;
15         //private Integer srcTag;
16         private double error = 0;
17
18         // TODO : add appliname too in Message object
19
20         // constructors
21         public Message(Object obj) {
22                 this.obj = obj;
23         }
24
25         public Message() {
26         }
27
28         public void setParam(Object buffer, TaskId src, TaskId dest, int tag,
29                         int time, int iter, int src_tag, double erreur_locale) {
30                 this.obj = buffer;
31                 this.Src = src;
32                 this.Dest = dest;
33                 this.tag = tag;
34                 this.timeStep = time;
35                 this.src_iteration = iter;
36                 this.src_tag = src_tag;
37                 error = erreur_locale;
38         }
39
40         // methods
41         public Object getData() {
42                 return obj;
43         }
44
45         public double getLocalError() {
46                 return error;
47         }
48
49         public int getSrc_iteration() {
50                 return src_iteration;
51         }
52
53         public int getSrc_tag() {
54                 return src_tag;
55         }
56
57         public void setTag(int val) {
58                 this.tag = val;
59         }
60
61         public int getTag() {
62                 return tag;
63         }
64
65         public TaskId getSender() {
66                 return Src;
67         }
68
69         public TaskId getReceiver() {
70                 return Dest;
71         }
72
73         public int getTimeStep() {
74                 return timeStep;
75         }
76
77         public Object clone() {
78                 Message tmp = new Message();
79                 tmp.setParam(this.obj, this.Src, this.Dest, this.tag, this.timeStep,
80                                 this.src_iteration, this.src_tag, this.error);
81                 return (Object) tmp;
82         }
83 }