Work on TmfCheckpoint
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / 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.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 * Offset of the packet in the file, in bytes
28 */
29 public long offsetBytes;
30
31 /**
32 * Offset of the data in the packet, in bits
33 */
34 public int dataOffsetBits = 0;
35
36 /**
37 * Packet size, in bits
38 */
39 public int packetSizeBits = 0;
40
41 /**
42 * Content size, in bits
43 */
44 public int contentSizeBits = 0;
45
46 /**
47 * Begin timestamp
48 */
49 public long timestampBegin = 0;
50
51 /**
52 * End timestamp
53 */
54 public long timestampEnd = 0;
55
56 // ------------------------------------------------------------------------
57 // Constructors
58 // ------------------------------------------------------------------------
59
60 /**
61 * Constructs an index entry.
62 *
63 * @param offset
64 * The offset of the packet in the file, in bytes.
65 */
66
67 public StreamInputPacketIndexEntry(long offset) {
68 this.offsetBytes = offset;
69 }
70
71 // ------------------------------------------------------------------------
72 // Operations
73 // ------------------------------------------------------------------------
74
75 /**
76 * Returns whether the packet includes (inclusively) the given timestamp in
77 * the begin-end timestamp range.
78 *
79 * @param ts
80 * The timestamp to check.
81 * @return True if the packet includes the timestamp.
82 */
83 boolean includes(long ts) {
84 return (ts >= timestampBegin) && (ts <= timestampEnd);
85 }
86
87 @Override
88 public String toString() {
89 /* Only for debugging, shouldn't be externalized */
90 return "PacketIndexEntry [offset=" + offsetBytes + ", timestampBegin=" //$NON-NLS-1$ //$NON-NLS-2$
91 + Long.toHexString(timestampBegin) + ',' + " timestampEnd=" //$NON-NLS-1$
92 + Long.toHexString(timestampEnd) + ", dataOffset=" //$NON-NLS-1$
93 + dataOffsetBits + ", packetSize=" + packetSizeBits //$NON-NLS-1$
94 + ", contentSize=" + contentSizeBits + ']'; //$NON-NLS-1$
95 }
96
97 }
This page took 0.034636 seconds and 5 git commands to generate.