1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 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 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
;
15 import java
.nio
.ByteBuffer
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.ITmfTimestamp
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.location
.TmfLocation
;
21 * The nugget of information that is unique to a location in a CTF trace.
23 * 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
50 public CtfLocation(final ITmfTimestamp timestamp
) {
51 this(timestamp
.getValue(), 0);
55 * Constructor using timestamp object and index
58 * The timestamp of this location
60 * The index of this location for this timestamp
63 public CtfLocation(final ITmfTimestamp timestamp
, long index
) {
64 this(timestamp
.getValue(), index
);
68 * Constructor using a long value for the timestamp, and an index
70 * @param timestampValue
76 public CtfLocation(final long timestampValue
, final long index
) {
77 super(new CtfLocationInfo(timestampValue
, index
));
81 * Constructor using a pre-made locationInfo object
84 * The locationInfo object to use
87 public CtfLocation(CtfLocationInfo locationInfo
) {
95 * Other location to copy
98 public CtfLocation(final CtfLocation location
) {
102 // ------------------------------------------------------------------------
104 // ------------------------------------------------------------------------
107 * Construct the location from the ByteBuffer.
110 * the buffer to read from
114 public CtfLocation(ByteBuffer bufferIn
) {
115 super(new CtfLocationInfo(bufferIn
));
122 public CtfLocationInfo
getLocationInfo() {
123 return (CtfLocationInfo
) super.getLocationInfo();
126 // ------------------------------------------------------------------------
128 // ------------------------------------------------------------------------
131 public String
toString() {
132 if( this.getLocationInfo().equals(CtfLocation
.INVALID_LOCATION
)) {
133 return getClass().getSimpleName() + " [INVALID]"; //$NON-NLS-1$
135 return super.toString();
139 * Constructs the location from the ByteBuffer. This typically happens when reading from disk.
144 public void serialize(ByteBuffer bufferOut
) {
145 getLocationInfo().serialize(bufferOut
);