tmf: Use TmfFilterMatchesAspectNode's in the event table
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ctf.core / src / org / eclipse / tracecompass / tmf / ctf / core / context / CtfLocation.java
CommitLineData
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 *******************************************************************************/
9722e5d7
AM
13
14package org.eclipse.tracecompass.tmf.ctf.core.context;
a3fc8213 15
032ecd45
MAL
16import java.nio.ByteBuffer;
17
2bdf0193
AM
18import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
19import org.eclipse.tracecompass.tmf.core.trace.location.TmfLocation;
a3fc8213 20
b1baa808 21/**
d09f973b 22 * The nugget of information that is unique to a location in a CTF trace.
132a02b0 23 *
d09f973b 24 * It can be copied and used to restore a position in a given trace.
132a02b0 25 *
d09f973b
FC
26 * @version 1.0
27 * @author Matthew Khouzam
b1baa808 28 */
a749efcb 29public final class CtfLocation extends TmfLocation {
132a02b0 30
a749efcb
AM
31 // ------------------------------------------------------------------------
32 // Attributes
33 // ------------------------------------------------------------------------
a3fc8213 34
9ac2eb62
MK
35 /**
36 * An invalid location
37 */
f5df94f8 38 public static final CtfLocationInfo INVALID_LOCATION = new CtfLocationInfo(-1, -1);
57c073c5 39
a749efcb
AM
40 // ------------------------------------------------------------------------
41 // Constructors
42 // ------------------------------------------------------------------------
43
b1baa808 44 /**
a749efcb 45 * Basic constructor for CtfLocation. Uses a default index of 0.
132a02b0 46 *
f0f3a065
AM
47 * @param timestamp
48 * The timestamp of this location
3bd46eef 49 * @since 2.0
b1baa808 50 */
d62bb185
FC
51 public CtfLocation(final ITmfTimestamp timestamp) {
52 this(timestamp.getValue(), 0);
a3fc8213 53 }
ce2388e0 54
b1baa808 55 /**
a749efcb 56 * Constructor using timestamp object and index
132a02b0
MK
57 *
58 * @param timestamp
59 * The timestamp of this location
60 * @param index
61 * The index of this location for this timestamp
62 * @since 2.0
63 */
d62bb185
FC
64 public CtfLocation(final ITmfTimestamp timestamp, long index) {
65 this(timestamp.getValue(), index);
132a02b0
MK
66 }
67
68 /**
a749efcb 69 * Constructor using a long value for the timestamp, and an index
132a02b0 70 *
d62bb185
FC
71 * @param timestampValue
72 * The new timestamp
73 * @param index
74 * The new index
f0f3a065 75 * @since 2.0
b1baa808 76 */
d62bb185 77 public CtfLocation(final long timestampValue, final long index) {
a749efcb 78 super(new CtfLocationInfo(timestampValue, index));
a3fc8213
AM
79 }
80
132a02b0 81 /**
a749efcb 82 * Constructor using a pre-made locationInfo object
132a02b0 83 *
a749efcb
AM
84 * @param locationInfo
85 * The locationInfo object to use
132a02b0 86 * @since 2.0
b1baa808 87 */
a749efcb
AM
88 public CtfLocation(CtfLocationInfo locationInfo) {
89 super(locationInfo);
a3fc8213
AM
90 }
91
b1baa808 92 /**
a749efcb 93 * Copy constructor
132a02b0 94 *
a749efcb
AM
95 * @param location
96 * Other location to copy
132a02b0 97 * @since 2.0
b1baa808 98 */
a749efcb
AM
99 public CtfLocation(final CtfLocation location) {
100 super(location);
a3fc8213
AM
101 }
102
a749efcb
AM
103 // ------------------------------------------------------------------------
104 // TmfLocation
105 // ------------------------------------------------------------------------
132a02b0 106
032ecd45
MAL
107 /**
108 * Construct the location from the ByteBuffer.
109 *
110 * @param bufferIn
111 * the buffer to read from
112 *
113 * @since 3.0
114 */
115 public CtfLocation(ByteBuffer bufferIn) {
116 super(new CtfLocationInfo(bufferIn));
117 }
118
a749efcb
AM
119 /**
120 * @since 2.0
81c8e6f7
MK
121 */
122 @Override
a749efcb
AM
123 public CtfLocationInfo getLocationInfo() {
124 return (CtfLocationInfo) super.getLocationInfo();
81c8e6f7
MK
125 }
126
a749efcb
AM
127 // ------------------------------------------------------------------------
128 // Object
129 // ------------------------------------------------------------------------
81c8e6f7 130
eea58fe7
MK
131 @Override
132 public String toString() {
283b5dc7 133 if (getLocationInfo().equals(CtfLocation.INVALID_LOCATION )) {
a749efcb 134 return getClass().getSimpleName() + " [INVALID]"; //$NON-NLS-1$
eea58fe7 135 }
a749efcb 136 return super.toString();
eea58fe7
MK
137 }
138
032ecd45
MAL
139 /**
140 * Constructs the location from the ByteBuffer. This typically happens when reading from disk.
141 *
142 * @since 3.0
143 */
144 @Override
145 public void serialize(ByteBuffer bufferOut) {
146 getLocationInfo().serialize(bufferOut);
032ecd45 147 }
a3fc8213 148}
This page took 0.074579 seconds and 5 git commands to generate.