Commit | Line | Data |
---|---|---|
b1baa808 MK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2012 Ericsson | |
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 | ||
15 | import org.eclipse.linuxtools.tmf.core.event.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 | |
b1baa808 | 46 | */ |
d62bb185 FC |
47 | public CtfLocation(final ITmfTimestamp timestamp) { |
48 | this(timestamp.getValue(), 0); | |
a3fc8213 | 49 | } |
ce2388e0 | 50 | |
b1baa808 | 51 | /** |
a749efcb | 52 | * Constructor using timestamp object and index |
132a02b0 MK |
53 | * |
54 | * @param timestamp | |
55 | * The timestamp of this location | |
56 | * @param index | |
57 | * The index of this location for this timestamp | |
58 | * @since 2.0 | |
59 | */ | |
d62bb185 FC |
60 | public CtfLocation(final ITmfTimestamp timestamp, long index) { |
61 | this(timestamp.getValue(), index); | |
132a02b0 MK |
62 | } |
63 | ||
64 | /** | |
a749efcb | 65 | * Constructor using a long value for the timestamp, and an index |
132a02b0 | 66 | * |
d62bb185 FC |
67 | * @param timestampValue |
68 | * The new timestamp | |
69 | * @param index | |
70 | * The new index | |
f0f3a065 | 71 | * @since 2.0 |
b1baa808 | 72 | */ |
d62bb185 | 73 | public CtfLocation(final long timestampValue, final long index) { |
a749efcb | 74 | super(new CtfLocationInfo(timestampValue, index)); |
a3fc8213 AM |
75 | } |
76 | ||
132a02b0 | 77 | /** |
a749efcb | 78 | * Constructor using a pre-made locationInfo object |
132a02b0 | 79 | * |
a749efcb AM |
80 | * @param locationInfo |
81 | * The locationInfo object to use | |
132a02b0 | 82 | * @since 2.0 |
b1baa808 | 83 | */ |
a749efcb AM |
84 | public CtfLocation(CtfLocationInfo locationInfo) { |
85 | super(locationInfo); | |
a3fc8213 AM |
86 | } |
87 | ||
b1baa808 | 88 | /** |
a749efcb | 89 | * Copy constructor |
132a02b0 | 90 | * |
a749efcb AM |
91 | * @param location |
92 | * Other location to copy | |
132a02b0 | 93 | * @since 2.0 |
b1baa808 | 94 | */ |
a749efcb AM |
95 | public CtfLocation(final CtfLocation location) { |
96 | super(location); | |
a3fc8213 AM |
97 | } |
98 | ||
a749efcb AM |
99 | // ------------------------------------------------------------------------ |
100 | // TmfLocation | |
101 | // ------------------------------------------------------------------------ | |
132a02b0 | 102 | |
a749efcb AM |
103 | /** |
104 | * @since 2.0 | |
81c8e6f7 MK |
105 | */ |
106 | @Override | |
a749efcb AM |
107 | public CtfLocationInfo getLocationInfo() { |
108 | return (CtfLocationInfo) super.getLocationInfo(); | |
81c8e6f7 MK |
109 | } |
110 | ||
a749efcb AM |
111 | // ------------------------------------------------------------------------ |
112 | // Object | |
113 | // ------------------------------------------------------------------------ | |
81c8e6f7 | 114 | |
eea58fe7 MK |
115 | @Override |
116 | public String toString() { | |
5976d44a | 117 | if( this.getLocationInfo().equals(CtfLocation.INVALID_LOCATION )) { |
a749efcb | 118 | return getClass().getSimpleName() + " [INVALID]"; //$NON-NLS-1$ |
eea58fe7 | 119 | } |
a749efcb | 120 | return super.toString(); |
eea58fe7 MK |
121 | } |
122 | ||
a3fc8213 | 123 | } |