Fix lost events to work after multiple reloads
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / internal / ctf / core / trace / StreamInputPacketIndexEntry.java
1 /*******************************************************************************
2 * Copyright (c) 2011-2012 Ericsson, Ecole Polytechnique de Montreal and others
3 *
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors: Matthew Khouzam - Initial API and implementation
10 * Contributors: Simon Marchi - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.internal.ctf.core.trace;
14
15 /**
16 * <b><u>StreamInputPacketIndexEntry</u></b>
17 * <p>
18 * Represents an entry in the index of event packets.
19 */
20 public class StreamInputPacketIndexEntry {
21
22 // ------------------------------------------------------------------------
23 // Attributes
24 // ------------------------------------------------------------------------
25
26
27 /**
28 * Offset of the packet in the file, in bytes
29 */
30 final private long offsetBytes;
31
32 /**
33 * Offset of the data in the packet, in bits
34 */
35 private int dataOffsetBits = 0;
36
37 /**
38 * Packet size, in bits
39 */
40 private int packetSizeBits = 0;
41
42 /**
43 * Content size, in bits
44 */
45 private int contentSizeBits = 0;
46
47 /**
48 * Begin timestamp
49 */
50 private long timestampBegin = 0;
51
52 /**
53 * End timestamp
54 */
55 private long timestampEnd = 0;
56
57 /**
58 * How many lost events are there?
59 */
60 private long lostEvents = 0;
61
62 // ------------------------------------------------------------------------
63 // Constructors
64 // ------------------------------------------------------------------------
65
66 /**
67 * Constructs an index entry.
68 *
69 * @param offset
70 * The offset of the packet in the file, in bytes.
71 */
72
73 public StreamInputPacketIndexEntry(long offset) {
74 this.offsetBytes = offset;
75 }
76
77 // ------------------------------------------------------------------------
78 // Operations
79 // ------------------------------------------------------------------------
80
81 /**
82 * Returns whether the packet includes (inclusively) the given timestamp in
83 * the begin-end timestamp range.
84 *
85 * @param ts
86 * The timestamp to check.
87 * @return True if the packet includes the timestamp.
88 */
89 boolean includes(long ts) {
90 return (ts >= timestampBegin) && (ts <= timestampEnd);
91 }
92
93 /*
94 * (non-Javadoc)
95 *
96 * @see java.lang.Object#toString()
97 */
98 @Override
99 public String toString() {
100 return "StreamInputPacketIndexEntry [offsetBytes=" + offsetBytes //$NON-NLS-1$
101 + ", timestampBegin=" + timestampBegin + ", timestampEnd=" //$NON-NLS-1$ //$NON-NLS-2$
102 + timestampEnd + "]"; //$NON-NLS-1$
103 }
104
105 // ------------------------------------------------------------------------
106 // Getters and Setters
107 // ------------------------------------------------------------------------
108
109 /**
110 * @return the offsetBytes
111 */
112 public long getOffsetBytes() {
113 return offsetBytes;
114 }
115
116 /**
117 * @return the dataOffsetBits
118 */
119 public int getDataOffsetBits() {
120 return dataOffsetBits;
121 }
122
123 /**
124 * @param dataOffsetBits
125 * the dataOffsetBits to set
126 */
127 public void setDataOffsetBits(int dataOffsetBits) {
128 this.dataOffsetBits = dataOffsetBits;
129 }
130
131 /**
132 * @return the packetSizeBits
133 */
134 public int getPacketSizeBits() {
135 return packetSizeBits;
136 }
137
138 /**
139 * @param packetSizeBits
140 * the packetSizeBits to set
141 */
142 public void setPacketSizeBits(int packetSizeBits) {
143 this.packetSizeBits = packetSizeBits;
144 }
145
146 /**
147 * @return the contentSizeBits
148 */
149 public int getContentSizeBits() {
150 return contentSizeBits;
151 }
152
153 /**
154 * @param contentSizeBits
155 * the contentSizeBits to set
156 */
157 public void setContentSizeBits(int contentSizeBits) {
158 this.contentSizeBits = contentSizeBits;
159 }
160
161 /**
162 * @return the timestampBegin
163 */
164 public long getTimestampBegin() {
165 return timestampBegin;
166 }
167
168 /**
169 * @param timestampBegin
170 * the timestampBegin to set
171 */
172 public void setTimestampBegin(long timestampBegin) {
173 this.timestampBegin = timestampBegin;
174 }
175
176 /**
177 * @return the timestampEnd
178 */
179 public long getTimestampEnd() {
180 return timestampEnd;
181 }
182
183 /**
184 * @param timestampEnd
185 * the timestampEnd to set
186 */
187 public void setTimestampEnd(long timestampEnd) {
188 this.timestampEnd = timestampEnd;
189 }
190
191 /**
192 * @return the lostEvents
193 */
194 public long getLostEvents() {
195 return lostEvents;
196 }
197
198 /**
199 * @param lostEvents the lostEvents to set
200 */
201 public void setLostEvents(long lostEvents) {
202 this.lostEvents = lostEvents;
203 }
204 }
This page took 0.041709 seconds and 6 git commands to generate.