tmf: Consolidate constructors in TmfExperiment
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / internal / tmf / core / trace / TmfExperimentLocation.java
CommitLineData
8c8bf09f 1/*******************************************************************************
61759503 2 * Copyright (c) 2009, 2013 Ericsson
9b749023 3 *
8c8bf09f
ASL
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
9b749023 8 *
8c8bf09f 9 * Contributors:
0316808c
FC
10 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Updated as per TMF Trace Model 1.0
ea271da6 12 * Patrick Tasse - Updated for ranks in experiment location
8c8bf09f
ASL
13 *******************************************************************************/
14
2bdf0193 15package org.eclipse.tracecompass.internal.tmf.core.trace;
8c8bf09f 16
032ecd45
MAL
17import java.nio.ByteBuffer;
18
2bdf0193 19import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation;
8c8bf09f 20
d62bb185 21
8c8bf09f 22/**
0316808c
FC
23 * The experiment location in TMF.
24 * <p>
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.
8c8bf09f 28 * <p>
0316808c
FC
29 * It is the responsibility of the user the individual trace locations are valid
30 * and that they are matched to the correct trace.
9b749023 31 *
0316808c
FC
32 * @version 1.0
33 * @author Francois Chouinard
9b749023 34 *
0316808c 35 * @see TmfLocationArray
8c8bf09f 36 */
d62bb185 37public final class TmfExperimentLocation implements ITmfLocation {
cb8c854e 38
d62bb185 39 private final TmfLocationArray fLocation;
8c8bf09f 40
0316808c
FC
41 // ------------------------------------------------------------------------
42 // Constructors
43 // ------------------------------------------------------------------------
8f50c396 44
0316808c
FC
45 /**
46 * The standard constructor
9b749023 47 *
0316808c
FC
48 * @param locations the set of trace locations
49 */
50 public TmfExperimentLocation(TmfLocationArray locations) {
cb8c854e 51 fLocation = locations;
0316808c 52 }
8c8bf09f 53
0316808c
FC
54 /**
55 * The copy constructor
9b749023 56 *
0316808c
FC
57 * @param location the other experiment location
58 */
59 public TmfExperimentLocation(TmfExperimentLocation location) {
5976d44a 60 this(location.getLocationInfo());
0316808c 61 }
8c8bf09f 62
0316808c
FC
63 // ------------------------------------------------------------------------
64 // Object
65 // ------------------------------------------------------------------------
66
0316808c
FC
67 @Override
68 @SuppressWarnings("nls")
69 public String toString() {
ea271da6
PT
70 StringBuilder result = new StringBuilder("TmfExperimentLocation [");
71 result.append(fLocation.toString());
0316808c
FC
72 result.append("]");
73 return result.toString();
74 }
75
6e85c58d
FC
76 @Override
77 public int hashCode() {
980a93c6
PT
78 final int prime = 31;
79 int result = 1;
80 result = prime * result + ((fLocation != null) ? fLocation.hashCode() : 0);
81 return result;
6e85c58d
FC
82 }
83
84 @Override
85 public boolean equals(Object obj) {
0316808c 86 if (this == obj) {
6e85c58d 87 return true;
0316808c 88 }
980a93c6 89 if (obj == null) {
6e85c58d 90 return false;
0316808c
FC
91 }
92 if (getClass() != obj.getClass()) {
6e85c58d 93 return false;
0316808c 94 }
980a93c6
PT
95 final TmfExperimentLocation other = (TmfExperimentLocation) obj;
96 if (fLocation == null) {
97 if (other.fLocation != null) {
98 return false;
99 }
100 } else if (!fLocation.equals(other.fLocation)) {
101 return false;
102 }
6e85c58d
FC
103 return true;
104 }
105
cb8c854e 106 @Override
5976d44a 107 public TmfLocationArray getLocationInfo() {
cb8c854e
FC
108 return fLocation;
109 }
110
032ecd45
MAL
111 @Override
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]);
118 }
119 }
8c8bf09f 120}
This page took 0.076671 seconds and 5 git commands to generate.