1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.trace
;
17 * <b><u>TmfContext</u></b>
19 * Trace context structure. It ties a trace location to an event rank. The
20 * context should be enough to restore the trace state so the corresponding
23 public class TmfContext
implements ITmfContext
, Cloneable
{
25 private ITmfLocation
<?
> fLocation
;
28 // ------------------------------------------------------------------------
30 // ------------------------------------------------------------------------
32 public TmfContext(ITmfLocation
<?
> loc
, long rank
) {
37 public TmfContext(ITmfLocation
<?
> location
) {
38 this(location
, UNKNOWN_RANK
);
41 public TmfContext(TmfContext other
) {
42 this(other
.fLocation
, other
.fRank
);
46 this(null, UNKNOWN_RANK
);
49 // ------------------------------------------------------------------------
51 // ------------------------------------------------------------------------
54 public void setLocation(ITmfLocation
<?
> location
) {
59 public ITmfLocation
<?
> getLocation() {
64 public void setRank(long rank
) {
69 public long getRank() {
74 public void updateRank(int delta
) {
80 public boolean isValidRank() {
81 return fRank
!= UNKNOWN_RANK
;
84 // ------------------------------------------------------------------------
86 // ------------------------------------------------------------------------
89 public int hashCode() {
91 result
= 37 * result
+ fLocation
.hashCode();
92 result
= 37 * result
+ (int) (fRank ^
(fRank
>>> 32));
97 public boolean equals(Object other
) {
101 if (!(other
instanceof TmfContext
)) {
104 TmfContext o
= (TmfContext
) other
;
105 return fLocation
.equals(o
.fLocation
) && (fRank
== o
.fRank
);
109 public String
toString() {
110 return "[TmfContext(" + fLocation
.toString() + "," + fRank
+ ")]";
114 public TmfContext
clone() {
115 TmfContext clone
= null;
117 clone
= (TmfContext
) super.clone();
118 clone
.fLocation
= fLocation
.clone();
120 } catch (CloneNotSupportedException e
) {