Commit | Line | Data |
---|---|---|
b1baa808 | 1 | /******************************************************************************* |
61759503 | 2 | * Copyright (c) 2012, 2013 Ericsson |
b1baa808 MK |
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 | * | |
a749efcb AM |
9 | * Contributors: |
10 | * Matthew Khouzam - Initial API and implementation | |
11 | * Alexandre Montplaisir - Extends TmfLocation | |
b1baa808 | 12 | *******************************************************************************/ |
a3fc8213 AM |
13 | package org.eclipse.linuxtools.tmf.core.ctfadaptor; |
14 | ||
3bd46eef | 15 | import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; |
a749efcb | 16 | import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; |
a3fc8213 | 17 | |
b1baa808 | 18 | /** |
d09f973b | 19 | * The nugget of information that is unique to a location in a CTF trace. |
132a02b0 | 20 | * |
d09f973b | 21 | * It can be copied and used to restore a position in a given trace. |
132a02b0 | 22 | * |
d09f973b FC |
23 | * @version 1.0 |
24 | * @author Matthew Khouzam | |
b1baa808 | 25 | */ |
a749efcb | 26 | public final class CtfLocation extends TmfLocation { |
132a02b0 | 27 | |
a749efcb AM |
28 | // ------------------------------------------------------------------------ |
29 | // Attributes | |
30 | // ------------------------------------------------------------------------ | |
a3fc8213 | 31 | |
9ac2eb62 MK |
32 | /** |
33 | * An invalid location | |
34 | */ | |
f5df94f8 | 35 | public static final CtfLocationInfo INVALID_LOCATION = new CtfLocationInfo(-1, -1); |
57c073c5 | 36 | |
a749efcb AM |
37 | // ------------------------------------------------------------------------ |
38 | // Constructors | |
39 | // ------------------------------------------------------------------------ | |
40 | ||
b1baa808 | 41 | /** |
a749efcb | 42 | * Basic constructor for CtfLocation. Uses a default index of 0. |
132a02b0 | 43 | * |
f0f3a065 AM |
44 | * @param timestamp |
45 | * The timestamp of this location | |
3bd46eef | 46 | * @since 2.0 |
b1baa808 | 47 | */ |
d62bb185 FC |
48 | public CtfLocation(final ITmfTimestamp timestamp) { |
49 | this(timestamp.getValue(), 0); | |
a3fc8213 | 50 | } |
ce2388e0 | 51 | |
b1baa808 | 52 | /** |
a749efcb | 53 | * Constructor using timestamp object and index |
132a02b0 MK |
54 | * |
55 | * @param timestamp | |
56 | * The timestamp of this location | |
57 | * @param index | |
58 | * The index of this location for this timestamp | |
59 | * @since 2.0 | |
60 | */ | |
d62bb185 FC |
61 | public CtfLocation(final ITmfTimestamp timestamp, long index) { |
62 | this(timestamp.getValue(), index); | |
132a02b0 MK |
63 | } |
64 | ||
65 | /** | |
a749efcb | 66 | * Constructor using a long value for the timestamp, and an index |
132a02b0 | 67 | * |
d62bb185 FC |
68 | * @param timestampValue |
69 | * The new timestamp | |
70 | * @param index | |
71 | * The new index | |
f0f3a065 | 72 | * @since 2.0 |
b1baa808 | 73 | */ |
d62bb185 | 74 | public CtfLocation(final long timestampValue, final long index) { |
a749efcb | 75 | super(new CtfLocationInfo(timestampValue, index)); |
a3fc8213 AM |
76 | } |
77 | ||
132a02b0 | 78 | /** |
a749efcb | 79 | * Constructor using a pre-made locationInfo object |
132a02b0 | 80 | * |
a749efcb AM |
81 | * @param locationInfo |
82 | * The locationInfo object to use | |
132a02b0 | 83 | * @since 2.0 |
b1baa808 | 84 | */ |
a749efcb AM |
85 | public CtfLocation(CtfLocationInfo locationInfo) { |
86 | super(locationInfo); | |
a3fc8213 AM |
87 | } |
88 | ||
b1baa808 | 89 | /** |
a749efcb | 90 | * Copy constructor |
132a02b0 | 91 | * |
a749efcb AM |
92 | * @param location |
93 | * Other location to copy | |
132a02b0 | 94 | * @since 2.0 |
b1baa808 | 95 | */ |
a749efcb AM |
96 | public CtfLocation(final CtfLocation location) { |
97 | super(location); | |
a3fc8213 AM |
98 | } |
99 | ||
a749efcb AM |
100 | // ------------------------------------------------------------------------ |
101 | // TmfLocation | |
102 | // ------------------------------------------------------------------------ | |
132a02b0 | 103 | |
a749efcb AM |
104 | /** |
105 | * @since 2.0 | |
81c8e6f7 MK |
106 | */ |
107 | @Override | |
a749efcb AM |
108 | public CtfLocationInfo getLocationInfo() { |
109 | return (CtfLocationInfo) super.getLocationInfo(); | |
81c8e6f7 MK |
110 | } |
111 | ||
a749efcb AM |
112 | // ------------------------------------------------------------------------ |
113 | // Object | |
114 | // ------------------------------------------------------------------------ | |
81c8e6f7 | 115 | |
eea58fe7 MK |
116 | @Override |
117 | public String toString() { | |
5976d44a | 118 | if( this.getLocationInfo().equals(CtfLocation.INVALID_LOCATION )) { |
a749efcb | 119 | return getClass().getSimpleName() + " [INVALID]"; //$NON-NLS-1$ |
eea58fe7 | 120 | } |
a749efcb | 121 | return super.toString(); |
eea58fe7 MK |
122 | } |
123 | ||
a3fc8213 | 124 | } |