1 /*******************************************************************************
2 * Copyright (c) 2009, 2013 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made 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 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Updated as per TMF Trace Model 1.0
12 * Patrick Tasse - Updated for ranks in experiment location
13 *******************************************************************************/
15 package org
.eclipse
.tracecompass
.internal
.tmf
.core
.trace
;
17 import java
.nio
.ByteBuffer
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.location
.ITmfLocation
;
23 * The experiment location in TMF.
25 * An experiment location is actually the set of locations of the traces it
26 * contains. By setting the individual traces to their corresponding locations,
27 * the experiment can be positioned to read the next chronological event.
29 * It is the responsibility of the user the individual trace locations are valid
30 * and that they are matched to the correct trace.
33 * @author Francois Chouinard
35 * @see TmfLocationArray
37 public final class TmfExperimentLocation
implements ITmfLocation
{
39 private final TmfLocationArray fLocation
;
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
46 * The standard constructor
48 * @param locations the set of trace locations
50 public TmfExperimentLocation(TmfLocationArray locations
) {
51 fLocation
= locations
;
55 * The copy constructor
57 * @param location the other experiment location
59 public TmfExperimentLocation(TmfExperimentLocation location
) {
60 this(location
.getLocationInfo());
63 // ------------------------------------------------------------------------
65 // ------------------------------------------------------------------------
68 @SuppressWarnings("nls")
69 public String
toString() {
70 StringBuilder result
= new StringBuilder("TmfExperimentLocation [");
71 result
.append(fLocation
.toString());
73 return result
.toString();
77 public int hashCode() {
80 result
= prime
* result
+ ((fLocation
!= null) ? fLocation
.hashCode() : 0);
85 public boolean equals(Object obj
) {
92 if (getClass() != obj
.getClass()) {
95 final TmfExperimentLocation other
= (TmfExperimentLocation
) obj
;
96 if (fLocation
== null) {
97 if (other
.fLocation
!= null) {
100 } else if (!fLocation
.equals(other
.fLocation
)) {
107 public TmfLocationArray
getLocationInfo() {
112 public void serialize(ByteBuffer bufferOut
) {
113 ITmfLocation
[] locations
= fLocation
.getLocations();
114 long[] ranks
= fLocation
.getRanks();
115 for (int i
= 0; i
< locations
.length
; ++i
) {
116 locations
[i
].serialize(bufferOut
);
117 bufferOut
.putLong(ranks
[i
]);