tmf: Use tabs in statistics view for each traces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.core / src / org / eclipse / linuxtools / internal / lttng / core / event / LttngLocation.java
CommitLineData
5945cec9 1package org.eclipse.linuxtools.internal.lttng.core.event;
5d10d135 2
6c13869b 3import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
5d10d135 4
9f584e4c 5
0879b6b9 6public class LttngLocation implements ITmfLocation<LttngTimestamp>, Comparable<LttngLocation>, Cloneable {
5d837f9b
FC
7
8 private final static long DEFAULT_CURR_TIME = 0L;
9
10 private boolean isLastOperationParse = false ;
11 private boolean isLastOperationReadNext = false;
12 private boolean isLastOperationSeek = false;
13
14 private LttngTimestamp operationTime = null;
15
16 public LttngLocation() {
17 this( DEFAULT_CURR_TIME );
18 }
19
20 public LttngLocation(final long newCurrentTimestampValue) {
21 isLastOperationParse = false;
22 isLastOperationReadNext = false;
23 isLastOperationSeek = false;
24 operationTime = new LttngTimestamp(newCurrentTimestampValue);
25 }
26
27 public LttngLocation(final LttngTimestamp newCurrentTimestamp) {
28 isLastOperationParse = false;
29 isLastOperationReadNext = false;
30 isLastOperationSeek = false;
31 operationTime = new LttngTimestamp(newCurrentTimestamp);
32 }
33
34
35 public LttngLocation(final LttngLocation oldLocation) {
36 this.isLastOperationParse = oldLocation.isLastOperationParse;
37 this.isLastOperationReadNext = oldLocation.isLastOperationReadNext;
38 this.isLastOperationSeek = oldLocation.isLastOperationSeek;
bcf8b0f3 39 this.operationTime = oldLocation.operationTime.clone();
5d837f9b
FC
40 }
41
42 @Override
43 public LttngLocation clone() {
0316808c
FC
44 LttngLocation newLocation = new LttngLocation(this);
45 newLocation.operationTime = new LttngTimestamp( this.operationTime );
5d837f9b
FC
46 return newLocation;
47 }
48
49 public LttngTimestamp getOperationTime() {
50 return operationTime;
51 }
52
53 public long getOperationTimeValue() {
54 return operationTime.getValue();
55 }
56
57 public void setOperationTime(final LttngTimestamp newOperationTime) {
58 this.operationTime.setValue(newOperationTime.getValue());
59 }
60
61 public void setOperationTime(final Long newOperationTimeValue) {
62 this.operationTime.setValue(newOperationTimeValue);
63 }
64
65
66 public void setLastOperationParse() {
67 isLastOperationParse = true;
68 isLastOperationReadNext = false;
69 isLastOperationSeek = false;
70 }
71
72 public boolean isLastOperationParse() {
73 return isLastOperationParse;
74 }
75
76
77 public void setLastOperationReadNext() {
78 isLastOperationParse = false;
79 isLastOperationReadNext = true;
80 isLastOperationSeek = false;
81 }
82
83 public boolean isLastOperationReadNext() {
84 return isLastOperationReadNext;
85 }
86
87
88 public void setLastOperationSeek() {
89 isLastOperationParse = false;
90 isLastOperationReadNext = false;
91 isLastOperationSeek = true;
92 }
93
94 public boolean isLastOperationSeek() {
95 return isLastOperationSeek;
96 }
97
98 public void resetLocationState() {
99 isLastOperationParse = false;
100 isLastOperationReadNext = false;
101 isLastOperationSeek = false;
102 }
103
104 // ------------------------------------------------------------------------
105 // Object
106 // ------------------------------------------------------------------------
107
108 /* (non-Javadoc)
1cceddbe 109 * @see java.lang.Object#hashCode()
110 */
111 @Override
112 public int hashCode() {
113 final int prime = 31;
114 int result = 1;
115 result = prime * result + (isLastOperationParse ? 1231 : 1237);
116 result = prime * result + (isLastOperationReadNext ? 1231 : 1237);
117 result = prime * result + (isLastOperationSeek ? 1231 : 1237);
118 result = prime * result + ((operationTime == null) ? 0 : operationTime.hashCode());
119 return result;
120 }
121
122 /* (non-Javadoc)
123 * @see java.lang.Object#equals(java.lang.Object)
124 */
125 @Override
5d837f9b
FC
126 public boolean equals(final Object obj) {
127 if (this == obj)
1cceddbe 128 return true;
5d837f9b 129 if (obj == null)
1cceddbe 130 return false;
5d837f9b 131 if (!(obj instanceof LttngLocation))
1cceddbe 132 return false;
5d837f9b 133 final LttngLocation o = (LttngLocation) obj;
1cceddbe 134 return (operationTime.equals(o.operationTime))
5d837f9b
FC
135 && (isLastOperationParse == o.isLastOperationParse)
136 && (isLastOperationReadNext == o.isLastOperationReadNext)
137 && (isLastOperationSeek == o.isLastOperationSeek);
138 }
139
140 @Override
141 public String toString() {
142 // return "\tLttngLocation[ P/R/S : " + isLastOperationParse + "/" + isLastOperationReadNext + "/" + isLastOperationSeek + " Current : " + operationTime + " ]";
143 return operationTime.toString();
144 }
145
146 // ------------------------------------------------------------------------
147 // ITmfLocation
148 // ------------------------------------------------------------------------
149
150 // @Override
151 public void setLocation(final LttngTimestamp location) {
152 operationTime = location;
153 }
154
155 @Override
156 public LttngTimestamp getLocation() {
157 return new LttngTimestamp ( operationTime );
1cceddbe 158 }
159
160 @Override
5d837f9b
FC
161 public int compareTo(final LttngLocation o) {
162 return operationTime.compareTo(o.operationTime);
163 }
164
5d10d135 165}
This page took 0.049387 seconds and 5 git commands to generate.