internalize some CTF API
[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 /**
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 private long indexBegin = Long.MAX_VALUE;
60
61 private long indexEnd = Long.MAX_VALUE;
62
63 // ------------------------------------------------------------------------
64 // Constructors
65 // ------------------------------------------------------------------------
66
67 /**
68 * Constructs an index entry.
69 *
70 * @param offset
71 * The offset of the packet in the file, in bytes.
72 */
73
74 public StreamInputPacketIndexEntry(long offset) {
75 this.offsetBytes = offset;
76 }
77
78 // ------------------------------------------------------------------------
79 // Operations
80 // ------------------------------------------------------------------------
81
82 /**
83 * Returns whether the packet includes (inclusively) the given timestamp in
84 * the begin-end timestamp range.
85 *
86 * @param ts
87 * The timestamp to check.
88 * @return True if the packet includes the timestamp.
89 */
90 boolean includes(long ts) {
91 return (ts >= timestampBegin) && (ts <= timestampEnd);
92 }
93
94 boolean includesIndex(long index){
95 return (index >= indexBegin) && (index <= indexEnd);
96 }
97 /* (non-Javadoc)
98 * @see java.lang.Object#toString()
99 */
100 @Override
101 public String toString() {
102 return "StreamInputPacketIndexEntry [offsetBytes=" + offsetBytes //$NON-NLS-1$
103 + ", timestampBegin=" + timestampBegin + ", timestampEnd=" //$NON-NLS-1$ //$NON-NLS-2$
104 + timestampEnd + ", indexBegin=" + indexBegin + ", indexEnd=" //$NON-NLS-1$ //$NON-NLS-2$
105 + indexEnd + "]"; //$NON-NLS-1$
106 }
107
108 // ------------------------------------------------------------------------
109 // Getters and Setters
110 // ------------------------------------------------------------------------
111
112 /**
113 * @return the offsetBytes
114 */
115 public long getOffsetBytes() {
116 return offsetBytes;
117 }
118
119 /**
120 * @return the dataOffsetBits
121 */
122 public int getDataOffsetBits() {
123 return dataOffsetBits;
124 }
125
126 /**
127 * @param dataOffsetBits the dataOffsetBits to set
128 */
129 public void setDataOffsetBits(int dataOffsetBits) {
130 this.dataOffsetBits = dataOffsetBits;
131 }
132
133 /**
134 * @return the packetSizeBits
135 */
136 public int getPacketSizeBits() {
137 return packetSizeBits;
138 }
139
140 /**
141 * @param packetSizeBits the packetSizeBits to set
142 */
143 public void setPacketSizeBits(int packetSizeBits) {
144 this.packetSizeBits = packetSizeBits;
145 }
146
147 /**
148 * @return the contentSizeBits
149 */
150 public int getContentSizeBits() {
151 return contentSizeBits;
152 }
153
154 /**
155 * @param contentSizeBits 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 the timestampBegin to set
170 */
171 public void setTimestampBegin(long timestampBegin) {
172 this.timestampBegin = timestampBegin;
173 }
174
175 /**
176 * @return the timestampEnd
177 */
178 public long getTimestampEnd() {
179 return timestampEnd;
180 }
181
182 /**
183 * @param timestampEnd the timestampEnd to set
184 */
185 public void setTimestampEnd(long timestampEnd) {
186 this.timestampEnd = timestampEnd;
187 }
188
189 /**
190 * @return the indexBegin
191 */
192 public long getIndexBegin() {
193 return indexBegin;
194 }
195
196 /**
197 * @param indexBegin the indexBegin to set
198 */
199 public void setIndexBegin(long indexBegin) {
200 this.indexBegin = indexBegin;
201 }
202
203 /**
204 * @return the indexEnd
205 */
206 public long getIndexEnd() {
207 return indexEnd;
208 }
209
210 /**
211 * @param indexEnd the indexEnd to set
212 */
213 public void setIndexEnd(long indexEnd) {
214 this.indexEnd = indexEnd;
215 }
216 }
This page took 0.047107 seconds and 6 git commands to generate.