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