Add incremental indexing support Bug 380952
[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 public static final long INVALID_INDEX = Long.MAX_VALUE;
27
28 /**
29 * Offset of the packet in the file, in bytes
30 */
31 final private long offsetBytes;
32
33 /**
34 * Offset of the data in the packet, in bits
35 */
36 private int dataOffsetBits = 0;
37
38 /**
39 * Packet size, in bits
40 */
41 private int packetSizeBits = 0;
42
43 /**
44 * Content size, in bits
45 */
46 private int contentSizeBits = 0;
47
48 /**
49 * Begin timestamp
50 */
51 private long timestampBegin = 0;
52
53 /**
54 * End timestamp
55 */
56 private long timestampEnd = 0;
57
58 // ------------------------------------------------------------------------
59 // Constructors
60 // ------------------------------------------------------------------------
61
62 /**
63 * Constructs an index entry.
64 *
65 * @param offset
66 * The offset of the packet in the file, in bytes.
67 */
68
69 public StreamInputPacketIndexEntry(long offset) {
70 this.offsetBytes = offset;
71 }
72
73 // ------------------------------------------------------------------------
74 // Operations
75 // ------------------------------------------------------------------------
76
77 /**
78 * Returns whether the packet includes (inclusively) the given timestamp in
79 * the begin-end timestamp range.
80 *
81 * @param ts
82 * The timestamp to check.
83 * @return True if the packet includes the timestamp.
84 */
85 boolean includes(long ts) {
86 return (ts >= timestampBegin) && (ts <= timestampEnd);
87 }
88
89 /*
90 * (non-Javadoc)
91 *
92 * @see java.lang.Object#toString()
93 */
94 @Override
95 public String toString() {
96 return "StreamInputPacketIndexEntry [offsetBytes=" + offsetBytes //$NON-NLS-1$
97 + ", timestampBegin=" + timestampBegin + ", timestampEnd=" //$NON-NLS-1$ //$NON-NLS-2$
98 + timestampEnd + "]"; //$NON-NLS-1$
99 }
100
101 // ------------------------------------------------------------------------
102 // Getters and Setters
103 // ------------------------------------------------------------------------
104
105 /**
106 * @return the offsetBytes
107 */
108 public long getOffsetBytes() {
109 return offsetBytes;
110 }
111
112 /**
113 * @return the dataOffsetBits
114 */
115 public int getDataOffsetBits() {
116 return dataOffsetBits;
117 }
118
119 /**
120 * @param dataOffsetBits
121 * the dataOffsetBits to set
122 */
123 public void setDataOffsetBits(int dataOffsetBits) {
124 this.dataOffsetBits = dataOffsetBits;
125 }
126
127 /**
128 * @return the packetSizeBits
129 */
130 public int getPacketSizeBits() {
131 return packetSizeBits;
132 }
133
134 /**
135 * @param packetSizeBits
136 * the packetSizeBits to set
137 */
138 public void setPacketSizeBits(int packetSizeBits) {
139 this.packetSizeBits = packetSizeBits;
140 }
141
142 /**
143 * @return the contentSizeBits
144 */
145 public int getContentSizeBits() {
146 return contentSizeBits;
147 }
148
149 /**
150 * @param contentSizeBits
151 * the contentSizeBits to set
152 */
153 public void setContentSizeBits(int contentSizeBits) {
154 this.contentSizeBits = contentSizeBits;
155 }
156
157 /**
158 * @return the timestampBegin
159 */
160 public long getTimestampBegin() {
161 return timestampBegin;
162 }
163
164 /**
165 * @param timestampBegin
166 * the timestampBegin to set
167 */
168 public void setTimestampBegin(long timestampBegin) {
169 this.timestampBegin = timestampBegin;
170 }
171
172 /**
173 * @return the timestampEnd
174 */
175 public long getTimestampEnd() {
176 return timestampEnd;
177 }
178
179 /**
180 * @param timestampEnd
181 * the timestampEnd to set
182 */
183 public void setTimestampEnd(long timestampEnd) {
184 this.timestampEnd = timestampEnd;
185 }
186
187 }
This page took 0.053495 seconds and 6 git commands to generate.