tmf/lttng: Update 2014 copyrights
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / internal / ctf / core / trace / StreamInputPacketIndexEntry.java
CommitLineData
ce2388e0 1/*******************************************************************************
60ae41e1 2 * Copyright (c) 2011, 2014 Ericsson, Ecole Polytechnique de Montreal and others
ce2388e0
FC
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
13package org.eclipse.linuxtools.internal.ctf.core.trace;
14
21fb02fa 15import java.util.HashMap;
8de0528f 16import java.util.Map;
21fb02fa 17
ce2388e0
FC
18/**
19 * <b><u>StreamInputPacketIndexEntry</u></b>
20 * <p>
21 * Represents an entry in the index of event packets.
22 */
23public class StreamInputPacketIndexEntry {
24
25 // ------------------------------------------------------------------------
26 // Attributes
27 // ------------------------------------------------------------------------
28
ce2388e0
FC
29 /**
30 * Offset of the packet in the file, in bytes
31 */
08330515 32 final private long fOffsetBytes;
ce2388e0
FC
33
34 /**
35 * Offset of the data in the packet, in bits
36 */
08330515 37 private long fDataOffsetBits = 0;
ce2388e0
FC
38
39 /**
40 * Packet size, in bits
41 */
08330515 42 private long fPacketSizeBits = 0;
ce2388e0
FC
43
44 /**
45 * Content size, in bits
46 */
08330515 47 private long fContentSizeBits = 0;
ce2388e0
FC
48
49 /**
50 * Begin timestamp
51 */
08330515 52 private long fTimestampBegin = 0;
ce2388e0
FC
53
54 /**
55 * End timestamp
56 */
08330515 57 private long fTimestampEnd = 0;
ce2388e0 58
5c7202b5
MK
59 /**
60 * How many lost events are there?
61 */
08330515 62 private long fLostEvents = 0;
5c7202b5 63
21fb02fa
MK
64 /**
65 * Which target is being traced
66 */
08330515
MK
67 private String fTarget ;
68 private long fTargetID;
21fb02fa 69
8de0528f
AM
70 /**
71 * Attributes of this index entry
72 */
08330515 73 private final Map<String, Object> fAttributes = new HashMap<>();
8de0528f 74
21fb02fa 75
ce2388e0
FC
76 // ------------------------------------------------------------------------
77 // Constructors
78 // ------------------------------------------------------------------------
79
80 /**
81 * Constructs an index entry.
82 *
83 * @param offset
84 * The offset of the packet in the file, in bytes.
85 */
86
87 public StreamInputPacketIndexEntry(long offset) {
08330515 88 fOffsetBytes = offset;
ce2388e0
FC
89 }
90
91 // ------------------------------------------------------------------------
92 // Operations
93 // ------------------------------------------------------------------------
94
95 /**
96 * Returns whether the packet includes (inclusively) the given timestamp in
97 * the begin-end timestamp range.
98 *
99 * @param ts
100 * The timestamp to check.
101 * @return True if the packet includes the timestamp.
102 */
103 boolean includes(long ts) {
08330515 104 return (ts >= fTimestampBegin) && (ts <= fTimestampEnd);
ce2388e0
FC
105 }
106
ce2388e0
FC
107 @Override
108 public String toString() {
08330515
MK
109 return "StreamInputPacketIndexEntry [offsetBytes=" + fOffsetBytes //$NON-NLS-1$
110 + ", timestampBegin=" + fTimestampBegin + ", timestampEnd=" //$NON-NLS-1$ //$NON-NLS-2$
111 + fTimestampEnd + "]"; //$NON-NLS-1$
ce2388e0
FC
112 }
113
114 // ------------------------------------------------------------------------
115 // Getters and Setters
116 // ------------------------------------------------------------------------
117
118 /**
119 * @return the offsetBytes
120 */
121 public long getOffsetBytes() {
08330515 122 return fOffsetBytes;
ce2388e0
FC
123 }
124
125 /**
126 * @return the dataOffsetBits
127 */
47ca6c05 128 public long getDataOffsetBits() {
08330515 129 return fDataOffsetBits;
ce2388e0
FC
130 }
131
132 /**
bfe038ff
MK
133 * @param dataOffsetBits
134 * the dataOffsetBits to set
ce2388e0 135 */
47ca6c05 136 public void setDataOffsetBits(long dataOffsetBits) {
08330515 137 fDataOffsetBits = dataOffsetBits;
ce2388e0
FC
138 }
139
140 /**
141 * @return the packetSizeBits
142 */
47ca6c05 143 public long getPacketSizeBits() {
08330515 144 return fPacketSizeBits;
ce2388e0
FC
145 }
146
147 /**
bfe038ff
MK
148 * @param packetSizeBits
149 * the packetSizeBits to set
ce2388e0 150 */
47ca6c05 151 public void setPacketSizeBits(long packetSizeBits) {
08330515 152 fPacketSizeBits = packetSizeBits;
ce2388e0
FC
153 }
154
155 /**
156 * @return the contentSizeBits
157 */
47ca6c05 158 public long getContentSizeBits() {
08330515 159 return fContentSizeBits;
ce2388e0
FC
160 }
161
162 /**
bfe038ff
MK
163 * @param contentSizeBits
164 * the contentSizeBits to set
ce2388e0 165 */
47ca6c05 166 public void setContentSizeBits(long contentSizeBits) {
08330515 167 fContentSizeBits = contentSizeBits;
ce2388e0
FC
168 }
169
170 /**
171 * @return the timestampBegin
172 */
173 public long getTimestampBegin() {
08330515 174 return fTimestampBegin;
ce2388e0
FC
175 }
176
177 /**
bfe038ff
MK
178 * @param timestampBegin
179 * the timestampBegin to set
ce2388e0
FC
180 */
181 public void setTimestampBegin(long timestampBegin) {
08330515 182 fTimestampBegin = timestampBegin;
ce2388e0
FC
183 }
184
185 /**
186 * @return the timestampEnd
187 */
188 public long getTimestampEnd() {
08330515 189 return fTimestampEnd;
ce2388e0
FC
190 }
191
192 /**
bfe038ff
MK
193 * @param timestampEnd
194 * the timestampEnd to set
ce2388e0
FC
195 */
196 public void setTimestampEnd(long timestampEnd) {
08330515 197 fTimestampEnd = timestampEnd;
ce2388e0
FC
198 }
199
5c7202b5 200 /**
132a02b0 201 * @return the lostEvents in this packet
5c7202b5
MK
202 */
203 public long getLostEvents() {
08330515 204 return fLostEvents;
5c7202b5
MK
205 }
206
207 /**
208 * @param lostEvents the lostEvents to set
209 */
210 public void setLostEvents(long lostEvents) {
08330515 211 fLostEvents = lostEvents;
5c7202b5 212 }
21fb02fa 213
8de0528f
AM
214 /**
215 * Add an attribute to this index entry
216 *
217 * @param field
132a02b0 218 * The name of the attribute
8de0528f
AM
219 * @param value
220 * The value to insert
221 */
21fb02fa 222 public void addAttribute(String field, Object value) {
08330515 223 fAttributes.put(field, value);
21fb02fa 224 }
8de0528f
AM
225
226 /**
227 * Retrieve the value of an existing attribute
228 *
229 * @param field
230 * The name of the attribute
231 * @return The value that was stored, or null if it wasn't found
232 */
21fb02fa 233 public Object lookupAttribute(String field){
08330515 234 return fAttributes.get(field);
21fb02fa
MK
235 }
236
8de0528f
AM
237 /**
238 * @return The target that is being traced
239 */
21fb02fa 240 public String getTarget() {
08330515 241 return fTarget;
21fb02fa
MK
242 }
243
8de0528f
AM
244 /**
245 * Assign a target to this index entry
246 *
247 * @param target
248 * The target to assign
249 */
21fb02fa 250 public void setTarget(String target) {
08330515
MK
251 fTarget = target;
252 fTargetID = Integer.parseInt(target.replaceAll("[\\D]", "")); //$NON-NLS-1$ //$NON-NLS-2$ // slow
21fb02fa
MK
253 }
254
8de0528f
AM
255 /**
256 * @return The ID of the target
257 */
21fb02fa 258 public long getTargetId(){
08330515 259 return fTargetID;
21fb02fa 260 }
ce2388e0 261}
This page took 0.051637 seconds and 5 git commands to generate.