1 /*******************************************************************************
2 * Copyright (c) 2012, 2014 Ericsson
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
10 * Matthew Khouzam - Initial API and implementation
11 * Alexandre Montplaisir - Extends TmfLocation
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.tmf
.ctf
.core
.context
;
16 import java
.nio
.ByteBuffer
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.ITmfTimestamp
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.location
.TmfLocation
;
22 * The nugget of information that is unique to a location in a CTF trace.
24 * It can be copied and used to restore a position in a given trace.
26 * @author Matthew Khouzam
28 public final class CtfLocation
extends TmfLocation
{
30 // ------------------------------------------------------------------------
32 // ------------------------------------------------------------------------
37 public static final CtfLocationInfo INVALID_LOCATION
= new CtfLocationInfo(-1, -1);
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
44 * Basic constructor for CtfLocation. Uses a default index of 0.
47 * The timestamp of this location
49 public CtfLocation(final ITmfTimestamp timestamp
) {
50 this(timestamp
.getValue(), 0);
54 * Constructor using timestamp object and index
57 * The timestamp of this location
59 * The index of this location for this timestamp
61 public CtfLocation(final ITmfTimestamp timestamp
, long index
) {
62 this(timestamp
.getValue(), index
);
66 * Constructor using a long value for the timestamp, and an index
68 * @param timestampValue
73 public CtfLocation(final long timestampValue
, final long index
) {
74 super(new CtfLocationInfo(timestampValue
, index
));
78 * Constructor using a pre-made locationInfo object
81 * The locationInfo object to use
83 public CtfLocation(CtfLocationInfo locationInfo
) {
91 * Other location to copy
93 public CtfLocation(final CtfLocation location
) {
97 // ------------------------------------------------------------------------
99 // ------------------------------------------------------------------------
102 * Construct the location from the ByteBuffer.
105 * the buffer to read from
107 public CtfLocation(ByteBuffer bufferIn
) {
108 super(new CtfLocationInfo(bufferIn
));
112 public CtfLocationInfo
getLocationInfo() {
113 return (CtfLocationInfo
) super.getLocationInfo();
116 // ------------------------------------------------------------------------
118 // ------------------------------------------------------------------------
121 public String
toString() {
122 if (getLocationInfo().equals(CtfLocation
.INVALID_LOCATION
)) {
123 return getClass().getSimpleName() + " [INVALID]"; //$NON-NLS-1$
125 return super.toString();
129 * Constructs the location from the ByteBuffer. This typically happens when reading from disk.
132 public void serialize(ByteBuffer bufferOut
) {
133 getLocationInfo().serialize(bufferOut
);